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


Python DataIO.getInputData方法代码示例

本文整理汇总了Python中cc.tools.io.DataIO.getInputData方法的典型用法代码示例。如果您正苦于以下问题:Python DataIO.getInputData方法的具体用法?Python DataIO.getInputData怎么用?Python DataIO.getInputData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cc.tools.io.DataIO的用法示例。


在下文中一共展示了DataIO.getInputData方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: setData

# 需要导入模块: from cc.tools.io import DataIO [as 别名]
# 或者: from cc.tools.io.DataIO import getInputData [as 别名]
 def setData(self,**kwargs):
     
     '''
     Select available data.
     
     Based on the data file types in Sed.dat and the available data files.
     
     Also calls the buildPhotometry method to create a photometry file from
     the IvS Sed builder tool
     
     Any keywords required for buildPhotometry can be passed here.
     
     '''
     
     data_types = DataIO.getInputData(keyword='DATA_TYPES',\
                                      filename='Sed.dat')
     abs_errs = DataIO.getInputData(keyword='ABS_ERR',filename='Sed.dat')
     
     if 'Photometric_IvS' in data_types:
         buildPhotometry(self.star_name,**kwargs)
     
     self.data_types = []
     self.data_filenames = []
     self.abs_err = dict()
     for dt,ierr in zip(data_types,abs_errs):
         searchpath = os.path.join(cc.path.dsed,'%s_*%s*.dat'\
                                                %(dt,self.star_name))
         add_files = glob(searchpath)
         for ff in add_files: 
             if ff not in self.data_filenames:
                 self.data_filenames.append(ff)
                 self.data_types.append(dt)
                 self.abs_err[dt] = ierr
开发者ID:IvS-KULeuven,项目名称:ComboCode,代码行数:35,代码来源:Sed.py

示例2: setStarPars

# 需要导入模块: from cc.tools.io import DataIO [as 别名]
# 或者: from cc.tools.io.DataIO import getInputData [as 别名]
 def setStarPars(self):
     
     """
     Set some standard stellar parameters such as Ak and galactic position.
     
     """
     
     self.star_index = DataIO.getInputData().index(self.star_name)
     ll = DataIO.getInputData(keyword='LONG',rindex=self.star_index)
     bb = DataIO.getInputData(keyword='LAT',rindex=self.star_index)
     if self.distance <> None:
         self.ak = em.findext_marshall(ll=ll,bb=bb,distance=self.distance,\
                                       norm='Ak')
         if self.ak is None:
             self.ak = em.findext_drimmel(lng=ll,lat=bb,norm='Ak',\
                                          distance=self.distance)
     if self.ak is None:
         self.ak = DataIO.getInputData(keyword='A_K',rindex=self.star_index)
     snp = DataIO.getInputData(keyword='STAR_NAME_PLOTS',\
                               remove_underscore=1,rindex=self.star_index)
     self.star_name_plots = snp    
     if (abs(ll) < 5.0 or ll > 355.0) and abs(bb) < 5.0:
         self.gal_position = 'GC'
     else:
         self.gal_position = 'ISM'    
开发者ID:FungKu01,项目名称:ComboCode,代码行数:27,代码来源:Sed.py

示例3: readTelescopeProperties

# 需要导入模块: from cc.tools.io import DataIO [as 别名]
# 或者: from cc.tools.io.DataIO import getInputData [as 别名]
def readTelescopeProperties(telescope):

    """
    Read the telescope properties from Telescope.dat. 
    
    This currently includes the telescope size in m, and the default 
    absolute flux calibration uncertainty. 
    
    @param telescope: The telescope requested
    @type telescope: str
    
    @return: The telescope size and absolute flux calibration uncertainty
    @rtype: (float,float)
    
    """

    all_telescopes = DataIO.getInputData(keyword="TELESCOPE", start_index=5, filename="Telescope.dat")
    if "PACS" in telescope:
        telescope = "PACS"
    else:
        telescope = telescope
    try:
        tel_index = all_telescopes.index(telescope)
    except ValueError:
        raise ValueError("%s not found in Telescope.dat." % telescope)

    size = DataIO.getInputData(keyword="SIZE", start_index=5, filename="Telescope.dat", rindex=tel_index)
    abs_err = DataIO.getInputData(keyword="ABS_ERR", start_index=5, filename="Telescope.dat", rindex=tel_index)
    return (size, abs_err)
开发者ID:robinlombaert,项目名称:ComboCode,代码行数:31,代码来源:LPTools.py

示例4: readTelescopeProperties

# 需要导入模块: from cc.tools.io import DataIO [as 别名]
# 或者: from cc.tools.io.DataIO import getInputData [as 别名]
    def readTelescopeProperties(self):
    
        """
        Read the telescope properties from Telescope.dat. 
        
        This currently includes the telescope size in m, and the default 
        absolute flux calibration uncertainty. 
        
        """
        
        all_telescopes = DataIO.getInputData(keyword='TELESCOPE',start_index=5,\
                                             filename='Telescope.dat')

        try:
            tel_index = all_telescopes.index(self.instrument.upper())
        except ValueError:
            raise ValueError('%s not found in Telescope.dat.'\
                             %self.instrument.upper())
        
        self.telescope_size = DataIO.getInputData(keyword='SIZE',start_index=5,\
                                                  filename='Telescope.dat',\
                                                  rindex=tel_index)
        self.absflux_err = DataIO.getInputData(keyword='ABS_ERR',start_index=5,\
                                               filename='Telescope.dat',\
                                               rindex=tel_index)
开发者ID:IvS-KULeuven,项目名称:ComboCode,代码行数:27,代码来源:Instrument.py

示例5: makeOpa

# 需要导入模块: from cc.tools.io import DataIO [as 别名]
# 或者: from cc.tools.io.DataIO import getInputData [as 别名]
 def makeOpa(self,mode='ZERO',**args):
     
     """
     Making custom .particle files.
     
     Every method called here will put the results in self.output_data.
     
     @keyword mode: type of extrapolation (ZERO,FUNCTION,HONY,ZHANG)
                     
                    (default: 'ZERO')
     @type mode: string
     @keyword args: Optional keywords required for the other methods of the 
                    class
     @type args: dict
     
     """
     
     self.output_data = []
     mode = mode.upper()
     if hasattr(self,'do' + mode):
         getattr(self,'do' + mode)(**args)
         self.output_data = [' '.join(str(line)) 
                             for line in self.output_data]
         output_filename = '_'.join(['customOpacity',mode] + \
                                    sorted(args.values()) + \
                                    [self.filename])
         if self.opacity_file:
             output_filename.replace('.particle','.opacity')
         DataIO.writeFile(filename=os.path.join(cc.path.mopac,\
                                                output_filename),\
                          input_lines=self.output_data)
         new_short = self.species + mode
         #- filename is already present: the new file should have the same
         #- parameters and the short name can be kept, 
         #- nothing is changed in the Dust.dat file
         try:    
             DataIO.getInputData(keyword='PART_FILE',filename='Dust.dat')\
                                .index(output_filename)
         #- filename is not present: do the normal procedure, ie check if 
         #- short name is already present
         except ValueError:        
             i=0
             while ' '.join(DataIO.getInputData(keyword='SPECIES_SHORT',\
                                                filename='Dust.dat'))\
                                               .find(new_short) != -1:
                 i+=1    
                 new_short = new_short + str(i)
             adding_line = [new_short] + \
                           [str(DataIO.getInputData(keyword=key,\
                                                    filename='Dust.dat',\
                                                    rindex=self.index))
                            for key in ['SPEC_DENS','T_DES','T_DESA','T_DESB']]
             adding_line.insert(2,output_filename)
             adding_line = '\t\t'.join(adding_line)
             DataIO.writeFile(os.path.join(cc.path.usr,'Dust.dat'),\
                              [adding_line+'\n'],mode='a')
     else:
         print 'Mode "' + mode + '" not available. Aborting.'
开发者ID:IvS-KULeuven,项目名称:ComboCode,代码行数:60,代码来源:DustOpacity.py

示例6: setStarPars

# 需要导入模块: from cc.tools.io import DataIO [as 别名]
# 或者: from cc.tools.io.DataIO import getInputData [as 别名]
 def setStarPars(self):
     
     """
     Set some standard stellar parameters such as Ak and galactic position.
     
     """
     
     self.star_index = DataIO.getInputData().index(self.star_name)
     self.ll = DataIO.getInputData(keyword='LONG',rindex=self.star_index)
     self.bb = DataIO.getInputData(keyword='LAT',rindex=self.star_index)
     snp = DataIO.getInputData(keyword='STAR_NAME_PLOTS',\
                               remove_underscore=1,rindex=self.star_index)
     self.star_name_plots = snp    
开发者ID:IvS-KULeuven,项目名称:ComboCode,代码行数:15,代码来源:Sed.py

示例7: __init__

# 需要导入模块: from cc.tools.io import DataIO [as 别名]
# 或者: from cc.tools.io.DataIO import getInputData [as 别名]
    def __init__(self):

        """
        Initiating an instance of the KappaReader.
        
        """

        self.lspecies = DataIO.getInputData(path=cc.path.usr, keyword="SPECIES_SHORT", filename="Dust.dat")
        self.lfilenames = DataIO.getInputData(path=cc.path.usr, keyword="PART_FILE", filename="Dust.dat")
        self.lspec_dens = DataIO.getInputData(path=cc.path.usr, keyword="SPEC_DENS", filename="Dust.dat")
        self.kappas = dict()
        self.qext_a = dict()
        self.waves = dict()
        self.fns = dict()
        self.spec_dens = dict()
开发者ID:robinlombaert,项目名称:ComboCode,代码行数:17,代码来源:KappaReader.py

示例8: addData

# 需要导入模块: from cc.tools.io import DataIO [as 别名]
# 或者: from cc.tools.io.DataIO import getInputData [as 别名]
 def addData(self,star_name,filename,trans):
     
     '''
     Add a new file to the database with given transition definition. If the 
     transition is already present in the database for this particular star, the
     filename is added to the dictionary for that transition.
     
     A single transition for a star can thus have multiple filenames associated
     with it!
     
     Note that this method does NOT automatically sync (ie save changes to the 
     hard disk) the database. That must be done through an additional flag to 
     avoid excess overhead. 
     
     The transition definition is checked for correctness: single spaces between
     entries in the defintion, and a total of 11 entries: 1 molecule (shorthand)
     8 quantum numbers, 1 offset 
     
     The fit is not done here. Instead the filename key is added to the 
     transition's dictionary with value None.
     
     @param star_name: The name of the star for which to add the data.
     @type star_name: str
     @param filename: The filename of the radio data to be added. Must be in the 
                     db folder! Only the filename is used. Any folder path is 
                     cut.
     @type filename: str
     @param trans: The transition definition. Must be in the correct format!
     @type trans: str
     
     '''
     
     filename = os.path.split(filename)[1]
     if not self.has_key(star_name):
         self.addStar(star_name)
     
     entries = trans.split()
     trans = ' '.join(entries)
     
     defmolecs = DataIO.getInputData(keyword='TYPE_SHORT',\
                                     filename='Molecule.dat')
     this_molec = entries[0].replace('TRANSITION=','',1)
     if this_molec not in defmolecs:
         print('Molecule %s unrecognized.'%this_molec)
         return
     
     if len(entries) != 11: 
         print('Incorrect transition definition:')
         print(trans)
         return
     
     if self[star_name].has_key(trans):
         if filename not in self[star_name][trans].keys():
             self[star_name][trans][filename] = None
             self.addChangedKey(star_name)
     else:
         self[star_name][trans] = dict([(filename,None)])
         self.addChangedKey(star_name)
开发者ID:FungKu01,项目名称:ComboCode,代码行数:60,代码来源:Radio.py

示例9: checkVlsr

# 需要导入模块: from cc.tools.io import DataIO [as 别名]
# 或者: from cc.tools.io.DataIO import getInputData [as 别名]
 def checkVlsr(self):
     
     """
     Check if the Vlsr was set correctly. If not, it is taken from Star.dat.
     
     It is assumed the vlsr in the fits file is correct within 25%. If it is
     not, the value from Star.dat is used.
     
     """
     
     try:
         star_index = DataIO.getInputData(keyword='STAR_NAME')\
                                         .index(self.star_name)
         vlsr = DataIO.getInputData(keyword='V_LSR',rindex=star_index)
     except KeyError,ValueError: 
         print 'Star not found in Star.dat for %s. '%(self.fn) + \
               'Add star to Star.dat!'
         raise IOError()
开发者ID:IvS-KULeuven,项目名称:ComboCode,代码行数:20,代码来源:LPDataReader.py

示例10: setSpecies

# 需要导入模块: from cc.tools.io import DataIO [as 别名]
# 或者: from cc.tools.io.DataIO import getInputData [as 别名]
 def setSpecies(self,species):
     
     """
     Change the species of the current CustomOpacity instance.
     
     @param species: the species short name
     @type species: string
     
     """
     
     self.species = species
     self.index = DataIO.getInputData(keyword='SPECIES_SHORT',\
                                      filename='Dust.dat')\
                                     .index(self.species)
     self.filename =  DataIO.getInputData(keyword='PART_FILE',\
                                          filename='Dust.dat',\
                                          rindex=self.index)
     fn = os.path.join(cc.path.mopac,self.filename)
     self.input_data = DataIO.readFile(filename=fn,delimiter=' ') 
开发者ID:IvS-KULeuven,项目名称:ComboCode,代码行数:21,代码来源:DustOpacity.py

示例11: getPacsResolution

# 需要导入模块: from cc.tools.io import DataIO [as 别名]
# 或者: from cc.tools.io.DataIO import getInputData [as 别名]
 def getPacsResolution(self):
     
     '''
     Get the Pacs resolution from cc aux file for all orders.
     
     @return: The resolution as a function of wavelength for the 3 orders
     @rtype: (list[list],list[list])
     
     '''
     
     reso_wave_list = [DataIO.getInputData(path=cc.path.aux,\
                                           filename='Pacs_Resolution.dat',\
                                           keyword='WAVE='+str(order))
                       for order in range(1,4)]
     reso_delta_list = [DataIO.getInputData(path=cc.path.aux,\
                                            filename='Pacs_Resolution.dat',\
                                            keyword='ORDER='+str(order))
                        for order in range(1,4)]
     return reso_wave_list,reso_delta_list
开发者ID:IvS-KULeuven,项目名称:ComboCode,代码行数:21,代码来源:Pacs.py

示例12: __init__

# 需要导入模块: from cc.tools.io import DataIO [as 别名]
# 或者: from cc.tools.io.DataIO import getInputData [as 别名]
 def __init__(self):
     
     """
     Initiating an instance of the KappaReader.
     
     """
     
     self.lspecies = DataIO.getInputData(path=cc.path.usr,\
                                         keyword='SPECIES_SHORT',\
                                         filename='Dust.dat')
     self.lfilenames = DataIO.getInputData(path=cc.path.usr,\
                                           keyword='PART_FILE',\
                                           filename='Dust.dat')
     self.lspec_dens = DataIO.getInputData(path=cc.path.usr,\
                                           keyword='SPEC_DENS',\
                                           filename='Dust.dat')
     self.kappas = dict()
     self.qext_a = dict()
     self.waves = dict()
开发者ID:FungKu01,项目名称:ComboCode,代码行数:21,代码来源:KappaReader.py

示例13: setDataInfo

# 需要导入模块: from cc.tools.io import DataIO [as 别名]
# 或者: from cc.tools.io.DataIO import getInputData [as 别名]
 def setDataInfo(self):
     
     '''
     Read data info from the ComboCode/usr/Data.dat file. Will return
     information such as sigma levels and wavelength range for determining
     the std value. 
     
     '''
     
     if not self.instrument: return
     self.data_info = dict()
     instbands = DataIO.getInputData(keyword='INSTRUMENT',\
                                     filename='Data.dat')
     instbands = [band.upper() for band in instbands]
     indices = [i
                for i,band in enumerate(instbands)
                if band.find(self.instrument.instrument.upper()) == 0]
     bands = [band.replace('%s_'%self.instrument.instrument.upper(),'')
              for i,band in enumerate(instbands)
              if i in indices]
     w_std_min = [wmin
                  for i,wmin in enumerate(DataIO.getInputData(\
                                   keyword='W_STD_MIN',filename='Data.dat'))
                  if i in indices]
     w_std_max = [wmax
                  for i,wmax in enumerate(DataIO.getInputData(\
                                   keyword='W_STD_MAX',filename='Data.dat'))
                  if i in indices]
     sigmas = [sigma
               for i,sigma in enumerate(DataIO.getInputData(\
                                       keyword='SIGMA',filename='Data.dat'))
               if i in indices]
     self.data_info['sigmas'] = sigmas
     self.data_info['bands'] = bands
     self.data_info['w_std_min'] = w_std_min
     self.data_info['w_std_max'] = w_std_max
     
开发者ID:FungKu01,项目名称:ComboCode,代码行数:38,代码来源:Statistics.py

示例14: doHONY

# 需要导入模块: from cc.tools.io import DataIO [as 别名]
# 或者: from cc.tools.io.DataIO import getInputData [as 别名]
    def doHONY(self,wl1 = 1.0,wl2=2.0,wl3=10.0,a_mod=0.05,q_cst=1.0):
        
        """
        Replace all opacities below a cut-off wavelength with values as assumed 
        by Hony et al (2003, 2004)
    
        @keyword wl1: first discontinuity in micron
        
                      (default: 1.0)
        @type wl1: float
        @keyword wl2: second discontinuity in micron
                      
                      (default: 2.0)
        @type wl2: float
        @keyword wl3: third discontinuity in micron
        
                      (default: 10)
        @type wl3: float
        @keyword a_mod: model grain size, 0.01 according to Hony 2004 in micron
        
                        (default: 0.05)
        @type a_mod: float
        @keyword q_cst: constant extinction efficiency at wavelengths < wl1
        
                        (default: 1.0)
        @type q_cst: float
        
        """

        spec_dens = DataIO.getInputData(keyword='SPEC_DENS',rindex=self.index,\
                                        filename='Dust.dat')
        opa_cst = q_cst/4.0*3.0/spec_dens/(a_mod*10**(-4))      
        for line in self.input_data:
            if len(line) == 4 and float(line[0]) < wl1:
                self.output_data.append([line[0],str(opa_cst+1e-60),\
                                         str(opa_cst),str(1e-60)])
            elif len(line)==4 and float(line[0])>=wl1 and float(line[0]) < wl2:
                opa = Interpol.linInterpol([wl1,wl2],[opa_cst,1e-60],\
                                            float(line[0]))
                self.output_data.append([line[0],str(opa+1e-60),str(opa),\
                                         str(1e-60)])
            elif len(line)==4 and float(line[0])>=wl2 and float(line[0]) < wl3:
                self.output_data.append([line[0],str(2e-60),str(1e-60),\
                                         str(1e-60)])
            else:
                self.output_data.append(line)
开发者ID:IvS-KULeuven,项目名称:ComboCode,代码行数:48,代码来源:DustOpacity.py

示例15: doZHANG

# 需要导入模块: from cc.tools.io import DataIO [as 别名]
# 或者: from cc.tools.io.DataIO import getInputData [as 别名]
 def doZHANG(self,wl=10.0,a_mod=0.05,q_cst=1.6,metallic=True):
     
     """
     Replace all opacities below a cut-off wavelength with values as assumed
     by Zhang et al (2009)
 
     @keyword wl: wavelength of the discontinuity
     
                  (default: 10.0)
     @type wl: float
     @keyword a_mod: model grain size, following Zhang et al 2009
     
                     (default: 0.05)
     @type a_mod: float
     @keyword q_cst: the constant extinction efficieny at short wavelengths
     
                     (default: 1.6)
     @type q_cst: float
     @keyword metallic: if metallic dust, cut off wavelength is calculated 
                        differently than if dielectric dust (ie metallic=0)
                        
                        (default: True)
     @type metallic: bool
     
     """
     
     spec_dens = DataIO.getInputData(keyword='SPEC_DENS',rindex=self.index,\
                                     filename='Dust.dat')
     wl1 = metallic and pi*a_mod or 2*pi*a_mod
     opa_cst = q_cst/4.0*3.0/spec_dens/(a_mod*10**(-4))
     i = 0
     while float(self.input_data[i][0]) <= wl:
         i += 1
     opa_10 = float(self.input_data[i][1])
     for line in self.input_data:
         if len(line) == 4 and float(line[0]) <= wl1:
             self.output_data.append([line[0],str(opa_cst+1e-60),\
                                      str(opa_cst),str(1e-60)])
         elif len(line)==4 and float(line[0]) > wl1 and float(line[0]) < wl:
             eps = min(1,float(line[0])/wl)
             opa = (1-eps) * opa_cst*wl1/float(line[0]) + eps*opa_10
             
             self.output_data.append([line[0],str(opa+1e-60),str(opa),\
                                      str(1e-60)])
         else:
             self.output_data.append(line)
开发者ID:IvS-KULeuven,项目名称:ComboCode,代码行数:48,代码来源:DustOpacity.py


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