Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LLS: Some edits for the LLS GUI #103

Merged
merged 3 commits into from
Dec 3, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 18 additions & 0 deletions linetools/isgm/abssystem.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,24 @@ def chk_component(self, component):
"""Additional checks on the component"""
return True

def list_of_abslines(self):
""" Generate a list of the absorption lines in this system

Drawn from the components

Returns
-------
abslist : list

"""
abslist = []
for component in self._components:
for iline in component._abslines:
abslist.append(iline)
# Return
return abslist


class GenericAbsSystem(AbsSystem):
"""Class for Generic Absorption Line System
"""
Expand Down
16 changes: 12 additions & 4 deletions linetools/isgm/lls.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from linetools.analysis import absline as ltaa
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should you move lls.py to the IGM package instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not today and this needs to be done now.

from linetools.lists.linelist import LineList
from linetools.isgm.abssystem import AbsSystem, AbsSubSystem
from linetools.isgm.abscomponent import AbsComponent
from linetools.isgm import utils as ltiu
from linetools.isgm.abssurvey import AbslineSurvey
from linetools.abund import ions as ltai
Expand Down Expand Up @@ -253,15 +254,20 @@ def get_ions(self, use_Nfile=False, idict=None, update_zvlim=True, linelist=None
else:
raise ValueError("Need an option in get_ions")

def fill_lls_lines(self, bval=20.*u.km/u.s):
def fill_lls_lines(self, bval=20.*u.km/u.s, do_analysis=1):
"""
Generate an HI line list for an LLS.
Goes into self.lls_lines

Now generates a component too.
Should have it check for an existing HI component..

Parameters
----------
bval : float, optional
Doppler parameter in km/s
do_analysis : int, optional
flag for analysis
"""
from linetools.lists import linelist as lll

Expand All @@ -275,10 +281,12 @@ def fill_lls_lines(self, bval=20.*u.km/u.s):
aline.attrib['N'] = 10**self.NHI / u.cm**2
aline.attrib['b'] = bval
aline.attrib['z'] = self.zabs
# Could set RA and DEC too
aline.attrib['RA'] = self.coord.ra
aline.attrib['DEC'] = self.coord.dec
aline.analy['vlim'] = self.vlim
aline.analy['do_analysis'] = do_analysis
aline.attrib['coord'] = self.coord
self.lls_lines.append(aline)
# Generate a component (should remove any previous HI)
self.add_component(AbsComponent.from_abslines(self.lls_lines))

def flux_model(self, spec, smooth=0):
""" Generate a LLS model given an input spectrum
Expand Down
46 changes: 46 additions & 0 deletions linetools/isgm/tests/test_use_abssys.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Module to run tests on generating AbsSystem

from __future__ import print_function, absolute_import, division, unicode_literals

# TEST_UNICODE_LITERALS

import pytest
from astropy import units as u
from astropy.coordinates import SkyCoord
import numpy as np

from linetools.isgm.abscomponent import AbsComponent
from linetools.isgm.abssystem import GenericAbsSystem, LymanAbsSystem
from linetools.spectralline import AbsLine

import pdb

def test_list_of_abslines():
radec = SkyCoord(ra=123.1143*u.deg, dec=-12.4321*u.deg)
# HI Lya, Lyb
lya = AbsLine(1215.670*u.AA)
lya.analy['vlim'] = [-300.,300.]*u.km/u.s
lya.attrib['z'] = 2.92939
lyb = AbsLine(1025.7222*u.AA)
lyb.analy['vlim'] = [-300.,300.]*u.km/u.s
lyb.attrib['z'] = lya.attrib['z']
abscomp = AbsComponent.from_abslines([lya,lyb])
abscomp.coord = radec
# SiII
SiIItrans = ['SiII 1260', 'SiII 1304', 'SiII 1526', 'SiII 1808']
abslines = []
for trans in SiIItrans:
iline = AbsLine(trans)
iline.attrib['z'] = 2.92939
iline.analy['vlim'] = [-250.,80.]*u.km/u.s
abslines.append(iline)
#
SiII_comp = AbsComponent.from_abslines(abslines)
SiII_comp.coord = radec
# Instantiate
gensys = GenericAbsSystem.from_components([abscomp,SiII_comp])
# Now the list
abslines = gensys.list_of_abslines()
# Test
assert len(abslines) == 6