Changeset 255 for CCCC


Ignore:
Timestamp:
12/11/14 16:52:20 (6 years ago)
Author:
mjuckes
Message:

added check to convert scalar variables to lists in NetCDF4

File:
1 edited

Legend:

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

    r254 r255  
    2222      try:  
    2323        cmd = 'import %s' % x 
    24         print '>>>>>>>>>', cmd 
    2524        exec cmd 
    2625        installedSupportedNetcdf.append( x ) 
     
    6362    if self.forceLib == 'ncq3': 
    6463      import ncq3 
    65       print 'Using ncq3' 
    6664      self.ncq3 = ncq3 
    6765      self.ncLib = 'ncq3' 
    6866    elif self.forceLib == 'cdms2': 
    6967      import cdms2 
    70       print 'Using using cdms2' 
    7168      self.cdms2 = cdms2 
    7269      self.ncLib = 'cdms2' 
     
    7774    elif self.forceLib == 'Scientific': 
    7875      import Scientific 
    79       print 'Using scientific python' 
    8076      from Scientific.IO import NetCDF as ncdf 
    8177      self.ncdf = ncdf 
     
    10197      self.cdms2 = cdms2 
    10298      self.loadNc__Cdms(fpath) 
    103     elif self.ncLib == 'netCDF4': 
     99    elif self.ncLib[:7] == 'netCDF4': 
    104100      import netCDF4 
    105101      self.netCDF4 = netCDF4 
    106102      self.loadNc__Netcdf4(fpath) 
    107     elif self.ncLib == 'Scientific': 
     103    elif self.ncLib[:10] == 'Scientific': 
    108104      from Scientific.IO import NetCDF as ncdf 
    109105      self.ncdf = ncdf 
     
    230226        if v in ['plev','plev_bnds','height']: 
    231227          self.va[v]['_data'] = self.nc.variables[v][:].tolist() 
     228          if type( self.va[v]['_data'] ) != type( [] ): 
     229            self.va[v]['_data'] = [self.va[v]['_data'],] 
    232230 
    233231    for v in self.nc.dimensions.keys(): 
     
    242240 
    243241        self.da[v]['_data'] = self.nc.variables[v][:].tolist() 
     242        if type( self.da[v]['_data'] ) != type( [] ): 
     243            self.da[v]['_data'] = [self.da[v]['_data'],] 
    244244      else: 
    245245        self.da[v]['_type'] = 'index (no data variable)' 
Note: See TracChangeset for help on using the changeset viewer.