Changeset 741


Ignore:
Timestamp:
06/09/16 13:09:33 (3 years ago)
Author:
mjuckes
Message:

fixed problems with request link listing by MIP

File:
1 edited

Legend:

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

    r737 r741  
    6565def filter2( a, b, tt, tm ): 
    6666## largest tier less than or equal to tm 
    67   t1 = [t for t in tt if t <= tm][-1] 
    68   it1 = tt.index(t1) 
    69   aa = a[it1] 
    70   if b < 0: 
    71     return aa 
     67  ll = [t for t in tt if t <= tm] 
     68  if len( ll ) > 0: 
     69    t1 = [t for t in tt if t <= tm][-1] 
     70    it1 = tt.index(t1) 
     71    aa = a[it1] 
     72    if b < 0: 
     73      return aa 
     74    else: 
     75      return min( [aa,b] ) 
    7276  else: 
    73     return min( [aa,b] ) 
     77    return 0 
    7478 
    7579npy = {'1hrClimMon':24*12, 'daily':365, u'Annual':1, u'fx':0.01, u'1hr':24*365, u'3hr':8*365, 
     
    207211 
    208212    s = set() 
    209     for i in self.dq.coll['objectiveLink'].items: 
    210       if t1(i.label): 
    211         s.add( self.dq.inx.uid[i.rid] ) 
    212  
    213     ##self.rqs = list({self.dq.inx.uid[i.rid] for i in self.dq.coll['objectiveLink'].items if t1(i.label) }) 
     213    for i in self.dq.coll['requestLink'].items: 
     214      if t1(i.mip): 
     215        if 'requestItem' in self.dq.inx.iref_by_sect[i.uid].a: 
     216          if any( [ self.rqiExp[x][-1] > 0 for  x in self.dq.inx.iref_by_sect[i.uid].a['requestItem'] if x in self.rqiExp ] ): 
     217            s.add( i ) 
     218 
    214219    self.rqs = list( s ) 
    215220    return self.rqs 
     
    221226 
    222227    s = set() 
    223     for i in self.dq.coll['objectiveLink'].items: 
    224       if i.label in mipSel: 
    225         if len(mipSel[i]) == 0 or self.dq.inx.uid[i.oid].label in mipSel[i]: 
    226           s.add( self.dq.inx.uid[i.rid] ) 
    227     ##self.rqs = list({self.dq.inx.uid[i.rid] for i in self.dq.coll['objectiveLink'].items if t1(i.label) }) 
    228     self.rqs = list( s ) 
    229     return self.rqs 
    230  
    231   def getRequestLinkByObjective( self, objSel ): 
    232     """Return the set of request links which are associated with specified objectives""" 
    233     if type(objSel) == type(''): 
    234       t1 = lambda x: x == self.rlu[objSel] 
    235     elif type(objSel) == type(set()): 
    236       t1 = lambda x: x in [self.rlu[i] for i in objSel] 
    237  
    238     s = set() 
    239     for i in self.dq.coll['objectiveLink'].items: 
    240       if t1(i.label): 
    241         s.add( self.dq.inx.uid[i.oid] ) 
    242 ## 
    243     self.rqs = list( s ) 
    244     ##self.rqs = list({self.dq.inx.uid[i.rid] for i in self.dq.coll['objectiveLink'].items if t1(i.oid) }) 
     228    for i in self.dq.coll['requestLink'].items: 
     229      if i.mip in mipSel: 
     230        if len(mipSel[i.mip]) == 0: 
     231          s.add( i ) 
     232        elif 'objectiveLink' in self.dq.inx.iref_by_sect[i.uid].a: 
     233          ss = {self.dq.inx.uid[k].label for k in self.dq.inx.iref_by_sect[i.uid].a['objectiveLink']} 
     234          if any( [x in mipSel[i.mip] for x in ss] ): 
     235            s.add( i ) 
     236## 
     237## filter requestLinks by tierMax: check to see whether they link to experiments with tier below or equal to tiermax. 
     238## 
     239    s1 = set() 
     240    for i in s: 
     241      if 'requestItem' in self.dq.inx.iref_by_sect[i.uid].a: 
     242        if any( [ self.rqiExp[x][-1] > 0 for  x in self.dq.inx.iref_by_sect[i.uid].a['requestItem'] if x in self.rqiExp ] ): 
     243            s1.add( i ) 
     244 
     245    self.rqs = list( s1 ) 
    245246    return self.rqs 
    246247 
Note: See TracChangeset for help on using the changeset viewer.