Changeset 966 in lmdz_wrf for trunk/tools
- Timestamp:
- Jun 28, 2016, 5:48:26 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/nc_var_tools.py
r964 r966 8838 8838 found = True 8839 8839 break 8840 if not found and not searchInlist(dimnslice,vardims[idd]):8840 if not found and not gen.searchInlist(dimnslice,vardims[idd]): 8841 8841 varvalsdim.append(slice(0,varobj.shape[idd])) 8842 8842 dimnslice.append(vardims[idd]) … … 16361 16361 16362 16362 onc = NetCDFFile(ncfile, 'r') 16363 filevars = list(onc.vari bles.keys)16363 filevars = list(onc.variables.keys()) 16364 16364 16365 16365 for var in variables: … … 16374 16374 ovar = onc.variables[var] 16375 16375 varinf = variable_inf(ovar) 16376 vardims = varin d.dmns16377 16378 newfiledims = list(onewnc.dimensions.keys )16376 vardims = varinf.dimns 16377 16378 newfiledims = list(onewnc.dimensions.keys()) 16379 16379 16380 16380 for vdim in vardims: 16381 16381 if not gen.searchInlist(newfiledims, vdim): 16382 16382 print ' ' + fname + ": including dimension '" + vdim + "'..." 16383 if onc.dimensions[vdim].isunlim ted:16383 if onc.dimensions[vdim].isunlimited(): 16384 16384 newdim = onewnc.createDimension(vdim, None) 16385 16385 else: 16386 16386 newdim = onewnc.createDimension(vdim, len(onc.dimensions[vdim])) 16387 16387 16388 if varinf.FillValue is not None:16389 newvar = onewnc.creatrVariable(var, nctype(varinf.dtype), tuple(vardims),\16390 fillvalue = varinf.FillValue)16391 else:16392 newvar = onewnc.creatrVariable(var, nctype(varinf.dtype), tuple(vardims))16393 16394 for attrn in varinf.atttributes:16395 attrv = ovar.getattribute(attrn)16396 newattr = set_attribute(newvar, attrn, attrv)16397 16398 onewnc.sync()16388 if varinf.FillValue is not None: 16389 newvar = onewnc.createVariable(var, nctype(varinf.dtype), tuple(vardims),\ 16390 fillvalue = varinf.FillValue) 16391 else: 16392 newvar = onewnc.createVariable(var, nctype(varinf.dtype), tuple(vardims)) 16393 16394 for attrn in varinf.attributes: 16395 attrv = ovar.getncattr(attrn) 16396 newattr = set_attribute(newvar, attrn, attrv) 16397 16398 onewnc.sync() 16399 16399 16400 16400 # Global attributes 16401 for attrn in onc.ncattrs :16402 attrv = ovar.getattribute(attrn)16403 newattr = set_attribute(newvar, attrn, attrv)16401 for attrn in onc.ncattrs(): 16402 attrv = onc.getncattr(attrn) 16403 newattr = set_attribute(onewnc, attrn, attrv) 16404 16404 16405 16405 onewnc.sync() … … 16408 16408 onewnc.close() 16409 16409 16410 print fname + ": successful written of '" + ncfile + "' !!"16410 print fname + ": successful written of '" + ofile + "' !!" 16411 16411 16412 16412 #quit()
Note: See TracChangeset
for help on using the changeset viewer.