Examples for the AbsComponent Class (v0.3) ========================================== :download:`Download ` this notebook. .. code:: python %matplotlib inline # suppress warnings for these examples import warnings warnings.filterwarnings('ignore') .. code:: python # import try: import seaborn as sns; sns.set_style("white") except: pass import astropy.units as u from linetools.spectralline import AbsLine from linetools.isgm import utils as ltiu from linetools.analysis import absline as laa from linetools.spectra import io as lsio from linetools.isgm.abscomponent import AbsComponent import imp lt_path = imp.find_module('linetools')[1] Instantiate ----------- Standard ~~~~~~~~ .. code:: python abscomp = AbsComponent((10.0*u.deg, 45*u.deg), (14,2), 1.0, [-300,300]*u.km/u.s) abscomp .. parsed-literal:: From AbsLines ~~~~~~~~~~~~~ From one line ^^^^^^^^^^^^^ .. code:: python lya = AbsLine(1215.670*u.AA) lya.analy['vlim'] = [-300.,300.]*u.km/u.s lya.attrib['z'] = 2.92939 .. code:: python abscomp = AbsComponent.from_abslines([lya]) print(abscomp) abscomp._abslines .. parsed-literal:: .. parsed-literal:: [] From multiple ^^^^^^^^^^^^^ .. code:: python lyb = AbsLine(1025.7222*u.AA) lyb.analy['vlim'] = [-300.,300.]*u.km/u.s lyb.attrib['z'] = lya.attrib['z'] .. code:: python abscomp = AbsComponent.from_abslines([lya,lyb]) print(abscomp) abscomp._abslines .. parsed-literal:: .. parsed-literal:: [, ] Methods ------- Generate a Component Table ~~~~~~~~~~~~~~~~~~~~~~~~~~ .. code:: python lya.attrib['logN'] = 14.1 lya.attrib['sig_logN'] = 0.15 lya.attrib['flag_N'] = 1 laa.linear_clm(lya.attrib) lyb.attrib['logN'] = 14.15 lyb.attrib['sig_logN'] = 0.19 lyb.attrib['flag_N'] = 1 laa.linear_clm(lyb.attrib) .. parsed-literal:: (, ) .. code:: python abscomp = AbsComponent.from_abslines([lya,lyb]) comp_tbl = abscomp.build_table() comp_tbl .. raw:: html <QTable length=2>
wrestzflag_NlogNsig_logN
Angstrom
float64float64int64float64float64
1215.672.92939114.10.15
1025.72222.92939114.150.19
Synthesize multiple components ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. code:: python SiIItrans = ['SiII 1260', 'SiII 1304', 'SiII 1526'] SiIIlines = [] for trans in SiIItrans: iline = AbsLine(trans) iline.attrib['logN'] = 12.8 + np.random.rand() iline.attrib['sig_logN'] = 0.15 iline.attrib['flag_N'] = 1 iline.attrib['z'] = 2.92939 iline.analy['vlim'] = [-300.,50.]*u.km/u.s _,_ = laa.linear_clm(iline.attrib) SiIIlines.append(iline) SiIIcomp = AbsComponent.from_abslines(SiIIlines) SiIIcomp.synthesize_colm() .. code:: python SiIIlines2 = [] for trans in SiIItrans: iline = AbsLine(trans) iline.attrib['logN'] = 13.3 + np.random.rand() iline.attrib['sig_logN'] = 0.15 iline.attrib['flag_N'] = 1 iline.attrib['z'] = 2.92939 iline.analy['vlim'] = [50.,300.]*u.km/u.s _,_ = laa.linear_clm(iline.attrib) SiIIlines2.append(iline) SiIIcomp2 = AbsComponent.from_abslines(SiIIlines2) SiIIcomp2.synthesize_colm() .. code:: python abscomp.synthesize_colm() [abscomp,SiIIcomp,SiIIcomp2] .. parsed-literal:: [, , ] .. code:: python synth_SiII = ltiu.synthesize_components([SiIIcomp,SiIIcomp2]) synth_SiII .. parsed-literal:: Generate multiple components from abslines ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. code:: python comps = ltiu.build_components_from_abslines([lya,lyb,SiIIlines[0],SiIIlines[1]]) comps .. parsed-literal:: [, ] Generate an Ion Table ~~~~~~~~~~~~~~~~~~~~~ .. code:: python tbl = ltiu.iontable_from_components([abscomp,SiIIcomp,SiIIcomp2]) tbl .. raw:: html <QTable length=2>
ZionAEjzvminvmaxflag_NlogNsig_logN
km / skm / s
int64int64int64float64float64float64float64int64float64float64
1100.02.92939-300.0300.0114.11720248170.117911610801
14200.02.92939-300.0300.0113.90061577330.0811522506077
Stack plot ~~~~~~~~~~ Load a spectrum ^^^^^^^^^^^^^^^ .. code:: python xspec = lsio.readspec(lt_path+'/spectra/tests/files/UM184_nF.fits') lya.analy['spec'] = xspec lyb.analy['spec'] = xspec Show ^^^^ .. code:: python abscomp = AbsComponent.from_abslines([lya,lyb]) abscomp.stack_plot() .. image:: AbsComponent_examples_files/AbsComponent_examples_30_0.png