本文整理汇总了Python中linetools.spectralline.AbsLine.attrib['sig_N']方法的典型用法代码示例。如果您正苦于以下问题:Python AbsLine.attrib['sig_N']方法的具体用法?Python AbsLine.attrib['sig_N']怎么用?Python AbsLine.attrib['sig_N']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类linetools.spectralline.AbsLine
的用法示例。
在下文中一共展示了AbsLine.attrib['sig_N']方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: lyman_comp
# 需要导入模块: from linetools.spectralline import AbsLine [as 别名]
# 或者: from linetools.spectralline.AbsLine import attrib['sig_N'] [as 别名]
def lyman_comp(radec, z=2.92939):
# HI Lya, Lyb
lya = AbsLine(1215.670*u.AA, z=z, linelist=ism)
lya.limits.set([-300.,300.]*u.km/u.s)
lya.attrib['flag_N'] = 1
lya.attrib['N'] = 1e17 / u.cm**2
lya.attrib['sig_N'] = 1e16 / u.cm**2
lya.attrib['coord'] = radec
# Lyb
lyb = AbsLine(1025.7222*u.AA, z=z, linelist=ism)
lyb.limits.set([-300.,300.]*u.km/u.s)
lyb.attrib['coord'] = radec
lyb.attrib['flag_N'] = 1
lyb.attrib['N'] = 1e17 / u.cm**2
lyb.attrib['sig_N'] = 1e16 / u.cm**2
# Build
abscomp = AbsComponent.from_abslines([lya,lyb])
#abscomp.synthesize_colm()
return abscomp
示例2: add_abslines_from_linelist
# 需要导入模块: from linetools.spectralline import AbsLine [as 别名]
# 或者: from linetools.spectralline.AbsLine import attrib['sig_N'] [as 别名]
def add_abslines_from_linelist(self, llist='ISM', wvlim=None, min_Wr=None, **kwargs):
"""
It adds associated AbsLines satisfying some conditions (see parameters below).
Parameters
----------
llist : str
Name of the linetools.lists.linelist.LineList
object where to look for the transition names.
Default is 'ISM', which means the function looks
within `list = LineList('ISM')`.
wvlims : Quantity array, optional
Observed wavelength limits for AbsLines to be added.
e.g. [1200, 2000]*u.AA.
min_Wr : Quantity, optional
Minimum rest-frame equivalent with for AbsLines to be added.
This is calculated in the very low optical depth regime tau0<<1,
where Wr is independent of Doppler parameter or gamma (see eq. 9.15 of
Draine 2011). Still, a column density attribute for the AbsComponent
is needed.
Returns
-------
Adds AbsLine objects to the AbsComponent._abslines list.
Notes
-----
**kwargs are passed to AbsLine.add_absline() method.
"""
# get the transitions from LineList
llist = LineList(llist)
name = ions.ion_name(self.Zion, nspace=0)
transitions = llist.all_transitions(name)
# unify output to be always QTable
if isinstance(transitions, dict):
transitions = llist.from_dict_to_qtable(transitions)
# check wvlims
if wvlim is not None:
cond = (transitions['wrest']*(1+self.zcomp) >= wvlim[0]) & \
(transitions['wrest']*(1+self.zcomp) <= wvlim[1])
transitions = transitions[cond]
# check outputs
if len(transitions) == 0:
warnings.warn("No transitions satisfying the criteria found. Doing nothing.")
return
# loop over the transitions when more than one found
for transition in transitions:
iline = AbsLine(transition['name'], z=self.zcomp)
iline.limits.set(self.vlim)
iline.attrib['coord'] = self.coord
iline.attrib['logN'] = self.logN
iline.attrib['sig_logN'] = self.sig_logN
iline.attrib['flag_N'] = self.flag_N
iline.attrib['N'] = 10**iline.attrib['logN'] / (u.cm * u.cm)
iline.attrib['sig_N'] = 10**iline.attrib['sig_logN'] / (u.cm * u.cm)
for key in self.attrib.keys():
iline.attrib[key] = self.attrib[key]
if min_Wr is not None:
# check logN is defined
logN = self.logN
if logN == 0:
warnings.warn("AbsComponent does not have logN defined. Appending AbsLines "
"regardless of min_Wr.")
else:
N = 10**logN / (u.cm*u.cm)
Wr_iline = iline.get_Wr_from_N(N=N) # valid for the tau0<<1 regime.
if Wr_iline < min_Wr: # do not append
continue
# add the absline
self.add_absline(iline)
示例3: read_clmfile
# 需要导入模块: from linetools.spectralline import AbsLine [as 别名]
# 或者: from linetools.spectralline.AbsLine import attrib['sig_N'] [as 别名]
def read_clmfile(clm_file,linelist=None):
""" Read in a .CLM file in an appropriate manner
NOTE: If program breaks in this function, check the clm to see if it is properly formatted.
RETURNS two dictionaries CLM and LINEDIC. CLM contains the contents of CLM
for the given DLA. THe LINEDIC that is passed (when not None) is updated appropriately.
Keys in the CLM dictionary are:
INST - Instrument used
FITS - a list of fits files
ZABS - absorption redshift
ION - .ION file location
HI - THe HI column and error; [HI, HIerr]
FIX - Any abundances that need fixing from the ION file
VELS - Dictioanry of velocity limits, which is keyed by
FLAGS - Any measurment flags assosicated with VLIM
VLIM - velocity limits in km/s [vmin,vmax]
ELEM - ELement (from get_elem)
See get_elem for properties of LINEDIC
Parameters
----------
clm_file : str
Full path to the .clm file
linelist : LineList
can speed up performance
"""
clm_dict = {}
# Read file
f=open(clm_file, 'r')
arr=f.readlines()
f.close()
nline = len(arr)
# Data files
clm_dict['flg_data'] = int(arr[1][:-1])
clm_dict['fits_files']={}
ii=2
for jj in range(0,6):
if (clm_dict['flg_data'] % (2**(jj+1))) > (2**jj - 1):
clm_dict['fits_files'][2**jj] = arr[ii].strip()
ii += 1
# Redshift
clm_dict['zsys']=float(arr[ii][:-1]) ; ii+=1
clm_dict['ion_fil']=arr[ii].strip() ; ii+=1
# NHI
tmp = arr[ii].split(',') ; ii+=1
if len(tmp) != 2:
raise ValueError('ionic_clm: Bad formatting {:s} in {:s}'
.format(arr[ii-1],clm_file))
clm_dict['NHI']=float(tmp[0])
clm_dict['sigNHI']=float(tmp[1])
# Abundances by hand
numhand=int(arr[ii][:-1]) ; ii+=1
clm_dict['fixabund']={}
if numhand>0:
for jj in range(numhand):
# Atomic number
atom=int(arr[ii][:-1]) ; ii+=1
# Values
tmp = arr[ii].strip().split(',') ; ii+=1
clm_dict['fixabund'][atom]= float(tmp[0]), float(tmp[1]), int(tmp[2])
# Loop on lines
clm_dict['lines'] = {}
while ii < (nline-1):
# No empty lines allowed
if len(arr[ii].strip()) == 0:
break
# Read flag
ionflg = int(arr[ii].strip()); ii+=1
# Read the rest
tmp = arr[ii].split(',') ; ii+=1
if len(tmp) != 4: raise ValueError('ionic_clm: Bad formatting {:s} in {:s}'
.format(arr[ii-1],clm_file))
vmin = float(tmp[1].strip())
vmax = float(tmp[2].strip())
key = float(tmp[0].strip()) # Using a float not string!
# Generate
clm_dict['lines'][key] = AbsLine(key*u.AA,closest=True,linelist=linelist)
clm_dict['lines'][key].attrib['z'] = clm_dict['zsys']
clm_dict['lines'][key].analy['FLAGS'] = ionflg, int(tmp[3].strip())
pdb.set_trace()
# By-hand
if ionflg >= 8:
clm_dict['lines'][key].attrib['N'] = 10.**vmin / u.cm**2
clm_dict['lines'][key].attrib['sig_N'] = (10.**(vmin+vmax) - 10.**(vmin-vmax))/2/u.cm**2
else:
clm_dict['lines'][key].analy['vlim']= [vmin,vmax]*u.km/u.s
# Return
return clm_dict
示例4: add_abslines_from_linelist
# 需要导入模块: from linetools.spectralline import AbsLine [as 别名]
# 或者: from linetools.spectralline.AbsLine import attrib['sig_N'] [as 别名]
def add_abslines_from_linelist(self, llist='ISM', init_name=None, wvlim=None, min_Wr=None, **kwargs):
"""
It adds associated AbsLines satisfying some conditions (see parameters below).
Parameters
----------
llist : str, optional
Name of the linetools.lists.linelist.LineList
object where to look for the transition names.
Default is 'ISM', which means the function looks
within `list = LineList('ISM')`.
init_name : str, optional
Name of the initial transition used to define the AbsComponent
wvlim : Quantity array, optional
Observed wavelength limits for AbsLines to be added.
e.g. [1200, 2000]*u.AA.
min_Wr : Quantity, optional
Minimum rest-frame equivalent with for AbsLines to be added.
This is calculated in the very low optical depth regime tau0<<1,
where Wr is independent of Doppler parameter or gamma (see eq. 9.15 of
Draine 2011). Still, a column density attribute for the AbsComponent
is needed.
Returns
-------
Adds AbsLine objects to the AbsComponent._abslines list.
Notes
-----
**kwargs are passed to AbsLine.add_absline() method.
"""
from linetools.lists import utils as ltlu
# get the transitions from LineList
llist = LineList(llist)
if init_name is None: # we have to guess it
if (self.Zion) == (-1, -1): # molecules
# init_name must be in self.attrib (this is a patch)
init_name = self.attrib['init_name']
else: # atoms
init_name = ions.ion_to_name(self.Zion, nspace=0)
transitions = llist.all_transitions(init_name)
# unify output to be a Table
if isinstance(transitions, dict):
transitions = ltlu.from_dict_to_table(transitions)
# check wvlims
if wvlim is not None:
# Deal with units
wrest = transitions['wrest'].data * transitions['wrest'].unit
# Logic
cond = (wrest*(1+self.zcomp) >= wvlim[0]) & \
(wrest*(1+self.zcomp) <= wvlim[1])
transitions = transitions[cond]
# check outputs
if len(transitions) == 0:
warnings.warn("No transitions satisfying the criteria found. Doing nothing.")
return
# loop over the transitions when more than one found
for transition in transitions:
iline = AbsLine(transition['name'], z=self.zcomp, linelist=llist)
iline.limits.set(self.vlim)
iline.attrib['coord'] = self.coord
iline.attrib['logN'] = self.logN
iline.attrib['sig_logN'] = self.sig_logN
iline.attrib['flag_N'] = self.flag_N
iline.attrib['N'] = 10**iline.attrib['logN'] / (u.cm * u.cm)
iline.attrib['sig_N'] = 10**iline.attrib['sig_logN'] / (u.cm * u.cm)
for key in self.attrib.keys():
iline.attrib[key] = self.attrib[key]
if min_Wr is not None:
# check logN is defined
if self.logN == 0:
pass
else:
N = 10.**self.logN / u.cm**2
Wr_iline = iline.get_Wr_from_N(N=N) # valid for the tau0<<1 regime.
if Wr_iline < min_Wr: # do not append
continue
# add the absline
self.add_absline(iline)