{"action":"created","comment":{"url":"https://api.github.com/repos/linetools/linetools/pulls/comments/45552856","id":45552856,"diff_hunk":"@@ -0,0 +1,232 @@\n+\"\"\"\n+#;+ \n+#; NAME:\n+#; spectralline\n+#;    Version 1.0\n+#;\n+#; PURPOSE:\n+#;    Module for SpectralLine class\n+#;   23-Jun-2015 by JXP\n+#;-\n+#;------------------------------------------------------------------------------\n+\"\"\"\n+from __future__ import print_function, absolute_import, division, unicode_literals\n+\n+# Python 2 & 3 compatibility\n+try:\n+    basestring\n+except NameError:\n+    basestring = str\n+\n+import pdb\n+\n+from astropy import constants as const\n+from astropy import units as u\n+from astropy.coordinates import SkyCoord\n+from astropy.table import QTable, Column\n+\n+from specutils import Spectrum1D\n+\n+#import xastropy.atomic as xatom\n+#from xastropy.stats import basic as xsb\n+#from xastropy.xutils import xdebug as xdb\n+\n+# Class for Components\n+class AbsComponent(object):\n+    \"\"\"Class for a spectral line.  Emission or absorption \n+    Attributes\n+    ----------\n+    coord : SkyCoord\n+    Zion : tuple \n+       Atomic number, ion -- (int,int) \n+       e.g. (8,1) for OI\n+    zcomp : float\n+       Component redshift\n+    vlim : Quantity array\n+       Velocity limits of the component\n+       e.g.  [-300,300]*u.km/u.s\n+    A : int\n+        Atomic mass -- used to distinguish isotopes\n+    Ej : Quantity\n+       Energy of lower level (1/cm)\n+    \"\"\"\n+    @classmethod\n+    def from_abslines(cls, abslines):\n+        \"\"\"Instantiate from a list of AbsLine objects\n+        Parameters\n+        ----------\n+        abslines : list \n+          List of AbsLine objects\n+        \"\"\"\n+        # Check\n+        if not isinstance(abslines,list):\n+            raise IOError('Need a list of AbsLine objects')\n+        # Instantiate with the first line\n+        init_line = abslines[0]\n+        slf = cls( init_line.attrib['coord'],\n+           (init_line.data['Z'],init_line.data['ion']),\n+           init_line.attrib['z'], init_line.analy['vlim']) \n+        slf._abslines.append(init_line)\n+        # Append with component checking\n+        if len(abslines) > 1:\n+            for absline in abslines[1:]:\n+                slf.add_absline(absline)\n+        # Return\n+        return slf\n+\n+    # Initialize with wavelength\n+    def __init__(self, radec, Zion, z, vlim, Ej=0./u.cm, A=None, Ntup=None):\n+        \"\"\"  Initiator\n+\n+        Parameters\n+        ----------\n+        radec : tuple or SkyCoord\n+          (RA,DEC) in deg\n+        Zion : tuple \n+          Atomic number, ion -- (int,int) \n+             e.g. (8,1) for OI\n+        z : float\n+          Absorption redshift\n+        vlim : Quantity array\n+          Velocity limits of the component\n+          e.g.  [-300,300]*u.km/u.s\n+        A : int, optional\n+          Atomic mass -- used to distinguish isotopes\n+        Ntup : tuple\n+          (int,float,float)\n+          (flgN,logN,sigN)\n+          flgN : Flag describing N measurement\n+          logN : log10 N column density\n+          sigN : Error in log10 N\n+        Ej : Quantity, optional\n+           Energy of lower level (1/cm)\n+        \"\"\"\n+\n+        # Required\n+        if isinstance(radec,(tuple)):\n+            self.coord = SkyCoord(ra=radec[0], dec=radec[1])\n+        elif isinstance(radec,SkyCoord):\n+            self.coord = radec\n+        self.Zion = Zion\n+        self.zcomp = z\n+        self.vlim = vlim\n+\n+        # Optional\n+        self.A = A\n+        self.Ej = Ej\n+        if Ntup is not None:\n+            self.flgN = Ntup[0]\n+            self.logN = Ntup[1]\n+            self.sigN = Ntup[2]\n+\n+        # Other\n+        self._abslines = []\n+\n+    def add_absline(self,absline):\n+        \"\"\"Add an AbsLine object to the component if it satisfies\n+        all of the rules.\n+        For velocities, we demands that the new line has a velocity\n+          range that is fully encompassed by the component.\n+\n+        Parameters\n+        ----------\n+        absline : AbsLine\n+        \"\"\"\n+        # Perform easy checks\n+        test = self.coord.separation(absline.attrib['coord']) < 0.1*u.arcsec","path":"linetools/isgm/abscomponent.py","position":136,"original_position":136,"commit_id":"4dd699c31af03bec3bb071e9a51bfd3d148809e4","original_commit_id":"4dd699c31af03bec3bb071e9a51bfd3d148809e4","user":{"login":"profxj","id":3998093,"avatar_url":"https://avatars.githubusercontent.com/u/3998093?v=3","gravatar_id":"","url":"https://api.github.com/users/profxj","html_url":"https://github.com/profxj","followers_url":"https://api.github.com/users/profxj/followers","following_url":"https://api.github.com/users/profxj/following{/other_user}","gists_url":"https://api.github.com/users/profxj/gists{/gist_id}","starred_url":"https://api.github.com/users/profxj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/profxj/subscriptions","organizations_url":"https://api.github.com/users/profxj/orgs","repos_url":"https://api.github.com/users/profxj/repos","events_url":"https://api.github.com/users/profxj/events{/privacy}","received_events_url":"https://api.github.com/users/profxj/received_events","type":"User","site_admin":false},"body":"Added as a parameter.  \r\n\r\nI think it should be here.","created_at":"2015-11-22T00:16:33Z","updated_at":"2015-11-22T00:16:33Z","html_url":"https://github.com/linetools/linetools/pull/84#discussion_r45552856","pull_request_url":"https://api.github.com/repos/linetools/linetools/pulls/84","_links":{"self":{"href":"https://api.github.com/repos/linetools/linetools/pulls/comments/45552856"},"html":{"href":"https://github.com/linetools/linetools/pull/84#discussion_r45552856"},"pull_request":{"href":"https://api.github.com/repos/linetools/linetools/pulls/84"}}},"pull_request":{"url":"https://api.github.com/repos/linetools/linetools/pulls/84","id":51443498,"html_url":"https://github.com/linetools/linetools/pull/84","diff_url":"https://github.com/linetools/linetools/pull/84.diff","patch_url":"https://github.com/linetools/linetools/pull/84.patch","issue_url":"https://api.github.com/repos/linetools/linetools/issues/84","number":84,"state":"open","locked":false,"title":"AbsComponent class","user":{"login":"profxj","id":3998093,"avatar_url":"https://avatars.githubusercontent.com/u/3998093?v=3","gravatar_id":"","url":"https://api.github.com/users/profxj","html_url":"https://github.com/profxj","followers_url":"https://api.github.com/users/profxj/followers","following_url":"https://api.github.com/users/profxj/following{/other_user}","gists_url":"https://api.github.com/users/profxj/gists{/gist_id}","starred_url":"https://api.github.com/users/profxj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/profxj/subscriptions","organizations_url":"https://api.github.com/users/profxj/orgs","repos_url":"https://api.github.com/users/profxj/repos","events_url":"https://api.github.com/users/profxj/events{/privacy}","received_events_url":"https://api.github.com/users/profxj/received_events","type":"User","site_admin":false},"body":"Have put together this Class after extensive discussion with Nicolas\nwho should review it carefully.\n\nCurrent PR includes documentation and tests and \na few simple methods.\n\nAm starting on other, more sophisticated methods now\n(e.g. curve-of-growth), but want this PR approved before\nincluding those.","created_at":"2015-11-21T15:38:25Z","updated_at":"2015-11-22T00:16:33Z","closed_at":null,"merged_at":null,"merge_commit_sha":"abf7dcd1a5854a5c0d52e37b7a803cef14576a82","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/linetools/linetools/pulls/84/commits","review_comments_url":"https://api.github.com/repos/linetools/linetools/pulls/84/comments","review_comment_url":"https://api.github.com/repos/linetools/linetools/pulls/comments{/number}","comments_url":"https://api.github.com/repos/linetools/linetools/issues/84/comments","statuses_url":"https://api.github.com/repos/linetools/linetools/statuses/4dd699c31af03bec3bb071e9a51bfd3d148809e4","head":{"label":"profxj:component","ref":"component","sha":"4dd699c31af03bec3bb071e9a51bfd3d148809e4","user":{"login":"profxj","id":3998093,"avatar_url":"https://avatars.githubusercontent.com/u/3998093?v=3","gravatar_id":"","url":"https://api.github.com/users/profxj","html_url":"https://github.com/profxj","followers_url":"https://api.github.com/users/profxj/followers","following_url":"https://api.github.com/users/profxj/following{/other_user}","gists_url":"https://api.github.com/users/profxj/gists{/gist_id}","starred_url":"https://api.github.com/users/profxj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/profxj/subscriptions","organizations_url":"https://api.github.com/users/profxj/orgs","repos_url":"https://api.github.com/users/profxj/repos","events_url":"https://api.github.com/users/profxj/events{/privacy}","received_events_url":"https://api.github.com/users/profxj/received_events","type":"User","site_admin":false},"repo":{"id":36232893,"name":"linetools","full_name":"profxj/linetools","owner":{"login":"profxj","id":3998093,"avatar_url":"https://avatars.githubusercontent.com/u/3998093?v=3","gravatar_id":"","url":"https://api.github.com/users/profxj","html_url":"https://github.com/profxj","followers_url":"https://api.github.com/users/profxj/followers","following_url":"https://api.github.com/users/profxj/following{/other_user}","gists_url":"https://api.github.com/users/profxj/gists{/gist_id}","starred_url":"https://api.github.com/users/profxj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/profxj/subscriptions","organizations_url":"https://api.github.com/users/profxj/orgs","repos_url":"https://api.github.com/users/profxj/repos","events_url":"https://api.github.com/users/profxj/events{/privacy}","received_events_url":"https://api.github.com/users/profxj/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/profxj/linetools","description":"","fork":true,"url":"https://api.github.com/repos/profxj/linetools","forks_url":"https://api.github.com/repos/profxj/linetools/forks","keys_url":"https://api.github.com/repos/profxj/linetools/keys{/key_id}","collaborators_url":"https://api.github.com/repos/profxj/linetools/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/profxj/linetools/teams","hooks_url":"https://api.github.com/repos/profxj/linetools/hooks","issue_events_url":"https://api.github.com/repos/profxj/linetools/issues/events{/number}","events_url":"https://api.github.com/repos/profxj/linetools/events","assignees_url":"https://api.github.com/repos/profxj/linetools/assignees{/user}","branches_url":"https://api.github.com/repos/profxj/linetools/branches{/branch}","tags_url":"https://api.github.com/repos/profxj/linetools/tags","blobs_url":"https://api.github.com/repos/profxj/linetools/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/profxj/linetools/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/profxj/linetools/git/refs{/sha}","trees_url":"https://api.github.com/repos/profxj/linetools/git/trees{/sha}","statuses_url":"https://api.github.com/repos/profxj/linetools/statuses/{sha}","languages_url":"https://api.github.com/repos/profxj/linetools/languages","stargazers_url":"https://api.github.com/repos/profxj/linetools/stargazers","contributors_url":"https://api.github.com/repos/profxj/linetools/contributors","subscribers_url":"https://api.github.com/repos/profxj/linetools/subscribers","subscription_url":"https://api.github.com/repos/profxj/linetools/subscription","commits_url":"https://api.github.com/repos/profxj/linetools/commits{/sha}","git_commits_url":"https://api.github.com/repos/profxj/linetools/git/commits{/sha}","comments_url":"https://api.github.com/repos/profxj/linetools/comments{/number}","issue_comment_url":"https://api.github.com/repos/profxj/linetools/issues/comments{/number}","contents_url":"https://api.github.com/repos/profxj/linetools/contents/{+path}","compare_url":"https://api.github.com/repos/profxj/linetools/compare/{base}...{head}","merges_url":"https://api.github.com/repos/profxj/linetools/merges","archive_url":"https://api.github.com/repos/profxj/linetools/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/profxj/linetools/downloads","issues_url":"https://api.github.com/repos/profxj/linetools/issues{/number}","pulls_url":"https://api.github.com/repos/profxj/linetools/pulls{/number}","milestones_url":"https://api.github.com/repos/profxj/linetools/milestones{/number}","notifications_url":"https://api.github.com/repos/profxj/linetools/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/profxj/linetools/labels{/name}","releases_url":"https://api.github.com/repos/profxj/linetools/releases{/id}","created_at":"2015-05-25T13:29:45Z","updated_at":"2015-05-25T13:29:45Z","pushed_at":"2015-11-21T18:28:50Z","git_url":"git://github.com/profxj/linetools.git","ssh_url":"git@github.com:profxj/linetools.git","clone_url":"https://github.com/profxj/linetools.git","svn_url":"https://github.com/profxj/linetools","homepage":null,"size":5941,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"linetools:master","ref":"master","sha":"aadc39ab4700984921a883d1d7afaae654d80206","user":{"login":"linetools","id":12589255,"avatar_url":"https://avatars.githubusercontent.com/u/12589255?v=3","gravatar_id":"","url":"https://api.github.com/users/linetools","html_url":"https://github.com/linetools","followers_url":"https://api.github.com/users/linetools/followers","following_url":"https://api.github.com/users/linetools/following{/other_user}","gists_url":"https://api.github.com/users/linetools/gists{/gist_id}","starred_url":"https://api.github.com/users/linetools/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/linetools/subscriptions","organizations_url":"https://api.github.com/users/linetools/orgs","repos_url":"https://api.github.com/users/linetools/repos","events_url":"https://api.github.com/users/linetools/events{/privacy}","received_events_url":"https://api.github.com/users/linetools/received_events","type":"Organization","site_admin":false},"repo":{"id":36200517,"name":"linetools","full_name":"linetools/linetools","owner":{"login":"linetools","id":12589255,"avatar_url":"https://avatars.githubusercontent.com/u/12589255?v=3","gravatar_id":"","url":"https://api.github.com/users/linetools","html_url":"https://github.com/linetools","followers_url":"https://api.github.com/users/linetools/followers","following_url":"https://api.github.com/users/linetools/following{/other_user}","gists_url":"https://api.github.com/users/linetools/gists{/gist_id}","starred_url":"https://api.github.com/users/linetools/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/linetools/subscriptions","organizations_url":"https://api.github.com/users/linetools/orgs","repos_url":"https://api.github.com/users/linetools/repos","events_url":"https://api.github.com/users/linetools/events{/privacy}","received_events_url":"https://api.github.com/users/linetools/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/linetools/linetools","description":"A package for the analysis of 1d astronomical spectra, especially quasar and galaxy spectra.","fork":false,"url":"https://api.github.com/repos/linetools/linetools","forks_url":"https://api.github.com/repos/linetools/linetools/forks","keys_url":"https://api.github.com/repos/linetools/linetools/keys{/key_id}","collaborators_url":"https://api.github.com/repos/linetools/linetools/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/linetools/linetools/teams","hooks_url":"https://api.github.com/repos/linetools/linetools/hooks","issue_events_url":"https://api.github.com/repos/linetools/linetools/issues/events{/number}","events_url":"https://api.github.com/repos/linetools/linetools/events","assignees_url":"https://api.github.com/repos/linetools/linetools/assignees{/user}","branches_url":"https://api.github.com/repos/linetools/linetools/branches{/branch}","tags_url":"https://api.github.com/repos/linetools/linetools/tags","blobs_url":"https://api.github.com/repos/linetools/linetools/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/linetools/linetools/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/linetools/linetools/git/refs{/sha}","trees_url":"https://api.github.com/repos/linetools/linetools/git/trees{/sha}","statuses_url":"https://api.github.com/repos/linetools/linetools/statuses/{sha}","languages_url":"https://api.github.com/repos/linetools/linetools/languages","stargazers_url":"https://api.github.com/repos/linetools/linetools/stargazers","contributors_url":"https://api.github.com/repos/linetools/linetools/contributors","subscribers_url":"https://api.github.com/repos/linetools/linetools/subscribers","subscription_url":"https://api.github.com/repos/linetools/linetools/subscription","commits_url":"https://api.github.com/repos/linetools/linetools/commits{/sha}","git_commits_url":"https://api.github.com/repos/linetools/linetools/git/commits{/sha}","comments_url":"https://api.github.com/repos/linetools/linetools/comments{/number}","issue_comment_url":"https://api.github.com/repos/linetools/linetools/issues/comments{/number}","contents_url":"https://api.github.com/repos/linetools/linetools/contents/{+path}","compare_url":"https://api.github.com/repos/linetools/linetools/compare/{base}...{head}","merges_url":"https://api.github.com/repos/linetools/linetools/merges","archive_url":"https://api.github.com/repos/linetools/linetools/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/linetools/linetools/downloads","issues_url":"https://api.github.com/repos/linetools/linetools/issues{/number}","pulls_url":"https://api.github.com/repos/linetools/linetools/pulls{/number}","milestones_url":"https://api.github.com/repos/linetools/linetools/milestones{/number}","notifications_url":"https://api.github.com/repos/linetools/linetools/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/linetools/linetools/labels{/name}","releases_url":"https://api.github.com/repos/linetools/linetools/releases{/id}","created_at":"2015-05-25T00:15:17Z","updated_at":"2015-11-17T23:54:48Z","pushed_at":"2015-11-21T23:47:42Z","git_url":"git://github.com/linetools/linetools.git","ssh_url":"git@github.com:linetools/linetools.git","clone_url":"https://github.com/linetools/linetools.git","svn_url":"https://github.com/linetools/linetools","homepage":"","size":5923,"stargazers_count":3,"watchers_count":3,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":6,"forks":4,"open_issues":6,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/linetools/linetools/pulls/84"},"html":{"href":"https://github.com/linetools/linetools/pull/84"},"issue":{"href":"https://api.github.com/repos/linetools/linetools/issues/84"},"comments":{"href":"https://api.github.com/repos/linetools/linetools/issues/84/comments"},"review_comments":{"href":"https://api.github.com/repos/linetools/linetools/pulls/84/comments"},"review_comment":{"href":"https://api.github.com/repos/linetools/linetools/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/linetools/linetools/pulls/84/commits"},"statuses":{"href":"https://api.github.com/repos/linetools/linetools/statuses/4dd699c31af03bec3bb071e9a51bfd3d148809e4"}}}}