Changeset 2198 in lmdz_wrf
- Timestamp:
- Oct 19, 2018, 3:06:26 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/nc_var_tools.py
r2197 r2198 26199 26199 quit(-1) 26200 26200 26201 26202 26201 ovar1 = onc.variables[varn1] 26203 26202 ovar2 = onc.variables[varn2] 26204 26203 v1u = ovar1.units 26205 26204 v2u = ovar2.units 26205 dimnv1 = list(ovar1.dimensions) 26206 dimnv2 = list(ovar2.dimensions) 26206 26207 26207 26208 dvar1 = (maxvar1 - minvar1+slicevar1)/slicevar1 … … 26255 26256 26256 26257 # variable dimensions 26258 for dn in dimnv1: 26259 if not gen.searchInlist(onewnc.dimensions,dn): add_dims(onc, onewnc, [dn]) 26260 26257 26261 newvar = onewnc.createVariable('slice_'+varn1, 'f', ('slice_'+varn1)) 26258 26262 newvar[:] = slcvalsc1[:] … … 26265 26269 varn1, v1u) 26266 26270 26271 slcdims = ['slice_'+varn1] + dimnv1 26272 slcshape = [Nslices1] + list(ovar1.shape) 26273 slcv = np.zeros(tuple(slcshape), dtype=int) 26274 for islc in range(Nslices1): 26275 vvslc = slcvar1[islc,] 26276 slcv[islc,] = np.where(vvslc, 1, 0) 26277 newvar = onewnc.createVariable(varn1+'sliced', 'i', tuple(slcdims)) 26278 newvar[:] = slcv[:] 26279 basicvardef(newvar, varn1+'sliced', 'sliced variable ' + varn1, v1u) 26280 26281 for dn in dimnv2: 26282 if not gen.searchInlist(onewnc.dimensions,dn): add_dims(onc, onewnc, [dn]) 26283 26267 26284 newvar = onewnc.createVariable('slice_'+varn2, 'f', ('slice_'+varn2)) 26268 26285 newvar[:] = slcvalsc2[:] … … 26274 26291 basicvardef(newvar, 'slice_'+varn2+'_bnds', 'boundaries of slices for variable '+\ 26275 26292 varn2, v2u) 26293 26294 slcdims = ['slice_'+varn2] + dimnv2 26295 slcshape = [Nslices2] + list(ovar2.shape) 26296 slcv = np.zeros(tuple(slcshape), dtype=int) 26297 for islc in range(Nslices2): 26298 vvslc = slcvar2[islc,] 26299 slcv[islc,] = np.where(vvslc, 1, 0) 26300 newvar = onewnc.createVariable(varn2+'sliced', 'i', tuple(slcdims)) 26301 newvar[:] = slcv[:] 26302 basicvardef(newvar, varn2+'sliced', 'sliced variable ' + varn2, v2u) 26276 26303 26277 26304 for varn in varns:
Note: See TracChangeset
for help on using the changeset viewer.