本文整理汇总了Python中linetools.spectralline.AbsLine.analy['flg_inst']方法的典型用法代码示例。如果您正苦于以下问题:Python AbsLine.analy['flg_inst']方法的具体用法?Python AbsLine.analy['flg_inst']怎么用?Python AbsLine.analy['flg_inst']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类linetools.spectralline.AbsLine
的用法示例。
在下文中一共展示了AbsLine.analy['flg_inst']方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: read_ion_file
# 需要导入模块: from linetools.spectralline import AbsLine [as 别名]
# 或者: from linetools.spectralline.AbsLine import analy['flg_inst'] [as 别名]
def read_ion_file(ion_fil,lines=None,components=None,linelist=None,toler=0.05*u.AA):
""" Read in JXP-style .ion file in an appropriate manner
NOTE: If program breaks in this function, check the .ion file
to see if it is properly formatted.
If components is passed in, these are filled as applicable.
Parameters
----------
ion_fil : str
Full path to .ion file
lines : list, optional
List of AbsLine objects [used for historical reasons, mainly]
components : list, optional
List of AbsComponent objects
linelist : LineList
May speed up performance
toler : Quantity, optional
Tolerance for matching wrest
"""
assert False # USE LINETOOLS
# Read
names=('wrest', 'logN', 'sig_logN', 'flag_N', 'flg_inst')
table = ascii.read(ion_fil, format='no_header', names=names)
if components is None:
if lines is None:
lines = []
# Generate AbsLine's
for row in table:
# Generate the line
aline = AbsLine(row['wrest']*u.AA, linelist=linelist, closest=True)
# Set z, RA, DEC, etc.
aline.attrib['z'] = self.zabs
aline.attrib['RA'] = self.coord.ra
aline.attrib['Dec'] = self.coord.dec
aline.attrib['coord'] = self.coord
aline.attrib['logN'] = row['logN']
aline.attrib['sig_logN'] = row['sig_logN']
aline.attrib['flag_N'] = row['flag_N']
aline.analy['flg_inst'] = row['flg_inst']
# Check against existing lines
mt = [kk for kk,oline in enumerate(lines) if oline.ismatch(aline)]
if len(mt) > 0:
mt.reverse()
for imt in mt:
print('read_ion_file: Removing line {:g}'.format(lines[imt].wrest))
lines.pop(imt)
# Append
lines.append(aline)
return lines
else: # Fill entries in components
# Generate look-up table for quick searching
all_wv = []
all_idx = []
for jj,comp in enumerate(components):
for kk,iline in enumerate(comp._abslines):
all_wv.append(iline.wrest)
all_idx.append((jj,kk))
all_wv = u.Quantity(all_wv)
# Loop now
for row in table:
mt = np.where(np.abs(all_wv-row['wrest']*u.AA)<toler)[0]
if len(mt) == 0:
pass
elif len(mt) == 1:
# Fill
jj = all_idx[mt[0]][0]
kk = all_idx[mt[0]][1]
components[jj]._abslines[kk].attrib['flag_N'] = row['flag_N']
components[jj]._abslines[kk].attrib['logN'] = row['logN']
components[jj]._abslines[kk].attrib['sig_logN'] = row['sig_logN']
components[jj]._abslines[kk].analy['flg_inst'] = row['flg_inst']
else:
raise ValueError("Matched multiple lines in read_ion_file")
# Return
return table