Changeset 909 in lmdz_wrf for trunk/tools


Ignore:
Timestamp:
Jun 20, 2016, 1:12:53 PM (8 years ago)
Author:
lfita
Message:

Adding:

  • de-staggering of the variable
  • come-back to the WRF dimension names
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/nc_var_tools.py

    r907 r909  
    1598715987    newWRFdims = ['Time', 'pres', 'south_north', 'west_east']
    1598815988    notCHK = ['WRFght', 'WRFt', 'WRFrh']
     15989    CFdims = ['time', 'pres', 'lat', 'lon']
    1598915990
    1599015991    varns = gen.str_list(variables, ',')
     
    1600916010    # looking for WRF required variables
    1601016011    WRFvarrequired = ['P', 'PB', 'PSFC', 'PH', 'PHB', 'HGT', 'T', 'QVAPOR', 'XLONG', \
    16011       'XLAT', 'Times' , 'P_TOP']
     16012      'XLAT', 'Times']
    1601216013    for var in WRFvarrequired:
    1601316014        if not gen.searchInlist(onc.variables, var):
     
    1605816059    temp = ((ovar1[:]+300.)*(pres[:]/p0)**RCP).astype('float64')
    1605916060
     16061    WRFdimvs = {'Time':dimt, 'bottom_top':dimz, 'south_north':dimy, 'west_east': dimx}
     16062
    1606016063    onewnc = NetCDFFile(ofile, 'w')
    1606116064# Creation of dimensions
     
    1607016073        ovar = onc.variables[var]
    1607116074        varinf = variable_inf(ovar)
     16075        newvard = []
    1607216076        for vd in varinf.dimns:
    16073             if not gen.searchInlist(onewnc.dimensions, vd):
     16077            if not gen.searchInlist(onewnc.dimensions, vd) and                       \
     16078              not gen.searchInlist(CFdims, vd):
    1607416079                newdim = onewnc.createDimension(vd, len(onc.dimensions[vd]))
     16080            if gen.searchInlist(CFdims,vd):
     16081                icfdim = CFdims.index(vd)
     16082                newvard.append(WRFdims[icfdim])
     16083            else:
     16084                newvard.append(vd)
     16085
    1607516086        newvar = onewnc.createVariable(var, nctype(varinf.dtype),                    \
    16076           tuple(varinf.dimns))
     16087          tuple(newvard))
    1607716088        newvar[:] = ovar[:]
    1607816089        for attrn in ovar.ncattrs():
     
    1612616137            varinf = variable_inf(ovarin)
    1612716138            varin = ovarin[:]
     16139            # de-staggering
     16140            if gen.searchInlist(ovarin.dimensions, 'west_east'):
     16141                varint = gen.stagger_unstagger(varin,list(ovarin.dimensions),WRFdimvs)
     16142            else:
     16143                CFdimvs = {'time': dimt, 'bottom_top': dimz, 'lat': dimy, 'lon': dimx}
     16144                varint = gen.stagger_unstagger(varin,list(ovarin.dimensions),CFdimvs)
    1612816145            isgeop = False
     16146            if vn == 'z': isgeop = True
    1612916147            varattrs = gen.variables_values(vn)
    1613016148            CFvn = varattrs[0]
     
    1614316161            tempt = temp.transpose()
    1614416162            qvt = qv.transpose()
     16163            print fname + ' Lluis shapes varint:', varint.shape, 'prest:', prest.shape, \
     16164              'psfct:', psfct.shape, 'hgtt:', hgtt.shape,' tempt:', tempt.shape, 'qvt:',qvt.shape
    1614516165            varinterp = fin.module_forinterpolate.interp( data_in=varint,            \
    1614616166              pres_field=prest, interp_levels=interplevs, psfc=psfct,                \
Note: See TracChangeset for help on using the changeset viewer.