本文整理汇总了Python中linetools.spectralline.AbsLine.analy['datafile']方法的典型用法代码示例。如果您正苦于以下问题:Python AbsLine.analy['datafile']方法的具体用法?Python AbsLine.analy['datafile']怎么用?Python AbsLine.analy['datafile']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类linetools.spectralline.AbsLine
的用法示例。
在下文中一共展示了AbsLine.analy['datafile']方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: parse_absid_file
# 需要导入模块: from linetools.spectralline import AbsLine [as 别名]
# 或者: from linetools.spectralline.AbsLine import analy['datafile'] [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
示例2: generate_line
# 需要导入模块: from linetools.spectralline import AbsLine [as 别名]
# 或者: from linetools.spectralline.AbsLine import analy['datafile'] [as 别名]
def generate_line(self, inp):
''' Generate a new line, if it doesn't exist
Parameters:
----------
inp: tuple
(z,wrest)
'''
# Generate?
if self.grab_line(inp[1]) is None:
#QtCore.pyqtRemoveInputHook()
#xdb.set_trace()
#QtCore.pyqtRestoreInputHook()
newline = AbsLine(inp[1],linelist=self.llist[self.llist['List']])
print('VelPlot: Generating line {:g}'.format(inp[1]))
newline.analy['vlim'] = self.vmnx/2.
newline.attrib['z'] = self.abs_sys.zabs
newline.analy['do_analysis'] = 1 # Init to ok
# Spec file
if self.spec_fil is not None:
newline.analy['datafile'] = self.spec_fil
# Append
self.abs_lines.append(newline)
示例3: jenkins2005
# 需要导入模块: from linetools.spectralline import AbsLine [as 别名]
# 或者: from linetools.spectralline.AbsLine import analy['datafile'] [as 别名]
def jenkins2005():
"""Jenkins, E. et al. 2005, ApJ, 2005, 623, 767
PHL 1811
HST/STIS, FUSE
Metals parsed from Table 1
OI taken from text
Had to input error on columns by hand (JXP)
Total NHI from Lyman series. see Fig 3
M/H from O/H
"""
# Grab ASCII file from ApJ
tab_fil = pyigm_path+"/data/LLS/Literature/jenkins2005.tb1.ascii"
chk_fil = glob.glob(tab_fil)
if len(chk_fil) > 0:
tab_fil = chk_fil[0]
else:
url = 'http://iopscience.iop.org/0004-637X/623/2/767/fulltext/61520.tb1.txt'
print('LLSSurvey: Grabbing table file from {:s}'.format(url))
f = urllib2.urlopen(url)
with open(tab_fil, "wb") as code:
code.write(f.read())
# Setup
radec = '215501.5152-092224.688' # SIMBAD
lls = LLSSystem(name='PHL1811_z0.081', radec=radec, zem=0.192,
zabs=0.080923, vlim=[-100., 100.]*u.km/u.s, NHI=17.98, ZH=-0.19,
sig_NHI=np.array([0.05,0.05]))
lls.lines = [] # Probably not used
# AbsLines
ism = LineList('ISM')
Nsig = {'C IV': 0.4, 'N II': 0.4, 'Si II': 0.05, 'Si IV': 0.25,
'S II': 0.2, 'Fe II': 0.12, 'H I': 0.05, 'S III': 0.06}
# Parse Table
with open(tab_fil,'r') as f:
flines = f.readlines()
ion_dict = {}
for iline in flines:
iline = iline.strip()
if (len(iline) == 0):
continue
# Split on tabs
isplit = iline.split('\t')
# Offset?
ioff = 0
if isplit[0][0] in ['1','2']:
ioff = -1
# Catch bad lines
if (isplit[1+ioff][0:6] in ['1442.0','1443.7','1120.9']): # Skip goofy CII line and CII*
continue
if len(isplit[2+ioff]) == 0:
continue
# Ion
if (len(isplit[0].strip()) > 0) & (isplit[0][0] not in ['1','2']):
ionc = isplit[0].strip()
try:
Zion = ltai.name_ion(ionc)
except KeyError:
pdb.set_trace()
# Generate the Line
try:
newline = AbsLine(float(isplit[2+ioff])*u.AA,linelist=ism, closest=True)
except ValueError:
pdb.set_trace()
newline.attrib['z'] = lls.zabs
# Spectrum
newline.analy['datafile'] = 'STIS' if 'S' in isplit[1] else 'FUSE'
# EW
try:
EWvals = isplit[4+ioff].split(' ')
except IndexError:
pdb.set_trace()
newline.attrib['EW'] = float(EWvals[0])*u.AA/1e3
newline.attrib['sig_EW'] = float(EWvals[2])*u.AA/1e3
newline.attrib['flag_EW'] = 1
if len(isplit) < (5+ioff+1):
continue
# Colm?
#xdb.set_trace()
newline.attrib['sig_logN'] = 0.
if (len(isplit[5+ioff].strip()) > 0) & (isplit[5+ioff].strip() != '\\ldots'):
if isplit[5+ioff][0] == '\\':
ipos = isplit[5+ioff].find(' ')
newline.attrib['logN'] = float(isplit[5+ioff][ipos+1:])
newline.attrib['flag_N'] = 2
elif isplit[5+ioff][0] == '<':
ipos = 0
newline.attrib['logN'] = float(isplit[5+ioff][ipos+1:])
newline.attrib['flag_N'] = 3
elif isplit[5+ioff][0] == '1':
try:
newline.attrib['logN'] = float(isplit[5+ioff][0:5])
except ValueError:
pdb.set_trace()
newline.attrib['flag_N'] = 1
try:
newline.attrib['sig_logN'] = Nsig[ionc]
except KeyError:
print('No error for {:s}'.format(ionc))
else:
#.........这里部分代码省略.........