Changeset 489 for CMIP6dreq/trunk


Ignore:
Timestamp:
19/11/15 09:53:53 (5 years ago)
Author:
mjuckes
Message:

test

Location:
CMIP6dreq/trunk/dreqPy
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • CMIP6dreq/trunk/dreqPy/scope.py

    r488 r489  
    99 
    1010python2 = True 
    11 if sys.version_info.major == 3: 
     11if sys.version_info[0] == 3: 
    1212  python2 = False 
    1313  from functools import reduce 
     
    200200    if len(rqlInv) != 0: 
    201201      print ( 'WARNING.001.00002: %s invalid request links from request items ...' % len(rqlInv) ) 
    202     rql = {u for u in rql0 if inx.uid[u]._h.label != 'remarks' } 
     202    rql = set() 
     203    for u in rql0: 
     204       if inx.uid[u]._h.label != 'remarks': 
     205         rql0.add( u )  
     206 
    203207    if len( rql ) == 0: 
    204208      self.vars = set() 
     
    208212    tm = 1 
    209213    if tm == 0: 
    210       rqvg = list({inx.uid[i].refid for i in rql}) 
     214      s = set() 
     215      for i in rql: 
     216        s.add( inx.uid[i].refid ) 
     217      rqvg = list( s ) 
    211218    else: 
    212219      cc1 = collections.defaultdict( set ) 
     
    221228        for k in cc1: 
    222229          thisc = reduce( operator.or_, [set( inx.iref_by_sect[vg].a['requestVar'] ) for vg in cc1[k] ] ) 
    223           ccv[k] = {inx.uid[l].vid for l in list(thisc) if inx.uid[l].priority <= pmax} 
     230          s = set() 
     231          for l in list(thisc): 
     232             if inx.uid[l].priority <= pmax: 
     233               s.add( inx.uid[l].vid ) 
     234          ccv[k] = s 
    224235 
    225236        if len( ccv.keys() ) < len( list(imips) ): 
     
    235246 
    236247###The collector col1 here accumulates all the record uids, resulting in a single collection. These are request variables, to get a set of CMOR variables at priority <= pmax: 
    237         vars = {inx.uid[l].vid for l in list(col1) if inx.uid[l].priority <= pmax} 
     248        vars = set() 
     249        for l in list(col1): 
     250           if inx.uid[l].priority <= pmax: 
     251             vars.add(inx.uid[l].vid) 
    238252## 
    239253## if looking for the union, would have to do a filter here ... after looking up which vars are requested by each MIP ... 
     
    244258### filter out cases where the request does not point to a CMOR variable. 
    245259    ##vars = {vid for vid in vars if inx.uid[vid][0] == u'CMORvar'} 
    246     vars = {vid for vid in vars if inx.uid[vid]._h.label == u'CMORvar'} 
     260    thisvars = set() 
     261    for vid in vars: 
     262       if inx.uid[vid]._h.label == u'CMORvar': 
     263             thisvars.add(vid) 
     264    vars = thisvars 
    247265## 
    248266## filter by configuration option and rank 
     
    260278### for request variables which reference the variable group attached to the link, add the associate CMOR variables, subject to priority 
    261279      i = inx.uid[u] 
    262       e[i.uid] = { inx.uid[x].vid for x in inx.iref_by_sect[i.refid].a['requestVar'] if inx.uid[x].priority <= pmax} 
     280      e[i.uid] = set() 
     281      for x in inx.iref_by_sect[i.refid].a['requestVar']: 
     282           if inx.uid[x].priority <= pmax: 
     283              e[i.uid].add( inx.uid[x].vid ) 
    263284# 
    264285# for each variable, calculate the maximum number of years across all the request links which reference that variable. 
     
    268289    nym = {} 
    269290    for v in vars: 
    270       nym[v] = max( {self.rqiExp[i.uid][2] for i in l1p if i.esid == ex and v in e[i.rlid]} ) 
     291      s = set() 
     292      for i in l1p: 
     293        if i.esid == ex and v in e[i.rlid]: 
     294          s.add( self.rqiExp[i.uid][2] ) 
     295      ##nym[v] = max( {self.rqiExp[i.uid][2] for i in l1p if i.esid == ex and v in e[i.rlid]} ) 
     296      nym[v] = max( s ) 
    271297 
    272298    szv = {} 
     
    362388  def volByMip( self, mip, pmax=2, retainRedundantRank=False): 
    363389 
    364     if type(mip) in {type( '' ),type( u'') }: 
     390    if type(mip) in [type( '' ),type( u'') ]: 
    365391      if mip not in self.mips: 
    366392        print ( self.mips ) 
     
    376402       
    377403    #### The set of experiments/experiment groups: 
    378     exps = {i.esid for i in l1} 
     404    exps = set() 
     405    for i in l1: 
     406      exps.add( i.esid ) 
    379407    self.volByE = {} 
    380408    vtot = 0 
     
    462490      self.adict['m'] = set(self.adict['m'].split(',') ) 
    463491 
    464     integerArgs = {'p','t','plm'} 
     492    integerArgs = set( ['p','t','plm'] ) 
    465493    for i in integerArgs.intersection( self.adict ): 
    466494      self.adict[i] = int( self.adict[i] ) 
  • CMIP6dreq/trunk/dreqPy/utilities.py

    r435 r489  
    5656 
    5757## set of vids associated with choices 
    58     s = {i.vid for i in self.dq.coll['varChoiceLinkC'].items} 
     58    s = set() 
     59    for i in self.dq.coll['varChoiceLinkC'].items: 
     60      s.add( i.vid ) 
    5961 
    6062## set of variables in current selection associated with choices 
    61     v1 = { u for u in cmv if u in s } 
     63    v1 = set( [ u for u in cmv if u in s ] ) 
    6264    if len(v1) == 0: 
    6365      ## print 'Nothing to do' 
     
    6567 
    6668## set of "rank" choice groups relevant to current selection 
    67     s1 = {i.cid for i in self.dq.coll['varChoiceLinkC'].items if i.vid in v1} 
     69    s1 = set( [i.cid for i in self.dq.coll['varChoiceLinkC'].items if i.vid in v1] ) 
    6870 
    6971    self.rejected = set() 
     
    7375## set of choice links in group s which relate to a variable in current selection 
    7476## 
    75       this = {i for i in self.dq.coll['varChoiceLinkC'].items if i.vid in v1 and i.cid == s} 
     77      this = set() 
     78      for i in self.dq.coll['varChoiceLinkC'].items: 
     79         if i.vid in v1 and i.cid == s: 
     80           set.add(i) 
    7681## 
    7782## value of configuration option (defaults to True here). 
     
    103108 
    104109## set of vids associated with choices 
    105     s = {i.vid for i in self.dq.coll['varChoiceLinkR'].items} 
     110    s = set( [i.vid for i in self.dq.coll['varChoiceLinkR'].items] ) 
    106111 
    107112## set of variables in current selection associated with choices 
    108     v1 = { u for u in cmv if u in s } 
     113    v1 = set( [ u for u in cmv if u in s ] ) 
    109114    if len(v1) == 0: 
    110115      ## print 'Nothing to do' 
     
    112117 
    113118## set of "rank" choice groups relevant to current selection 
    114     s1 = {i.cid for i in self.dq.coll['varChoiceLinkR'].items if i.vid in v1} 
     119    s1 = set( [i.cid for i in self.dq.coll['varChoiceLinkR'].items if i.vid in v1] ) 
    115120 
    116121    self.rejected = set() 
     
    120125## set of choice links in group s which relate to a variable in current selection 
    121126## 
    122       this = {i for i in self.dq.coll['varChoiceLinkR'].items if i.vid in v1 and i.cid == s} 
     127      this = set( [i for i in self.dq.coll['varChoiceLinkR'].items if i.vid in v1 and i.cid == s] ) 
    123128      if len(this) > 1: 
    124129        mr = max( [i.rank for i in this ] ) 
Note: See TracChangeset for help on using the changeset viewer.