本文整理汇总了Python中cc.tools.io.DataIO.findString方法的典型用法代码示例。如果您正苦于以下问题:Python DataIO.findString方法的具体用法?Python DataIO.findString怎么用?Python DataIO.findString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cc.tools.io.DataIO
的用法示例。
在下文中一共展示了DataIO.findString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: parseProfile
# 需要导入模块: from cc.tools.io import DataIO [as 别名]
# 或者: from cc.tools.io.DataIO import findString [as 别名]
def parseProfile(self):
'''
Parse the sphinx file 2, which includes all line profile info.
The output is stored in dict self['sph2'].
'''
self['sph2'] = dict()
self['sph2']['nobeam'] = dict()
self['sph2']['beam'] = dict()
self['sph2']['nobeam_cont'] = dict()
self['sph2']['beam_cont'] = dict()
data = self.getFile(wildcard='2',delimiter=' ')
data_col_1 = [d[0] for d in data]
data_i = 6
data_j = DataIO.findString(data_i,data_col_1)
self['sph2']['nobeam']['velocity'] = array([float(line[0])
for line in data[data_i:data_j]])
#-- Reverse this flux grid. Sphinx output files give the mirrored
# flux grid for the associated velocity grid.
self['sph2']['nobeam']['flux'] = array([DataIO.convertFloat(line[-1],\
nans=1)
for line in data[data_i:data_j]])
self['sph2']['nobeam']['flux'] = self['sph2']['nobeam']['flux'][::-1]
data_k = data_j + 4
data_l = DataIO.findString(data_k,data_col_1)
self['sph2']['beam']['velocity'] = array([float(line[0])
for line in data[data_k:data_l]])
self['sph2']['beam']['flux'] = array([float(line[-1])
for line in data[data_k:data_l]])
self['sph2']['beam']['norm_flux'] = array([float(line[1])
for line in data[data_k:data_l]])
self['sph2']['beam']['tmb'] = array([float(line[2])
for line in data[data_k:data_l]])
#-- Set the continuum value for the different profiles
self.setContinuum('nobeam','flux')
for lp in ['flux','norm_flux','tmb']:
self.setContinuum('beam',lp)
#-- Check if the velocity is correctly monotonously increasing
if self['sph2']['beam']['velocity'][0] > self['sph2']['beam']['velocity'][-1]:
self['sph2']['beam']['velocity'] = self['sph2']['beam']['velocity'][::-1]
self['sph2']['beam']['flux'] = self['sph2']['beam']['flux'][::-1]
self['sph2']['beam']['norm_flux'] = self['sph2']['beam']['norm_flux'][::-1]
self['sph2']['beam']['tmb'] = self['sph2']['beam']['tmb'][::-1]
if self['sph2']['nobeam']['velocity'][0] > self['sph2']['nobeam']['velocity'][-1]:
self['sph2']['nobeam']['velocity'] = self['sph2']['nobeam']['velocity'][::-1]
self['sph2']['nobeam']['flux'] = self['sph2']['nobeam']['flux'][::-1]
#-- Check for NaNs in the profile.
if True in list(isnan(self['sph2']['nobeam']['flux'])):
self.nans_present = True
print "WARNING! There are NaN's in the intrinsic line profile " + \
"with model id %s:"\
%(os.path.split(os.path.split(self.fn)[0])[1])
print os.path.split(self.fn.replace('sph*','sph2'))[1]
示例2: parseProfile
# 需要导入模块: from cc.tools.io import DataIO [as 别名]
# 或者: from cc.tools.io.DataIO import findString [as 别名]
def parseProfile(self):
"""
Parse the sphinx file 2, which includes all line profile info.
The output is stored in dict self.sph2.
"""
self.sph2 = dict()
self.contents["sph2"] = self.sph2
self.sph2["nobeam"] = dict()
self.sph2["beam"] = dict()
self.sph2["nobeam_cont"] = dict()
self.sph2["beam_cont"] = dict()
data = self.getFile(self.filename.replace("*", "2"))
data_col_1 = [d[0] for d in data]
data_i = 6
data_j = DataIO.findString(data_i, data_col_1)
self.sph2["nobeam"]["velocity"] = array([float(line[0]) for line in data[data_i:data_j]])
# -- Reverse this flux grid. Sphinx output files give the mirrored
# flux grid for the associated velocity grid.
self.sph2["nobeam"]["flux"] = array([DataIO.convertFloat(line[-1], nans=1) for line in data[data_i:data_j]])
self.sph2["nobeam"]["flux"] = self.sph2["nobeam"]["flux"][::-1]
data_k = data_j + 4
data_l = DataIO.findString(data_k, data_col_1)
self.sph2["beam"]["velocity"] = array([float(line[0]) for line in data[data_k:data_l]])
self.sph2["beam"]["flux"] = array([float(line[-1]) for line in data[data_k:data_l]])
self.sph2["beam"]["norm_flux"] = array([float(line[1]) for line in data[data_k:data_l]])
self.sph2["beam"]["tmb"] = array([float(line[2]) for line in data[data_k:data_l]])
self.setContinuum("nobeam", "flux")
for lp in ["flux", "norm_flux", "tmb"]:
self.setContinuum("beam", lp)
if self.sph2["beam"]["velocity"][0] > self.sph2["beam"]["velocity"][-1]:
self.sph2["beam"]["velocity"] = self.sph2["beam"]["velocity"][::-1]
self.sph2["beam"]["flux"] = self.sph2["beam"]["flux"][::-1]
self.sph2["beam"]["norm_flux"] = self.sph2["beam"]["norm_flux"][::-1]
self.sph2["beam"]["tmb"] = self.sph2["beam"]["tmb"][::-1]
if self.sph2["nobeam"]["velocity"][0] > self.sph2["nobeam"]["velocity"][-1]:
self.sph2["nobeam"]["velocity"] = self.sph2["nobeam"]["velocity"][::-1]
self.sph2["nobeam"]["flux"] = self.sph2["nobeam"]["flux"][::-1]
if True in list(isnan(self.sph2["nobeam"]["flux"])):
self.nans_present = True
print "WARNING! There are NaN's in the intrinsic line profile " + "with model id %s:" % (
os.path.split(os.path.split(self.filename)[0])[1]
)
print os.path.split(self.filename.replace("sph*", "sph2"))[1]