Changeset 206
- Timestamp:
- 05/09/14 16:56:34 (6 years ago)
- Location:
- CCCC/trunk/ceda_cc
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
CCCC/trunk/ceda_cc/c4.py
r204 r206 255 255 return 256 256 257 fltype = None 257 258 argu = [] 258 259 while len(args) > 0: 259 260 next = args.pop(0) 260 261 if next == '-f': 262 print '###########',args[0] 261 263 flist = [args.pop(0),] 262 264 self.logByFile = False 265 fltype = '-f' 263 266 elif next == '--log': 264 267 x = args.pop(0) … … 306 309 self.commandHints( argsIn ) 307 310 308 if self.project == 'CMIP5' :311 if self.project == 'CMIP5' and fltype != '-f': 309 312 fl0 = [] 310 313 for f in flist: -
CCCC/trunk/ceda_cc/file_utils.py
r205 r206 15 15 16 16 installedSupportedNetcdf = [] 17 ##ll = []17 ll = [] 18 18 19 19 for x in supportedNetcdf: … … 76 76 self.loadNc__Scientific(fpath) 77 77 else: 78 raise baseException( 'No supported netcdf module assigned' ) 79 80 def loadNc_ncq(self,fpath): 78 self.loadNc__ncq(fpath) 79 ##raise baseException( 'No supported netcdf module assigned' ) 80 81 def loadNc__ncq(self,fpath): 81 82 self.nc0 = ncq3.open( fpath ) 82 83 self.nc0.getDigest() 83 84 self.nc0.info() 84 85 self.nc = ncq3.Browse( self.nc0.digest ) 85 for a in self.nc._ga :86 for a in self.nc._gal: 86 87 self.ga[a.name] = a.value 87 88 for v in self.nc._vdict.keys(): 88 thisv = self.nc._vdict[v] 89 thisv = self.nc._vdict[v][0] 89 90 if v not in self.nc._ddict.keys(): 90 91 self.va[v] = {} 91 for a in self.nc._ll[thisv [0].id]:92 for a in self.nc._ll[thisv.id]: 92 93 self.va[v][a.name] = a.value 93 94 self.va[v]['_type'] = tstr( thisv.type ) … … 100 101 self.da[v] = {} 101 102 thisa = self.nc._ddict[v] 102 for a in self.nc._ll[thisv [0].id]:103 for a in self.nc._ll[thisv.id]: 103 104 self.da[v][a.name] = a.value 104 105 self.da[v]['_type'] = tstr( thisv.type ) -
CCCC/trunk/ceda_cc/ncq3.py
r205 r206 62 62 NC_DOUBLE:c_double } 63 63 64 ncmappings.tdict2 = { NC_BYTE:"byte", 65 NC_SHORT:"short", 66 NC_INT:"int", 67 NC_LONG:"long", 68 NC_FLOAT:"float", 69 NC_DOUBLE:"double" } 70 64 71 NC_MAX_NAME = 256 65 72 … … 114 121 ti = -2 115 122 for a in self.nc.attributes: 116 print a.id, a.vid, a.name, len(self._ll[a.vid])117 123 if a.vid != -1: 118 124 assert a.id == len(self._ll[a.vid]), 'Unexpected attribute id: %s -- %s' % (str(a),str(self._ll[a.vid]) ) … … 198 204 data = (c_double*len)() 199 205 err = libnetcdf.nc_get_var_double(self.id, i, data) 200 self.vars.append( Variable( name.value, 0, i, type.value, natts.value, ndims.value, list(dimids), data[:] ) )206 self.vars.append( Variable( name.value, 0, i, ncmappings.tdict2[type.value], natts.value, ndims.value, list(dimids), data[:] ) ) 201 207 else: 202 self.vars.append( Variable( name.value, 0, i, type.value, natts.value, ndims.value, list(dimids), None ) )208 self.vars.append( Variable( name.value, 0, i, ncmappings.tdict2[type.value], natts.value, ndims.value, list(dimids), None ) ) 203 209 else: 204 210 self.vars.append( VarInfo( name.value, 0, i, type.value, natts.value, ndims.value, list(dimids) ) ) … … 255 261 tt = ncmappings.tdict.get( type, None ) 256 262 if tt == None: raise NCError("unknown data type") 263 t2 = ncmappings.tdict2.get( type, None ) 257 264 if len > 1: 258 265 data = (tt*len)() 259 266 err = libnetcdf.nc_get_att(self.id, vid, c_char_p(name), data) 260 267 if err != 0: raise NCError( 'Error reading attribute value %s, type:%s' % (name,type) ) 261 return Attribute( name, 0, vid, aid, t ype, len, data )268 return Attribute( name, 0, vid, aid, t2, len, data ) 262 269 else: 263 270 data = tt() 264 271 err = libnetcdf.nc_get_att(self.id, vid, c_char_p(name), byref(data)) 265 272 if err != 0: raise NCError( 'Error reading attribute value %s, type:%s' % (name,type) ) 266 return Attribute( name, 0, vid, aid, type, len, data.value ) 273 print name, data.value, t2, type, float(data.value) 274 if type == 5: 275 dv = c_float( data.value ).value 276 else: 277 dv = data.value 278 return Attribute( name, 0, vid, aid, t2, len, dv ) 267 279 268 280 ## end of extension ## -
CCCC/trunk/ceda_cc/utils_c4.py
r201 r206 539 539 ok &= self.test( da['time'].has_key( 'calendar' ), 'Time: required attribute calendar missing', part=True ) 540 540 541 ok &= self.test( da['time']['_type'] == "float64", 'Time: data type not float64', part=True )541 ok &= self.test( da['time']['_type'] in ["float64","double"], 'Time: data type not float64 [%s]' % da['time']['_type'], part=True ) 542 542 543 543 if ok:
Note: See TracChangeset
for help on using the changeset viewer.