Changeset 2224 in lmdz_wrf for trunk/tools
- Timestamp:
- Nov 9, 2018, 3:41:43 PM (6 years ago)
- Location:
- trunk/tools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/nc_var.py
r2219 r2224 64 64 ## e.g. # nc_var.py -o compute_slice2Dstats -S 'XLAT,-63.,19.,2.,HGT,250.,7000.,500.,Time|Times:west_east|XLONG:south_north|XLAT' -f wrfout_d01_1995-01-01_00:00:00 -v T2,Q2 65 65 ## e.g. # nc_var.py -o same_deltasign -f wrfout_d01_1995-01-01_00:00:00 -S 'Time:0|south_north:60|west_east:-1' -v T2,Q2,XLAT,XLONG 66 ## e.g. # nc_var.py -o compute_slices_stats -S 'XLONG,-74.,-36.,4.;XLAT,-6 3.,19.,2.;HGT,250.,7000.,500.@Time|Times:west_east|XLONG:south_north|XLAT@Time' -f wrfout_d01_1995-01-01_00:00:00 -v T2,Q266 ## e.g. # nc_var.py -o compute_slices_stats -S 'XLONG,-74.,-36.,4.;XLAT,-62.,18.,2.;HGT,500.,7000.,500.@Time|Times:west_east|XLONG:south_north|XLAT@Time' -f wrfout_d01_1995-01-01_00:00:00 -v T2,Q2 67 67 68 68 from optparse import OptionParser -
trunk/tools/nc_var_tools.py
r2219 r2224 26448 26448 maxvar[i]: maximum value to end the slices for variable i 26449 26449 slcevar[i]: length of slices in variable i 26450 NOTE: slices will be: 26451 [minvar[i]-slicevar[i]/2., minvar[i]+slicevar[i]/2.), ..., 26452 [maxvar[i]-slicevar[i]/2., maxvar[i]+slicevar[i]/2.) 26450 26453 [dimvars]: ':' separated list of [dimn]|[vardimn] dimension name [dimn] and 26451 26454 its associated dimension-variable to get its values to provide values for … … 26544 26547 slcvals = np.zeros((Nslices,2), dtype=np.float) 26545 26548 varv = ovar[:] 26546 for islc in range(Nslices-1): 26547 slcvar[islc,] = ma.masked_inside(varv, slices[islc], slices[islc+1]).mask 26548 slcvalsc[islc] = (slices[islc+1]+slices[islc+1])/2. 26549 slcvals[islc,0] = slices[islc] 26550 slcvals[islc,1] = slices[islc+1] 26549 print varv.dtype 26550 for islc in range(Nslices): 26551 slcvalsc[islc] = slices[islc] 26552 slcvals[islc,0] = slices[islc]-slicevar/2. 26553 slcvals[islc,1] = slices[islc]+slicevar/2. 26554 #slcvar[islc,] = ma.masked_inside(varv, slcvals[islc,0], slcvals[islc,1]).mask 26555 slcvar[islc,] = ma.masked_outside(varv, slcvals[islc,0], slcvals[islc,1]).mask 26551 26556 26552 26557 slicesinf[varn] = [Nslices, dimnv, slcvar] … … 26581 26586 slcv = np.zeros(tuple(slcshape), dtype=int) 26582 26587 for islc in range(Nslices): 26583 vvslc = slcvar[islc,]26588 vvslc = ~slcvar[islc,] 26584 26589 slcv[islc,] = np.where(vvslc, 1, 0) 26585 26590 newvar = onewnc.createVariable(varn+'sliced', 'i', tuple(slcdims)) … … 26722 26727 slcnewvar.append(islcN[iv]) 26723 26728 if iv == 0: newmask = masksv[islcN[iv]] 26724 else: newmask = newmask *masksv[islcN[iv]]26729 else: newmask = newmask+masksv[islcN[iv]] 26725 26730 iv = iv + 1 26726 26731 … … 26728 26733 slcnewvar.append(slice(0,iid)) 26729 26734 26730 mavals = ma.array(varv, mask= ~newmask)26735 mavals = ma.array(varv, mask=newmask) 26731 26736 #newvarNmasked[tuple(slcnewvar)] = mavals.filled(gen.fillValueF) 26732 26737 newvarNmasked[:] = mavals.filled(gen.fillValueF)
Note: See TracChangeset
for help on using the changeset viewer.