本文整理汇总了Python中linetools.spectralline.AbsLine.analy['vlim']方法的典型用法代码示例。如果您正苦于以下问题:Python AbsLine.analy['vlim']方法的具体用法?Python AbsLine.analy['vlim']怎么用?Python AbsLine.analy['vlim']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类linetools.spectralline.AbsLine
的用法示例。
在下文中一共展示了AbsLine.analy['vlim']方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_add_component
# 需要导入模块: from linetools.spectralline import AbsLine [as 别名]
# 或者: from linetools.spectralline.AbsLine import analy['vlim'] [as 别名]
def test_add_component():
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
lya.attrib['N'] = 1e17 / u.cm**2
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
# Instantiate
abssys = GenericAbsSystem.from_components([abscomp])
# New component
oi = AbsLine('OI 1302')
oi.analy['vlim'] = [-300.,300.]*u.km/u.s
oi.attrib['z'] = lya.attrib['z']
abscomp2 = AbsComponent.from_abslines([oi])
abscomp2.coord = radec
# Standard
assert abssys.add_component(abscomp2)
# Fail
abssys = GenericAbsSystem.from_components([abscomp])
abscomp2.vlim = [-400.,300.]*u.km/u.s
assert not abssys.add_component(abscomp2)
# Overlap
assert abssys.add_component(abscomp2, overlap_only=True)
示例2: test_multi_components
# 需要导入模块: from linetools.spectralline import AbsLine [as 别名]
# 或者: from linetools.spectralline.AbsLine import analy['vlim'] [as 别名]
def test_multi_components():
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
LLSsys = GenericAbsSystem.from_components([abscomp,SiII_comp])
# Test
assert len(LLSsys._components) == 2
示例3: test_list_of_abslines
# 需要导入模块: from linetools.spectralline import AbsLine [as 别名]
# 或者: from linetools.spectralline.AbsLine import analy['vlim'] [as 别名]
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
# Grab one line
lyb = gensys.get_absline('HI 1025')
np.testing.assert_allclose(lyb.wrest.value, 1025.7222)
lyb = gensys.get_absline(1025.72*u.AA)
np.testing.assert_allclose(lyb.wrest.value, 1025.7222)
示例4: test_init_multi_absline
# 需要导入模块: from linetools.spectralline import AbsLine [as 别名]
# 或者: from linetools.spectralline.AbsLine import analy['vlim'] [as 别名]
def test_init_multi_absline():
# AbsLine(s)
lya = AbsLine(1215.670*u.AA, z=2.92939)
lya.analy['vlim'] = [-300.,300.]*u.km/u.s
lyb = AbsLine(1025.7222*u.AA)
lyb.analy['vlim'] = [-300.,300.]*u.km/u.s
lyb.setz(lya.z)
# Instantiate
abscomp = AbsComponent.from_abslines([lya,lyb])
# Test
assert len(abscomp._abslines) == 2
np.testing.assert_allclose(abscomp.zcomp,2.92939)
示例5: lyman_comp
# 需要导入模块: from linetools.spectralline import AbsLine [as 别名]
# 或者: from linetools.spectralline.AbsLine import analy['vlim'] [as 别名]
def lyman_comp(radec):
# HI Lya, Lyb
lya = AbsLine(1215.670*u.AA)
lya.analy['vlim'] = [-300.,300.]*u.km/u.s
lya.attrib['z'] = 2.92939
lya.attrib['N'] = 1e17 / u.cm**2
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
return abscomp
示例6: test_build_table
# 需要导入模块: from linetools.spectralline import AbsLine [as 别名]
# 或者: from linetools.spectralline.AbsLine import analy['vlim'] [as 别名]
def test_build_table():
# AbsLine(s)
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']
# Instantiate
abscomp = AbsComponent.from_abslines([lya,lyb])
comp_tbl = abscomp.build_table()
# Test
assert isinstance(comp_tbl,QTable)
示例7: fill_lls_lines
# 需要导入模块: from linetools.spectralline import AbsLine [as 别名]
# 或者: from linetools.spectralline.AbsLine import analy['vlim'] [as 别名]
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
# May be replaced by component class (as NT desires)
HIlines = lll.LineList('HI')
self.lls_lines = []
Nval = 10**self.NHI / u.cm**2
for lline in HIlines._data:
aline = AbsLine(lline['wrest'], linelist=HIlines)
# Attributes
aline.attrib['N'] = Nval
aline.attrib['b'] = bval
aline.attrib['z'] = self.zabs
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))
示例8: mk_comp
# 需要导入模块: from linetools.spectralline import AbsLine [as 别名]
# 或者: from linetools.spectralline.AbsLine import analy['vlim'] [as 别名]
def mk_comp(ctype,vlim=[-300.,300]*u.km/u.s,add_spec=False, use_rand=True,
add_trans=False, zcomp=2.92939):
# Read a spectrum Spec
if add_spec:
xspec = lsio.readspec(lt_path+'/spectra/tests/files/UM184_nF.fits')
else:
xspec = None
# AbsLines
if ctype == 'HI':
all_trans = ['HI 1215', 'HI 1025']
elif ctype == 'SiII':
all_trans = ['SiII 1260', 'SiII 1304', 'SiII 1526', 'SiII 1808']
if add_trans:
all_trans += ['SiII 1193']
abslines = []
for trans in all_trans:
iline = AbsLine(trans)
iline.attrib['z'] = zcomp
if use_rand:
rnd = np.random.rand()
else:
rnd = 0.
iline.attrib['logN'] = 13.3 + rnd
iline.attrib['sig_logN'] = 0.15
iline.attrib['flag_N'] = 1
iline.analy['spec'] = xspec
iline.analy['vlim'] = vlim
iline.analy['wvlim'] = iline.wrest * (1 + zcomp + ltu.give_dz(vlim, zcomp))
_,_ = ltaa.linear_clm(iline.attrib) # Loads N, sig_N
abslines.append(iline)
# Component
abscomp = AbsComponent.from_abslines(abslines)
return abscomp, abslines
示例9: test_init_single_absline
# 需要导入模块: from linetools.spectralline import AbsLine [as 别名]
# 或者: from linetools.spectralline.AbsLine import analy['vlim'] [as 别名]
def test_init_single_absline():
# Single AbsLine
lya = AbsLine(1215.670*u.AA)
lya.analy['vlim'] = [-300.,300.]*u.km/u.s
lya.attrib['z'] = 2.92939
abscomp = AbsComponent.from_abslines([lya])
# Test
assert abscomp.Zion[0] == 1
np.testing.assert_allclose(abscomp.zcomp,2.92939)
示例10: test_one_component
# 需要导入模块: from linetools.spectralline import AbsLine [as 别名]
# 或者: from linetools.spectralline.AbsLine import analy['vlim'] [as 别名]
def test_one_component():
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
# Instantiate
HIsys = LymanAbsSystem.from_components([abscomp])
# Test
assert HIsys.abs_type == 'HILyman'
assert len(HIsys._components) == 1
assert HIsys._components[0].Zion[0] == 1
assert HIsys._components[0].Zion[1] == 1
示例11: test_todict
# 需要导入模块: from linetools.spectralline import AbsLine [as 别名]
# 或者: from linetools.spectralline.AbsLine import analy['vlim'] [as 别名]
def test_todict():
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
# Instantiate
HIsys = LymanAbsSystem.from_components([abscomp])
# Dict
adict = HIsys.to_dict()
assert isinstance(adict, dict)
# Instantiate
newsys = AbsSystem.from_dict(adict)
assert isinstance(newsys, AbsSystem)
示例12: test_add_absline
# 需要导入模块: from linetools.spectralline import AbsLine [as 别名]
# 或者: from linetools.spectralline.AbsLine import analy['vlim'] [as 别名]
def test_add_absline():
abscomp,_ = mk_comp('HI', zcomp=0)
abscomp.add_absline(AbsLine('HI 972'), chk_sep=False, chk_vel=False)
with pytest.raises(ValueError):
abscomp.add_absline(AbsLine('HI 949'), vtoler=-10)
# failed addition
bad_absline = AbsLine('CIV 1550')
bad_absline.analy['vlim'] = [500, 1000]*u.km/u.s
bad_absline.attrib['coord'] = SkyCoord(20,20, unit='deg')
abscomp.add_absline(bad_absline)
示例13: test_DLA_from_components
# 需要导入模块: from linetools.spectralline import AbsLine [as 别名]
# 或者: from linetools.spectralline.AbsLine import analy['vlim'] [as 别名]
def test_DLA_from_components():
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
lya.attrib['N'] = 3e20 / u.cm**2
lyb = AbsLine(1025.7222*u.AA)
lyb.analy['vlim'] = [-300.,300.]*u.km/u.s
lyb.attrib['z'] = lya.attrib['z']
lyb.attrib['N'] = 3e20 / u.cm**2
abscomp = AbsComponent.from_abslines([lya,lyb])
abscomp.coord = radec
# Instantiate
HIsys = DLASystem.from_components([abscomp])
# Test
np.testing.assert_allclose(HIsys.NHI, 20.477121254719663)
assert len(HIsys._components) == 1
assert HIsys._components[0].Zion[0] == 1
assert HIsys._components[0].Zion[1] == 1
示例14: test_todict_withjson
# 需要导入模块: from linetools.spectralline import AbsLine [as 别名]
# 或者: from linetools.spectralline.AbsLine import analy['vlim'] [as 别名]
def test_todict_withjson():
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
# Instantiate
HIsys = LymanAbsSystem.from_components([abscomp])
# Dict
adict = HIsys.to_dict()
assert isinstance(adict, dict)
# Verify it is JSON compatible (failing in Python 3)
import io,json
with io.open('tmp.json', 'w', encoding='utf-8') as f:
f.write(unicode(json.dumps(adict, sort_keys=True, indent=4,
separators=(',', ': '))))
示例15: parse_absid_file
# 需要导入模块: from linetools.spectralline import AbsLine [as 别名]
# 或者: from linetools.spectralline.AbsLine import analy['vlim'] [as 别名]
def parse_absid_file(self, abs_fil):
from xastropy import spec as xxspec
if self.linelist is None:
self.linelist = LineList('ISM')
# FITS binary table
hdu = fits.open(abs_fil)
table = hdu[1].data
newz = table[0]['ZABS']
if (self.zabs > 0.) & (np.abs(self.zabs-newz) > 1e-4):
print('WARNING: Updating zabs from {:s}'.format(abs_fil))
self.zabs = newz
self.absid_file = abs_fil
# Load up lines
for row in table:
aline = AbsLine(row['WREST']*u.AA, linelist=self.linelist,
closest=True)
# Velocity limits and flags
try:
aline.analy['vlim'] = row['VLIM'] * u.km/u.s
except KeyError:
aline.analy['vlim'] = row['DV'] * u.km/u.s
try:
aline.analy['do_analysis'] = row['do_analysis']
except KeyError:
aline.analy['do_analysis'] = row['FLG_ANLY']
aline.analy['flg_eye'] = row['FLG_EYE']
aline.analy['flg_limit'] = row['FLG_LIMIT']
try:
aline.analy['datafile'] = row['datafile']
except KeyError:
aline.analy['datafile'] = row['DATFIL']
aline.analy['spec'] = None # Spectrum
aline.attrib['z'] = self.zabs
# Append
self.lines.append(aline)
''' OLD FORMAT