Changeset 1255 in lmdz_wrf for trunk/tools
- Timestamp:
- Nov 2, 2016, 7:53:58 PM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/nc_var_tools.py
r1242 r1255 17120 17120 unstaggerDIM = 'lon' 17121 17121 17122 print ' ' + fname + ': CF dimension lengths:', CFdimvs 17123 17122 17124 # sfc pressure 17123 17125 if modname == 'WRF': … … 17285 17287 # de-staggering 17286 17288 if gen.searchInlist(ovarin.dimensions, unstaggerDIM): 17287 varin t= gen.stagger_unstagger(varin,list(ovarin.dimensions),MODdimvs)17289 varin = gen.stagger_unstagger(varin,list(ovarin.dimensions),MODdimvs) 17288 17290 else: 17289 varin t= gen.stagger_unstagger(varin,list(ovarin.dimensions),CFdimvs)17291 varin = gen.stagger_unstagger(varin,list(ovarin.dimensions),CFdimvs) 17290 17292 isgeop = False 17291 17293 if vn == 'z': isgeop = True … … 17299 17301 newvarattr[attrn] = attrv 17300 17302 17301 print fname + '; Lluis varin shape:', varin.shape17302 17303 if varin is not None: 17303 varint = varin.transpose()17304 prest = pres.transpose()17305 psfct = psfc.transpose()17306 hgtt = hgt.transpose()17307 tempt = temp.transpose()17308 qvt = qv.transpose()17309 17310 print fname + '; Lluis going to the subroutine....'17311 print fname + '; Lluis shapes: varint:', varint.shape,'prest:',prest.shape,'psfct:',psfct.shape,\17312 'hgtt:', hgtt.shape,'tempt:',tempt.shape,'qvt:',qvt.shape17313 varinterp = fin.module_forinterpolate.interp( data_in=varint, \17314 pres_field=prest, interp_levels=interplevs, psfc=psfct, \17315 ter=hgtt, tk=tempt, qv=qvt, linlog=linloginterp, \17316 extrapolate=extrap, geopt=isgeop, missing=gen.fillValueF, ix=dimx, \17317 iy=dimy, iz=dimz, it=dimt, num_metgrid_levels=len(interplevs))17318 print fname + '; Lluis after the subroutine'17319 17320 17304 newvar = onewnc.createVariable(CFvn, 'f4', tuple(newMODdims), \ 17321 17305 fill_value=gen.fillValueF) 17322 newvar[:] = varinterp.transpose() 17306 # There is a memroy issue, thus is necessary to split the matrix... 17307 if np.prod(list(varin.shape)) > 150*150*39: 17308 dimtfrac = 5 17309 varinterp = np.zeros(tuple([dimx,dimy,len(interplevs),dimtfrac]), dtype=np.float) 17310 print warnmsg 17311 print ' ' + fname + ': variable to interpolate:', varin.shape, \ 17312 'too big!!' 17313 print ' p-interpolation will be done by time-slices of 5 time-steps' 17314 print range(0,dimtfrac*int(dimt/dimtfrac),dimtfrac) 17315 else: 17316 dimtfrac = dimt 17317 varinterp = np.zeros(tuple([dimx,dimy,len(interplevs),dimt]), dtype=np.float) 17318 for itt in range(0,dimtfrac*int(dimt/dimtfrac),dimtfrac): 17319 tini = itt 17320 tend = itt + dimtfrac 17321 varint = varin[tini:tend,:,:,:].transpose() 17322 prest = pres[tini:tend,:,:,:].transpose() 17323 psfct = psfc[tini:tend,:,:].transpose() 17324 hgtt = hgt.transpose() 17325 tempt = temp[tini:tend,:,:,:].transpose() 17326 qvt = qv[tini:tend,:,:,:].transpose() 17327 17328 varinterp = fin.module_forinterpolate.interp( data_in=varint, \ 17329 pres_field=prest, interp_levels=interplevs, psfc=psfct, \ 17330 ter=hgtt, tk=tempt, qv=qvt, linlog=linloginterp, \ 17331 extrapolate=extrap, geopt=isgeop, missing=gen.fillValueF) 17332 newvar[tini:tend,:,:,:] = varinterp.transpose() 17333 17334 if dimtfrac != dimt: 17335 print ' finishing time-splitting:', tend, ', ', dimt 17336 varint = varin[tend:dimt,:,:,:].transpose() 17337 prest = pres[tend:dimt,:,:,:].transpose() 17338 psfct = psfc[tend:dimt,:,:].transpose() 17339 hgtt = hgt.transpose() 17340 tempt = temp[tend:dimt,:,:,:].transpose() 17341 qvt = qv[tend:dimt,:,:,:].transpose() 17342 17343 varinterplast = fin.module_forinterpolate.interp( data_in=varint, \ 17344 pres_field=prest, interp_levels=interplevs, psfc=psfct, \ 17345 ter=hgtt, tk=tempt, qv=qvt, linlog=linloginterp, \ 17346 extrapolate=extrap, geopt=isgeop, missing=gen.fillValueF) 17347 17348 newvar[tend:dimt,:,::] = varinterplast.transpose() 17323 17349 17324 17350 for attrn in newvarattr.keys():
Note: See TracChangeset
for help on using the changeset viewer.