当前位置: 首页>>代码示例>>Python>>正文


Python DataIO.findString方法代码示例

本文整理汇总了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]
开发者ID:IvS-KULeuven,项目名称:ComboCode,代码行数:62,代码来源:SphinxReader.py

示例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]
开发者ID:FungKu01,项目名称:ComboCode,代码行数:50,代码来源:SphinxReader.py


注:本文中的cc.tools.io.DataIO.findString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。