Changeset 2224 in lmdz_wrf


Ignore:
Timestamp:
Nov 9, 2018, 3:41:43 PM (6 years ago)
Author:
lfita
Message:

Final working version of compute_slices_stats

Location:
trunk/tools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/nc_var.py

    r2219 r2224  
    6464## 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
    6565## 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,-63.,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,Q2
     66## 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
    6767
    6868from optparse import OptionParser
  • trunk/tools/nc_var_tools.py

    r2219 r2224  
    2644826448          maxvar[i]: maximum value to end the slices for variable i
    2644926449          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.)
    2645026453        [dimvars]: ':' separated list of [dimn]|[vardimn] dimension name [dimn] and
    2645126454          its associated dimension-variable to get its values to provide values for
     
    2654426547        slcvals = np.zeros((Nslices,2), dtype=np.float)
    2654526548        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
    2655126556
    2655226557        slicesinf[varn] = [Nslices, dimnv, slcvar]
     
    2658126586        slcv = np.zeros(tuple(slcshape), dtype=int)
    2658226587        for islc in range(Nslices):
    26583             vvslc = slcvar[islc,]
     26588            vvslc = ~slcvar[islc,]
    2658426589            slcv[islc,] = np.where(vvslc, 1, 0)
    2658526590        newvar = onewnc.createVariable(varn+'sliced', 'i', tuple(slcdims))
     
    2672226727                slcnewvar.append(islcN[iv])
    2672326728                if iv == 0: newmask = masksv[islcN[iv]]
    26724                 else: newmask = newmask*masksv[islcN[iv]]
     26729                else: newmask = newmask+masksv[islcN[iv]]
    2672526730                iv = iv + 1
    2672626731
     
    2672826733               slcnewvar.append(slice(0,iid))
    2672926734
    26730             mavals = ma.array(varv, mask=~newmask)
     26735            mavals = ma.array(varv, mask=newmask)
    2673126736            #newvarNmasked[tuple(slcnewvar)] = mavals.filled(gen.fillValueF)
    2673226737            newvarNmasked[:] = mavals.filled(gen.fillValueF)
Note: See TracChangeset for help on using the changeset viewer.