Changeset 894


Ignore:
Timestamp:
09/12/16 15:34:37 (3 years ago)
Author:
mjuckes
Message:

added descriptions to section index html pages

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

Legend:

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

    r782 r894  
    1010try: 
    1111  from __init__ import DOC_DIR, version, PACKAGE_DIR 
     12  import utilities 
    1213except: 
    1314  from dreqPy.__init__ import DOC_DIR, version, PACKAGE_DIR 
     15  from dreqPy import utilities 
    1416 
    1517python2 = True 
     
    168170         elif mdMode: 
    169171           self.mdInit( xmlMiniDom, etree=etree ) 
     172 
     173       def hasattr(self,tag): 
     174         """Return True id the argument passed is the name of an attribute of this instance.""" 
     175         return tag in self.__dict__ 
    170176 
    171177       def __repr__(self): 
     
    469475    self.coll = {} 
    470476 
    471     self.nts = collections.namedtuple( 'sectdef', ['tag','label','title','id','itemLabelMode','level','maxOccurs','labUnique','uid'] ) 
     477    self.nts = collections.namedtuple( 'sectdef', ['tag','label','title','id','itemLabelMode','level','maxOccurs','labUnique','uid','description'] ) 
    472478    self.nti = collections.namedtuple( 'itemdef', ['tag','label','title','type','useClass','techNote','required'] ) 
    473479    self.ntt = collections.namedtuple( 'sectinit', ['header','attributes','defaults'] ) 
     
    702708           'type':'xs:string', 'uid':'__core__:description', 'label':'label', 'required':'required' } 
    703709        if v == None: 
    704           vtt = self.nts( '__core__', 'CoreAttributes', 'X.1 Core Attributes', '00000000', 'def', '0', '0', 'false', '__core__' ) 
     710          vtt = self.nts( '__core__', 'CoreAttributes', 'X.1 Core Attributes', '00000000', 'def', '0', '0', 'false', '__core__', 'The core attributes, used in defining sections and attributes' ) 
    705711        else: 
    706           vtt = self.nts( '__main__', 'DataRequestAttributes', 'X.2 Data Request Attributes', '00000001', 'def', '0', '0', 'false', '__main__' ) 
     712          vtt = self.nts( '__main__', 'DataRequestAttributes', 'X.2 Data Request Attributes', '00000001', 'def', '0', '0', 'false', '__main__' , 'The attributes used to define data request records') 
    707713      elif v == '__sect__': 
    708714        idict = {'title':'Record Description', \ 
    709715         'uid':'__core__:description', 'label':'label', 'useClass':'text', 'id':'id', 'maxOccurs':'', 'itemLabelMode':'', 'level':'', 'labUnique':'' } 
    710         vtt = self.nts( '__sect__', 'sectionAttributes', 'X.3 Section Attributes', '00000000', 'def', '0', '0', 'false', '__sect__' ) 
     716        vtt = self.nts( '__sect__', 'sectionAttributes', 'X.3 Section Attributes', '00000000', 'def', '0', '0', 'false', '__sect__', 'The attributes used to define data request sections' ) 
    711717##<var label="var" uid="SECTION:var" useClass="vocab" title="MIP Variable" id="cmip.drv.001"> 
    712718      else: 
     
    719725        maxo = v.getAttribute( 'maxOccurs' ) 
    720726        labu = v.getAttribute( 'labUnique' ) 
     727        des = v.getAttribute( 'description' ) 
    721728        il = v.getElementsByTagName( 'rowAttribute' ) 
    722729        ##vtt = self.nts( v.nodeName, l,t,i,ilm,lev, maxo, labu, 's__%s' % v.nodeName ) 
    723         vtt = self.nts( v.nodeName, l,t,i,ilm,lev, maxo, labu, u ) 
     730        vtt = self.nts( v.nodeName, l,t,i,ilm,lev, maxo, labu, u, des ) 
    724731        idict = {} 
    725732        for i in il: 
     
    874881defaultDreqPath = '%s/%s' % (DOC_DIR, defaultDreq ) 
    875882defaultConfigPath = '%s/%s' % (DOC_DIR, defaultConfig ) 
     883defaultManifestPath = '%s/dreqManifest.txt' % DOC_DIR 
    876884 
    877885class loadDreq(object): 
     
    883891""" 
    884892 
    885   def __init__(self,dreqXML=defaultDreqPath, configdoc=defaultConfigPath, useShelve=False, htmlStyles=None, strings=False, manifest=None , configOnly=False): 
     893  def __init__(self,dreqXML=None, configdoc=None, useShelve=False, htmlStyles=None, strings=False, manifest=defaultManifestPath , configOnly=False): 
    886894    self.c = config( thisdoc=dreqXML, configdoc=configdoc, useShelve=useShelve,strings=strings,manifest=manifest,configOnly=configOnly) 
    887895    self.coll = self.c.coll 
     
    10231031    odir: directory for html files; 
    10241032    ttl0: Title for main index (in odir/index.html)""" 
     1033    markup = utilities.markupHtml( '' ) 
    10251034 
    10261035    ks = self.inx.uid.keys() 
     
    10621071      msg = ['<h1>%s</h1>\n' % ttl, '<ul>',] 
    10631072      msg.append( '<a href="../index.html">Home</a><br/>\n' ) 
     1073      msg.append( '<p>%s</p>\n' % markup.parse( self.coll[k].header.description ) ) 
    10641074      lst = self.getHtmlItemStyle(k) 
    10651075       
  • CMIP6dreqbuild/trunk/src/framework/dreqPy/makeTables.py

    r885 r894  
    398398            dims +=  strc.coords.split( '|' ) 
    399399            dims = ' '.join( dims ) 
     400            if "qcranges" in dq.inx.iref_by_sect[v.uid].a: 
     401              u = dq.inx.iref_by_sect[v.uid].a['qcranges'][0] 
     402              qc = dq.inx.uid[u] 
     403              ll = [] 
     404              for k in ['valid_min', 'valid_max', 'ok_min_mean_abs', 'ok_max_mean_abs']: 
     405                if qc.hasattr(k): 
     406                  ll.append( '%s %s' % (qc.__dict__[k],qc.__dict__['%s_status' % k][0]) ) 
     407                else: 
     408                  ll.append( '' ) 
     409              valid_min, valid_max, ok_min_mean_abs, ok_max_mean_abs = tuple( ll ) 
     410            else: 
     411              valid_min, valid_max, ok_min_mean_abs, ok_max_mean_abs = ('','','','') 
     412                
    400413            if mode == 'c': 
    401414              orec = [str(v.defaultPriority),cv.title, cv.units, cv.description, v.description, cv.label, cv.sn, strc.cell_methods, v.positive, v.type, dims, v.label, v.modeling_realm, v.frequency, strc.cell_measures, v.prov,v.provNote,str(v.rowIndex),v.uid,v.vid,v.stid,strc.title] 
  • CMIP6dreqbuild/trunk/src/framework/dreqPy/packageConfig.py

    r885 r894  
    1515 
    1616__versionComment__ = "Updates to AerChemMIP experiment names; removed some variable duplication; cleaned uid strings" 
    17 __version__ = "01.beta.44" 
     17__version__ = "01.beta.45" 
    1818__title__ = "dreqPy" 
    1919__description__ = "CMIP6 Data Request Python API" 
  • CMIP6dreqbuild/trunk/src/framework/dreqPy/scope.py

    r885 r894  
    132132       u'monClim':12, u'Timestep':100, u'6hr':4*365, u'day':365, u'1day':365, u'mon':12, u'yr':1, 
    133133       u'1mon':12, 'month':12, 'year':1, 'monthly':12, 'hr':24*365, 'other':24*365, 
    134         'subhr':24*365, 'Day':365, '6h':4*365, '3 hourly':8*365, '':1 } 
     134        'subhr':24*365, 'Day':365, '6h':4*365, '3 hourly':8*365, '':1, 'dec':0.1 } 
    135135 
    136136## There are 4 cmor variables with blank frequency .... 
     
    172172    self.gridOceanStructured = True 
    173173    self.gridPolicyForce = None 
     174    self.retainRedundantRank = True 
    174175    self.gridPolicyTopOnly = True 
    175176    self.exptFilter = None 
     
    559560    return ff 
    560561 
    561   def volByExpt( self, l1, ex, pmax=1, cc=None, retainRedundantRank=False, intersection=False,expFullEx=False, adsCount=False ): 
     562  def volByExpt( self, l1, ex, pmax=1, cc=None, intersection=False,expFullEx=False, adsCount=False ): 
    562563    """volByExpt: calculates the total data volume associated with an experiment/experiment group and a list of request items. 
    563564          The calculation has some approximations concerning the number of years in each experiment group. 
     
    591592## filter by configuration option and rank 
    592593## 
    593     if not retainRedundantRank: 
     594    if not self.retainRedundantRank: 
    594595      len1 = len(vars.keys()) 
    595596      cmv = self.cmvFilter.filterByChoiceRank(cmv=vars.keys()) 
     
    11241125      cmv2, cmvts2 = self.cmvByMip('TOTAL',pmax=pmax,includeYears=True,exptFilter=self.exptFilter,exptFilterBlack=self.exptFilterBlack) 
    11251126      cmv = self.differenceSelectedCmvDict(  cmv1, cmv2 ) 
     1127 
     1128    if not self.retainRedundantRank: 
     1129      len1 = len(cmv) 
     1130      self.cmvFilter.filterByChoiceRank(cmv=cmv,asDict=True) 
     1131      len2 = len(cmv) 
     1132      print 'INFO.redundant.0001: length %s --> %s' % (len1,len2) 
     1133    else: 
     1134      print 'INFO.redundant.0002' 
    11261135  
    11271136    self.selectedCmv = cmv 
     
    13531362        return l2 
    13541363 
    1355   def volByMip( self, mip, pmax=2, retainRedundantRank=False, intersection=False, adsCount=False, exptid=None): 
     1364  def volByMip( self, mip, pmax=2, intersection=False, adsCount=False, exptid=None): 
    13561365 
    13571366    l1 = self.rqiByMip( mip ) 
     
    13741383      if expts not in  [None,[]]: 
    13751384        for ei in expts: 
    1376           self.volByE[ei.label] = self.volByExpt( l1, ei.uid, pmax=pmax, cc=cc, retainRedundantRank=retainRedundantRank, intersection=intersection, adsCount=adsCount ) 
     1385          self.volByE[ei.label] = self.volByExpt( l1, ei.uid, pmax=pmax, cc=cc, intersection=intersection, adsCount=adsCount ) 
    13771386          vtot += self.volByE[ei.label][0] 
    13781387        self.allVars = self.allVars.union( self.vars ) 
     
    16371646    ##doSf = 'SF' in self.adict or 'sf' in self.adict 
    16381647    doSf = 'legacy' not in self.adict 
     1648    if doSf: 
     1649      self.adict['sf'] = True 
    16391650    assert not ('legacy' in self.adict and 'sf' in self.adict), "Conflicting command line argument, 'legacy' and 'sf': use only one of these" 
    16401651    if makeXls or makeTxt or doSf: 
  • CMIP6dreqbuild/trunk/src/framework/dreqPy/utilities.py

    r885 r894  
     1import re 
     2 
     3class markupHtml(object): 
     4  def __init__(self,base): 
     5    self.resect = re.compile( '(\{[a-zA-Z]*\})' ) 
     6    self.relink = re.compile( '(\[http\S*.*\])' ) 
     7    self.base = base 
     8 
     9  def parse(self,ss): 
     10    print 'INFO.parsing: ',ss 
     11    for x in self.resect.findall( ss ): 
     12      print 'INFO.parsing.0001: ',x 
     13      ss = ss.replace( x, self.sectionlink(x) ) 
     14    for x in self.relink.findall( ss ): 
     15      print 'INFO.parsing.0001: ',x 
     16      ss = ss.replace( x, self.linklink(x) ) 
     17    return ss 
     18 
     19  def sectionlink( self, x ): 
     20    x1 = x[1:-1] 
     21    return '<a href=%s%s.html>%s</a>' % (self.base,x1,x1) 
     22  def linklink( self, x ): 
     23    a,b = x[1:-1].split( None, 1 ) 
     24    return '<a href=%s>%s</a>' % (a,b) 
     25 
    126 
    227class gridOptionSort(object): 
     
    109134 
    110135    return cmv 
    111   def filterByChoiceRank(self,cmv=None): 
     136 
     137  def filterByChoiceRank(self,cmv=None,asDict=False): 
    112138    """Filter a set of CMOR variable identifiers by rank as specified in varChoiceLinkR section of the data request. 
    113139       cmv: set of CMOR variable identifiers. 
    114140       
    115141       Returns the filetered set. The items removed are available in self.rejected.""" 
     142    if asDict: 
     143      assert cmv != None, 'Cannot have empty cmv argument if asDict is True' 
    116144## 
    117145## cmv is a set of CMORvar ids 
     
    128156    if len(v1) == 0: 
    129157      ## print 'Nothing to do' 
    130       return cmv 
     158      if asDict: 
     159        return 
     160      else: 
     161        return cmv 
    131162 
    132163## set of "rank" choice groups relevant to current selection 
     
    145176          if i.rank < mr: 
    146177            l1 = len(cmv) 
    147             cmv.remove( i.vid ) 
     178            if asDict: 
     179               cmv.pop( i.vid ) 
     180            else: 
     181              cmv.remove( i.vid ) 
    148182            if len(cmv) == l1: 
    149183              print ( 'Failed to remove i.vid=%s' % i.vid ) 
     
    156190        pass 
    157191 
    158     return cmv 
     192    if asDict: 
     193      return 
     194    else: 
     195      return cmv 
    159196 
    160197 
Note: See TracChangeset for help on using the changeset viewer.