Ignore:
Timestamp:
12/12/15 06:49:13 (6 years ago)
Author:
mjuckes
Message:

Cleaning volByExpt

Location:
CMIP6dreqbuild/trunk/src/framework/dreqPy
Files:
2 edited

Legend:

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

    r521 r522  
    252252               except: 
    253253                 print ( 'Failed to convert real number: %s' % v ) 
    254                  raise 
     254                 if v == '': 
     255                   v = 0. 
     256                 else: 
     257                   raise 
    255258             elif self._a[a].type == u'xs:integer': 
    256259               if self._rc.isIntStr( v ): 
  • CMIP6dreqbuild/trunk/src/framework/dreqPy/scope.py

    r520 r522  
    169169    return self.ntot 
    170170 
    171   def volByExpt( self, l1, ex, pmax=2, cc=None, retainRedundantRank=False, intersection=False,expFullEx=False ): 
    172     """volByExpt: calculates the total data volume associated with an experiment/experiment group and a list of request items. 
    173           The calculation has some approximations concerning the number of years in each experiment group.""" 
    174 ## 
    175 ## cc: an optional collector, to accumulate indexed volumes 
     171  def rqlByExpt( self, l1, ex, pmax=2, expFullEx=False ): 
     172    """rqlByExpt: return a set of request links for an experiment""" 
    176173## 
    177174    inx = self.dq.inx 
    178     imips = set() 
    179     for i in l1: 
    180       imips.add(i.mip) 
    181     ##imips = {i.mip for i in l1} 
    182175     
    183176    exi = self.dq.inx.uid[ex] 
     
    210203         rql.add( u )  
    211204 
     205    return rql, l1p, exset 
     206 
     207  def volByExpt( self, l1, ex, pmax=2, cc=None, retainRedundantRank=False, intersection=False,expFullEx=False ): 
     208    """volByExpt: calculates the total data volume associated with an experiment/experiment group and a list of request items. 
     209          The calculation has some approximations concerning the number of years in each experiment group. 
     210          cc: an optional collector, to accumulate indexed volumes. """ 
     211## 
     212    inx = self.dq.inx 
     213    imips = set() 
     214    for i in l1: 
     215      imips.add(i.mip) 
     216    ##imips = {i.mip for i in l1} 
     217     
     218    rql, l1p, exset = self.rqlByExpt( l1, ex, pmax=pmax, expFullEx=expFullEx ) 
     219    dn = False 
     220    if dn: 
     221      exi = self.dq.inx.uid[ex] 
     222      if exi._h.label == 'experiment': 
     223        exset = set( [ex,exi.egid,exi.mip] ) 
     224      else: 
     225        exset = set( self.esid_to_exptList(ex,deref=False,full=expFullEx) ) 
     226## 
     227## rql is the set of all request links which are associated with a request item for this experiment set 
     228## 
     229      l1p = set() 
     230      for i in l1: 
     231        if i.preset < 0 or i.preset <= pmax: 
     232          if i.esid in exset: 
     233            l1p.add(i) 
     234   
     235      rql0 = set() 
     236      for i in l1p: 
     237         rql0.add(i.rlid) 
     238   
     239      rqlInv = set() 
     240      for u in rql0: 
     241        if inx.uid[u]._h.label == 'remarks': 
     242          rqlInv.add( u ) 
     243      if len(rqlInv) != 0: 
     244        print ( 'WARNING.001.00002: %s invalid request links from request items ...' % len(rqlInv) ) 
     245      rql = set() 
     246      for u in rql0: 
     247         if inx.uid[u]._h.label != 'remarks': 
     248           rql.add( u )  
     249 
     250##### 
    212251    if len( rql ) == 0: 
    213252      self.vars = set() 
Note: See TracChangeset for help on using the changeset viewer.