Changeset 2198 in lmdz_wrf


Ignore:
Timestamp:
Oct 19, 2018, 3:06:26 PM (6 years ago)
Author:
lfita
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/nc_var_tools.py

    r2197 r2198  
    2619926199            quit(-1)
    2620026200
    26201 
    2620226201    ovar1 = onc.variables[varn1]
    2620326202    ovar2 = onc.variables[varn2]
    2620426203    v1u = ovar1.units
    2620526204    v2u = ovar2.units
     26205    dimnv1 = list(ovar1.dimensions)
     26206    dimnv2 = list(ovar2.dimensions)
    2620626207
    2620726208    dvar1 = (maxvar1 - minvar1+slicevar1)/slicevar1
     
    2625526256
    2625626257    # variable dimensions
     26258    for dn in dimnv1:
     26259        if not gen.searchInlist(onewnc.dimensions,dn): add_dims(onc, onewnc, [dn])
     26260
    2625726261    newvar = onewnc.createVariable('slice_'+varn1, 'f', ('slice_'+varn1))
    2625826262    newvar[:] = slcvalsc1[:]
     
    2626526269      varn1, v1u)
    2626626270
     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
    2626726284    newvar = onewnc.createVariable('slice_'+varn2, 'f', ('slice_'+varn2))
    2626826285    newvar[:] = slcvalsc2[:]
     
    2627426291    basicvardef(newvar, 'slice_'+varn2+'_bnds', 'boundaries of slices for variable '+\
    2627526292      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)
    2627626303
    2627726304    for varn in varns:
Note: See TracChangeset for help on using the changeset viewer.