Changeset 205


Ignore:
Timestamp:
05/09/14 16:12:28 (5 years ago)
Author:
mjuckes
Message:

Added ncq3 support -- as final recourse

Location:
CCCC/trunk/ceda_cc
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • CCCC/trunk/ceda_cc/file_utils.py

    r202 r205  
    1212ll = map( lambda x: x[1], l ) 
    1313 
    14 supportedNetcdf = ['cdms2','netCDF4','Scientific'] 
     14supportedNetcdf = ['cdms2','netCDF4','Scientific','ncq3'] 
    1515 
    1616installedSupportedNetcdf = [] 
     17##ll = [] 
    1718 
    1819for x in supportedNetcdf: 
     
    3031  print """No supported netcdf module found. 
    3132         Supported modules are %s. 
    32          Execution my fail, depending on options chosen. 
     33         Attempting to run with experimental ncq3 
     34         Execution may fail, depending on options chosen. 
    3335         """ % str(supportedNetcdf) 
    34   ncLib = None 
     36  import ncq3 
     37  ncLib = 'ncq3' 
    3538 
    3639if ncLib == 'Scientific': 
     
    7578      raise baseException( 'No supported netcdf module assigned' ) 
    7679 
     80  def loadNc_ncq(self,fpath): 
     81    self.nc0 = ncq3.open( fpath ) 
     82    self.nc0.getDigest() 
     83    self.nc0.info() 
     84    self.nc = ncq3.Browse( self.nc0.digest ) 
     85    for a in self.nc._ga: 
     86       self.ga[a.name] = a.value 
     87    for v in self.nc._vdict.keys(): 
     88      thisv = self.nc._vdict[v] 
     89      if v not in self.nc._ddict.keys(): 
     90        self.va[v] = {} 
     91        for a in self.nc._ll[thisv[0].id]: 
     92          self.va[v][a.name] = a.value 
     93        self.va[v]['_type'] = tstr( thisv.type ) 
     94        if v in ['plev','plev_bnds','height']: 
     95          x = thisv.data 
     96          if type(x) != type([]): 
     97            x = [x] 
     98          self.va[v]['_data'] = x 
     99      else: 
     100        self.da[v] = {} 
     101        thisa = self.nc._ddict[v] 
     102        for a in self.nc._ll[thisv[0].id]: 
     103          self.da[v][a.name] = a.value 
     104        self.da[v]['_type'] = tstr( thisv.type ) 
     105        self.da[v]['_data'] = thisv.data 
     106     
    77107  def loadNc__Cdms(self,fpath): 
    78108    self.nc = cdms2.open( fpath ) 
Note: See TracChangeset for help on using the changeset viewer.