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


Python io.DataIO类代码示例

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


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

示例1: readTelescopeProperties

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,代码行数:29,代码来源:LPTools.py

示例2: parseProfile

 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,代码行数:60,代码来源:SphinxReader.py

示例3: getKey

def getKey(k,data=None,fn=None):

    '''
    Retrieve data from an ALI inputfile. 
    
    Returns the line following the line that contains the given key. 
    
    @param k: The unique input key word for which the ALI inputfile is 
              searched.
    @type k: str

    @keyword data: The data, ie a file read by readFile with delimiter set to ''
                   A filename must be given if data is None.
                   
                   (default: None)
    @type data: list[str]
    @keyword fn: The ALI input filename. Only used if data is None.
    
                 (default: None)
    @type fn: str
    
    @return: The line following the line that contains given key
    @rtype: str
    
    ''' 
    
    if data is None:
        data = DataIO.readFile(filename=fn,delimiter=None,replace_spaces=0)
    i = DataIO.findKey(0,data,k)
    return data[i+1].replace('\n','')
开发者ID:IvS-KULeuven,项目名称:ComboCode,代码行数:30,代码来源:ALI.py

示例4: setStarPars

 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,代码行数:25,代码来源:Sed.py

示例5: waterFraction1StepProfiler

def waterFraction1StepProfiler(model_id,path_gastronoom,fraction,rfrac):

    '''
    Create a 1-step fractional profile for water.
    
    The original water abundance profile is taken from the output of the 
    original model without fractional abundances. 
    
    These fraction profiles can be used for CHANGE_ABUNDANCE_FRACTION in mline
    
    @param model_id: The model id of the original cooling model
    @type model_id: string
    @param path_gastronoom: The model subfolder in ~/GASTRoNOoM/
    @type path_gastronoom: string
    @param fraction: the fraction used
    @type fraction: float
    @param rfrac: the radius at the step to the fractional abundance [cm]
    @type rfrac: float
    
    '''
    
    rfrac = float(rfrac)
    fraction = float(fraction)
    filename = os.path.join(cc.path.gastronoom,path_gastronoom,'models',\
                            model_id,'coolfgr_all%s.dat'%model_id)
    rad = Gastronoom.getGastronoomOutput(filename=filename,keyword='RADIUS',\
                                         return_array=1)
    fraction_profile = np.ones(len(rad))
    step_index = np.argmin(abs(rad-rfrac))
    fraction_profile[step_index:] = fraction
    output_filename = os.path.join(cc.path.gastronoom,path_gastronoom,\
                                   'profiles',\
                                   'water_fractions_%s_%.2f_r%.3e.dat'\
                                   %(model_id,fraction,rfrac))
    DataIO.writeCols(output_filename,[rad,fraction_profile])
开发者ID:MarieVdS,项目名称:ComboCode,代码行数:35,代码来源:Profiler.py

示例6: setData

 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,代码行数:33,代码来源:Sed.py

示例7: doMline

    def doMline(self,star):
        
        """
        Run mline.
        
        First, database is checked for retrieval of old models. 

        @param star: The parameter set for this session
        @type star: Star()
        
        """
        
        model_bools = self.checkMlineDatabase()
        del self.command_list['R_OUTER']
        del self.command_list['OUTER_R_MODE']
        for molec,model_bool in zip(self.molec_list,model_bools):
            if not model_bool:
                self.updateModel(molec.getModelId())
                commandfile = ['%s=%s'%(k,v) 
                               for k,v in sorted(self.command_list.items())
                               if k != 'R_POINTS_MASS_LOSS'] +\
                              ['####'] + \
                              ['%s=%s'%(k,v) 
                               for k,v in sorted(molec.makeDict().items())] +\
                              ['####']
                if self.command_list.has_key('R_POINTS_MASS_LOSS'):
                    commandfile.extend(['%s=%s'%('R_POINTS_MASS_LOSS',v) 
                                        for v in self.command_list\
                                                    ['R_POINTS_MASS_LOSS']] +\
                                       ['####'])
                filename = os.path.join(cc.path.gout,'models',\
                                        'gastronoom_%s.inp'%molec.getModelId())
                DataIO.writeFile(filename,commandfile)                
                self.execGastronoom(subcode='mline',filename=filename)
                self.mline_done=True
                if len([f for f in glob(os.path.join(cc.path.gout,'models',\
                                        molec.getModelId(),'ml*%s_%s.dat'\
                                        %(molec.getModelId(),molec.molecule)))])\
                        == 3:
                    self.ml_db[self.model_id][molec.getModelId()]\
                              [molec.molecule] = molec.makeDict()
                    self.ml_db.addChangedKey(self.model_id)
                    self.ml_db.sync()
                else:
                    print 'Mline model calculation failed for'\
                          '%s. No entry is added to the database.'\
                          %(molec.molecule)
                    molec.setModelId('')
        if set([molec.getModelId() for molec in self.molec_list]) == set(['']):  
            #- no mline models calculated: stop GASTRoNOoM here
            self.model_id = ''
            print 'Mline model calculation failed for all requested ' + \
                  'molecules. Stopping GASTRoNOoM here!'
        else:        
            #- at least one molecule was successfully calculated, so start  
            #- Sphinx, hence if vic is requested, the cooling model_id can now  
            #- be added to the models list
            if self.vic <> None and self.sphinx: 
                #- add the command list to the vic models list
                self.vic.addModel(self.model_id,self.command_list)
开发者ID:FungKu01,项目名称:ComboCode,代码行数:60,代码来源:Gastronoom.py

示例8: makeMCMaxStars

 def makeMCMaxStars(self,models):
     
     '''
     Set parameters for star_list taken from the MCMax database.
     
     Based on the model id of MCMax.
     
     @param models: model_ids for the MCMax db
     @type models: list(string)
     @return: The model instances 
     @rtype: list(Star())
     
     '''
     
     star_grid = Star.makeStars(models=models,code='MCMax',id_type='MCMax',\
                                path=self.path)
     for star,model in zip(star_grid,models):    
         filepath = os.path.join(cc.path.mout,'models',\
                                 star['LAST_MCMAX_MODEL'])
         denstemp = os.path.join(filepath,'denstemp.dat')
         logfile = os.path.join(filepath,'log.dat')
         grid_shape = DataIO.getMCMaxOutput(filename=denstemp,incr=1,\
                                            keyword='NGRAINS',single=0)[0]
         star.update({'NTHETA':int(grid_shape[1]),\
                      'NRAD':int(grid_shape[0]),\
                      'T_STAR':float(DataIO.getMCMaxOutput(filename=logfile,\
                                             incr=0,\
                                             keyword='STELLAR TEMPERATURE',\
                                             single=0)[0][2]),\
                      'R_STAR':float(DataIO.getMCMaxOutput(filename=logfile,\
                                             incr=0,\
                                             keyword='STELLAR RADIUS',\
                                             single=0)[0][2])})            
     return star_grid  
开发者ID:FungKu01,项目名称:ComboCode,代码行数:34,代码来源:PlotDust.py

示例9: readTelescopeProperties

    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,代码行数:25,代码来源:Instrument.py

示例10: __init__

 def __init__(self,path_chemistry='runTest',replace_db_entry=0,db=None,\
              single_session=0):
     
     """ 
     Initializing an instance of ModelingSession.
     
     @keyword db: the Chemistry database
     
                       (default: None)
     @type db: Database()
     @keyword replace_db_entry: replace an entry in the Chemistry database with 
                                a newly calculated model with a new model id 
                                (for instance if some general data not 
                                included in the inputfiles is changed)
                                
                                (default: 0)
     @type replace_db_entry: bool
     @keyword path_chemistry: modeling folder in Chemistry home
     
                          (default: 'runTest')
     @type path_chemistry: string
     @keyword new_entries: The new model_ids when replace_db_entry is 1
                                of other models in the grid. These are not 
                                replaced!
                                
                                (default: [])
     @type new_entries: list[str]     
     @keyword single_session: If this is the only CC session. Speeds up db
                              check.
                              
                              (default: 0)
     @type single_session: bool
             
     """
     
     super(Chemistry, self).__init__(code='Chemistry',path=path_chemistry,\
                                 replace_db_entry=replace_db_entry,\
                                 single_session=single_session)
     #-- Convenience path
     cc.path.cout = os.path.join(cc.path.chemistry,self.path)
     #DataIO.testFolderExistence(os.path.join(cc.path.mout,\
                                             #'data_for_gastronoom'))
     self.db = db
     
     #-- If an chemistry model is in progress, the model manager will hold until
     #   the other cc session is finished. 
     self.in_progress = False
     
     #- Read standard input file with all parameters that should be included
     #- as well as some dust specific information
     self.inputfilename = os.path.join(cc.path.aux,'inputChemistry.dat')
     self.standard_inputfile = DataIO.readDict(self.inputfilename,\
                                               convert_floats=1,\
                                               convert_ints=1,\
                                               comment_chars=['#','*'])
     chemistry_keys = os.path.join(cc.path.aux,'Input_Keywords_Chemistry.dat')
     self.chemistry_keywords = [line.strip() 
                                for line in DataIO.readFile(chemistry_keys) 
                                if line]      
开发者ID:IvS-KULeuven,项目名称:ComboCode,代码行数:59,代码来源:Chemistry.py

示例11: combineRedLaw

def combineRedLaw(ofn, chiar_curve="ism", power=-1.8):

    """
    A method to combine the Fitzpatrick 2004 and Chiar & Tielens 2006 reddening
    laws as well as to extrapolate Chiar and Tielens 2006 to longer wavelengths.
    
    The result is saved in a file and used by the IvS repository as a valid 
    reddening law. 
    
    @param ofn: The output filename with path
    @type ofn: str
    
    @keyword chiar_curve: The curve type for Chiar & Tielens 2004. Either 'gc' 
                          or 'ism'.
                          
                          (default: 'ism')
    @type chiar_curve: str
    @keyword power: The power for the power law extrapolation. Default is taken
                    from Chiar and Tielens 2006, as a typical value for local
                    ISM between 2 and 5 micron. gc may require different value
                    but not very important.
                    
                    (default: -1.8)
    @type power: float

    """

    chiar_curve = chiar_curve.lower()

    # -- Extract the two relevant extinction laws.
    xchiar, a_ak_chiar = red.get_law("chiar2006", norm="Ak", wave_units="micron", curve=chiar_curve)
    xfitz, a_ak_fitz = red.get_law("fitzpatrick2004", norm="Ak", wave_units="micron")

    # -- Define a power law for the extrapolation
    def power_law(x, scale, power):
        return scale * (x) ** power

    # -- Determine the scaling factor from specific chiar/tielens law
    scale = a_ak_chiar[-1] / (xchiar[-1] ** power)

    # -- Create an x grid for longer wavelengths.
    xlong = np.linspace(xchiar[-1] + 0.1, 1000, 1000)
    a_ak_long = power_law(xlong, scale, power)

    # -- Combine the three sections
    xcom = hstack([xfitz[xfitz < xchiar[0]], xchiar, xlong])
    a_ak_com = hstack([a_ak_fitz[xfitz < xchiar[0]], a_ak_chiar, a_ak_long])

    # -- Write the result to a file
    comments = "#-- wavelength (micron)   A_lambda/A_k\n"
    DataIO.writeCols(filename=ofn, cols=[[comments]])
    DataIO.writeCols(filename=ofn, cols=[xcom, a_ak_com], mode="a")
开发者ID:robinlombaert,项目名称:ComboCode,代码行数:52,代码来源:Reddening.py

示例12: setStarPars

 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,代码行数:13,代码来源:Sed.py

示例13: mergeOpacity

def mergeOpacity(species,lowres='nom_res',highres='high_res'):
    
    '''
    Merge high-res opacities into a grid of low-res opacities.
    
    The wavelength range of the inserted high res opacities is taken from the 
    given high res grid. 
        
    @param species: The dust species for which this is done. This is also the 
                    name of the folder in ~/MCMax/DustOpacities/ that contains
                    the data files.
    @type species: string
    @keyword lowres: The subfolder in ~/MCMax/DustOpacities/species containing
                     the low resolution datafiles.
                   
                     (default: low_res)
    @type lowres: string
    @keyword highres: The subfolder in ~/MCMax/DustOpacities/species containing
                      the high resolution datafiles.
                      
                      (default: high_res)
    @type highres: string
    
    '''
    
    path = os.path.join(cc.path.mopac,species)
    lowres_files = [f 
                    for f in glob(os.path.join(path,lowres,'*')) 
                    if f[-5:] == '.opac']
    highres_files = [f 
                     for f in glob(os.path.join(path,highres,'*')) 
                     if f[-5:] == '.opac']
    files = set([os.path.split(f)[1] for f in lowres_files] + \
                [os.path.split(f)[1] for f in highres_files])
    
    for f in files:
        hdfile = os.path.join(path,highres,f)
        ldfile = os.path.join(path,lowres,f)
        if os.path.isfile(ldfile) and os.path.isfile(hdfile):
            hd = DataIO.readCols(hdfile)
            ld = DataIO.readCols(ldfile)
            hdw = hd[0]
            ldw = ld[0]
            wmin = hdw[0]
            wmax = hdw[-1]
            ld_low = [list(col[ldw<wmin]) for col in ld]
            ld_high = [list(col[ldw>wmax]) for col in ld]
            hd = [list(col) for col in hd]
            merged = [ld_low[i] + hd[i] + ld_high[i] 
                      for i in range(len(hd))]
            DataIO.writeCols(filename=os.path.join(path,f),cols=merged)
开发者ID:IvS-KULeuven,项目名称:ComboCode,代码行数:51,代码来源:DustOpacity.py

示例14: copyOutput

 def copyOutput(self,entry,old_id,new_id):
     
     '''
     Copy modelling output based on model_id.
     
     @param entry: the modeling object for which output is copied
     @type entry: Molecule() or Transition()
     @param old_id: The old model_id
     @type old_id: string
     @param new_id: the new_model_id
     @type new_id: string
     
     '''
     
     folder_old = os.path.join(cc.path.gout,'models',old_id)
     folder_new = os.path.join(cc.path.gout,'models',new_id)
     lsprocess = subprocess.Popen('ls %s'%folder_old,shell=True,\
                                  stdout=subprocess.PIPE)
     lsfile = lsprocess.communicate()[0].split('\n')
     lsfile = [os.path.split(line)[1] 
                  for line in lsfile 
                  if ((line[0:2] == 'ml' or line[0:4] == 'cool') \
                         and not entry.isMolecule()) \
                      or line[0:7] == 'coolfgr' \
                      or line[0:4] == 'para' \
                      or line[0:5] == 'input']
     if not entry.isMolecule():
         lsfile = [line 
                      for line in lsfile 
                      if not (line[0:2] == 'ml' \
                         and line.split('_')[-1].replace('.dat','') \
                                         != entry.molecule.molecule)]
         lsfile = [line 
                      for line in lsfile 
                      if not (line[0:4] == 'cool' \
                         and (line.split('_')[-1].replace('.dat','') \
                                         != entry.molecule.molecule \
                         or line.split('_')[-1].replace('.dat','')=='sampling'\
                         or line[0:7] == 'coolfgr'))]
                          
     new_lsfile = [line.replace(old_id,new_id) for line in lsfile]
     DataIO.testFolderExistence(folder_new)
     lsprocess = subprocess.Popen('ls %s'%folder_new,shell=True,\
                                  stdout=subprocess.PIPE)
     already_done = lsprocess.communicate()[0].split('\n')
     for ls,nls in zip(lsfile,new_lsfile):
         if not nls in already_done:
             subprocess.call(['ln -s %s %s'%(os.path.join(folder_old,ls),\
                                            os.path.join(folder_new,nls))],\
                             shell=True)
开发者ID:FungKu01,项目名称:ComboCode,代码行数:50,代码来源:Gastronoom.py

示例15: finalizeVic

 def finalizeVic(self):
     
     '''
     Finalize a modeling procedure on VIC: successful and failed results 
     are printed to a file, including the transitions.
     
     This log file can be used as input for ComboCode again by putting 
     LINE_LISTS=2.
     
     '''
     
     for trans in self.trans_in_progress:
         filename = os.path.join(cc.path.gastronoom,\
                                 self.path,'models',trans.getModelId(),\
                                 trans.makeSphinxFilename(2))
         if not os.path.isfile(filename):              
             trans.setModelId('') 
     if self.models.keys():
         time_stamp = '%.4i-%.2i-%.2ih%.2i:%.2i:%.2i' \
                      %(gmtime()[0],gmtime()[1],gmtime()[2],\
                        gmtime()[3],gmtime()[4],gmtime()[5])
         results = ['# Successfully calculated models:'] \
                 + [self.models[current_model] 
                    for current_model in self.models.keys() 
                    if current_model not in self.failed.keys()] \
                 + ['# Unsuccessfully calculated models (see 3 logfiles '+ \
                    'for these models):'] \
                 + [self.models[current_model] 
                    for current_model in self.models.keys() 
                    if current_model in self.failed.keys()]
         DataIO.writeFile(os.path.join(cc.path.gastronoom,self.path,\
                                       'vic_results','log_' + time_stamp),\
                          results)
         for current_model,model_id in self.models.items():
             model_results = ['# Successfully calculated transitions:'] + \
                 ['Sphinx %s: %s' %(trans.getModelId(),str(trans)) 
                  for trans in self.finished[current_model]] + \
                 ['# Unsuccessfully calculated transitions (see 2 other ' + \
                  'logfiles for these transitions):'] + \
                 ['Sphinx %s: %s' %(trans.getModelId(),str(trans)) 
                  for trans in self.failed[current_model]]
             DataIO.writeFile(os.path.join(cc.path.gastronoom,self.path,\
                                           'vic_results','log_results%s_%i'\
                                           %(time_stamp,current_model)),\
                              model_results)
             for this_id in self.sphinx_model_ids[current_model]:
                 sphinx_files = os.path.join(cc.path.gastronoom,self.path,\
                                             'models',this_id,'sph*')
                 subprocess.call(['chmod a+r %s'%sphinx_files],shell=True)
开发者ID:IvS-KULeuven,项目名称:ComboCode,代码行数:49,代码来源:Vic.py


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