Ignore:
Timestamp:
26/07/18 14:04:14 (16 months ago)
Author:
mjuckes
Message:

cand. 01.00.27

File:
1 edited

Legend:

Unmodified
Added
Removed
  • CMIP6dreqbuild/trunk/src/framework/dreqPy/table_utils.py

    r1173 r1241  
    180180        self.oo.write( '\n' ) 
    181181 
    182   def cmvtab(self,t,addMips,mode='c',tslice=False,byFreqRealm=False): 
     182  def cmvtab(self,t,addMips,mode='c',tslice=False,byFreqRealm=False,truePriority=False): 
    183183      if self.xls: 
    184184        self.sht = self.newSheet( t ) 
     
    186186      ncga = 'NetCDF Global Attribute' 
    187187      if mode == 'c': 
    188         hrec = ['Priority','Long name', 'units', 'description', 'comment', 'Variable Name', 'CF Standard Name', 'cell_methods', 'positive', 'type', 'dimensions', 'CMOR Name', 'modeling_realm', 'frequency', 'cell_measures', 'prov', 'provNote','rowIndex','UID','vid','stid','Structure Title','valid_min', 'valid_max', 'ok_min_mean_abs', 'ok_max_mean_abs'] 
     188        hrec = ['Default Priority','Long name', 'units', 'description', 'comment', 'Variable Name', 'CF Standard Name', 'cell_methods', 'positive', 'type', 'dimensions', 'CMOR Name', 'modeling_realm', 'frequency', 'cell_measures', 'prov', 'provNote','rowIndex','UID','vid','stid','Structure Title','valid_min', 'valid_max', 'ok_min_mean_abs', 'ok_max_mean_abs'] 
    189189        hcmt = ['Default priority (generally overridden by settings in "requestVar" record)',ncga,'','','Name of variable in file','','','CMOR directive','','','CMOR name, unique within table','','','','','','','','','','CMOR variable identifier','MIP variable identifier','Structure identifier','','','','',''] 
     190        if truePriority: 
     191           hrec[0] = 'Priority' 
     192           hcmt[0] = 'Lowest priority value set in request for this variable for this experiment' 
    190193        if self.xls: 
    191194          self.sht.set_column(1,1,40) 
     
    248251### 
    249252class makeTab(object): 
    250   def __init__(self, sc, subset=None, mcfgNote=None, dest='tables/test', skipped=set(), collected=None,xls=True,txt=False,txtOpts=None,byFreqRealm=False, tslice=None, exptUid=None): 
     253  def __init__(self, sc, subset=None, mcfgNote=None, dest='tables/test', skipped=set(), collected=None,xls=True,txt=False,txtOpts=None,byFreqRealm=False, tslice=None, exptUid=None, tabMode=None, pdict=None): 
    251254    """txtOpts: gives option to list MIP variables instead of CMOR variables""" 
    252255    self.sc = sc 
     
    284287      wb.mcfgNote = mcfgNote 
    285288    wb.header( tableNotes, collected) 
     289    truePriority = tabMode == 'e' and pdict != None 
    286290 
    287291    if txtOpts != None and txtOpts.mode == 'var': 
     
    305309        if withoo: 
    306310          oo = open( 'tables/test_%s.csv' % t, 'w' ) 
    307         wb.cmvtab(t,addMips,mode='c',tslice=tslice != None,byFreqRealm=byFreqRealm) 
     311        wb.cmvtab(t,addMips,mode='c',tslice=tslice != None,byFreqRealm=byFreqRealm,truePriority = truePriority) 
    308312 
    309313        j = 0 
     
    358362            if mode == 'c': 
    359363              try: 
    360                 orec = [str(cmv.defaultPriority),var.title, var.units, var.description, cmv.description, var.label, var.sn, strc.cell_methods, cmv.positive, cmv.type, dims, cmv.label, cmv.modeling_realm, cmv.frequency, strc.cell_measures, cmv.prov,cmv.provNote,str(cmv.rowIndex),cmv.uid,cmv.vid,cmv.stid,strc.title, valid_min, valid_max, ok_min_mean_abs, ok_max_mean_abs] 
     364                if tabMode == 'e' and pdict != None: 
     365                  if cmv.uid in pdict: 
     366                    thisp = str( min( pdict[cmv.uid] ) ) 
     367                  else: 
     368                    thisp = str(cmv.defaultPriority) 
     369                    print 'ERROR.priority.0101: ',cmv.label,dest 
     370                else: 
     371                  thisp = str(cmv.defaultPriority) 
     372                orec = [thisp,var.title, var.units, var.description, cmv.description, var.label, var.sn, strc.cell_methods, cmv.positive, cmv.type, dims, cmv.label, cmv.modeling_realm, cmv.frequency, strc.cell_measures, cmv.prov,cmv.provNote,str(cmv.rowIndex),cmv.uid,cmv.vid,cmv.stid,strc.title, valid_min, valid_max, ok_min_mean_abs, ok_max_mean_abs] 
    361373              except: 
    362374                print ('FAILED TO CONSTRUCT RECORD: %s [%s], %s [%s]' % (cmv.uid,cmv.label,var.uid,var.label) ) 
     
    407419                  priority = thisp[1] 
    408420                  ##print 'ERROR in priority type[2]: ',priority, tslice[cmv.uid] 
    409                 orec[0] = priority 
     421                orec[0] = '%s' % priority 
    410422                      
    411423                if tsmode[:4] in ['simp','bran']: 
     
    425437                orec.append( grid ) 
    426438                 
     439            if orec[0] in [0,'0',None]: 
     440                  print 'ERROR.priority.006: ',orec,dest 
    427441            if withoo: 
    428442              oo.write( '\t'.join(orec ) + '\n' ) 
Note: See TracChangeset for help on using the changeset viewer.