Changeset 1748 in lmdz_wrf
- Timestamp:
- Dec 17, 2017, 4:21:01 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/ORforcing_reconstruct.py
r1746 r1748 228 228 quit(-1) 229 229 230 slices = gen.provide_slices(vardims, shapevar, ['x','y'])230 print ' reconstructing:', vn, '...' 231 231 # Filling variable. It would be faster if we can avoid this loop... I'm feeling lazy! 232 232 if not gen.searchInlist(vardims,'x') and not gen.searchInlist(vardims,'y'): 233 233 newvar[:] = ovar[:] 234 234 else: 235 iix = vardims.index('x') 236 iiy = vardims.index('y') 237 iislc = 0 238 Nslices = len(slices) 239 for slc in slices: 240 gen.percendone(iislc,Nslices,0.25,vn + ' reconstructed:') 241 ival = slc[iix] 242 jval = slc[iiy] 243 # Avoiding not found grid points 244 if matind[jval,ival] != -1: 245 oldvarslice = [] 246 for dn in indn: 247 if dn == vecdimn: oldvarslice.append(matind[jval,ival]) 248 else: 249 iid = vardims.index(dn) 250 oldvarslice.append(slc[iid]) 251 252 newvar[tuple(slc)] = ovar[tuple(oldvarslice)] 253 else: 254 if type(newvar.dtype) == type(float(2.)) or \ 255 type(newvar.dtype) == type(np.float(2.)) or \ 256 type(newvar.dtype) == type(np.float32(2)) or \ 257 type(newvar.dtype) == type(np.float64(2)): 258 newvar[tuple(slc)] = gen.fillValuerF 259 else: 260 newvar[tuple(slc)] = gen.fillValueI 235 ovart = ovar[:].transpose() 236 if newvar.dtype == type(float(2.)) or newvar.dtype == type(np.float(2.)) \ 237 or newvar.dtype == type(np.float32(2)) or \ 238 newvar.dtype == type(np.float64(2)): 239 newvals = Sci.module_scientific.fill3dr_2dvec(matind=matindt, \ 240 inmat=ovart, id1=ovart.shape[0], id2=ovart.shape[1], \ 241 od1=newvar.shape[2], od2=newvar.shape[1], od3=newvar.shape[0]) 242 else: 243 newvals = Sci.module_scientific.fill3di_2dvec(matind=matindt, \ 244 inmat=ovart, id1=ovart.shape[0], id2=ovart.shape[1], \ 245 od1=newvar.shape[2], od2=newvar.shape[1], od3=newvar.shape[0]) 246 newvar[:] = newvals.transpose() 261 247 262 248 # Attributes 263 249 for atn in ovar.ncattrs(): 264 if atn != ' fill_Value' and atn != 'units':250 if atn != '_FillValue' and atn != 'units': 265 251 atv = ovar.getncattr(atn) 266 252 ncvar.set_attribute(newvar, atn, atv) … … 273 259 ncvar.set_attribute(onewnc, atn, atv) 274 260 onewnc.sync() 275 ncvar.add_global_PyNCplot(onewnc, pyscript, fname, '0.1')261 ncvar.add_global_PyNCplot(onewnc, main, fname, '0.1') 276 262 277 263 onc.close()
Note: See TracChangeset
for help on using the changeset viewer.