Changeset 1777 in lmdz_wrf for trunk/tools/diagnostics.py


Ignore:
Timestamp:
Feb 16, 2018, 3:17:02 PM (7 years ago)
Author:
lfita
Message:

Adding:

  • `WRFz': as height above surface unstaggering WRFgeop
  • Fixing zwind computation
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/diagnostics.py

    r1776 r1777  
    66#      ciclad: f2py --f90flags="-fPIC" --f90exec=/usr/bin/gfortran -L/opt/canopy-1.3.0/Canopy_64bit/System/lib/ -L/usr/lib64/ -L/opt/canopy-1.3.0/Canopy_64bit/System/lib/ -m module_ForDiagnostics -c module_generic.F90 module_ForDiagnosticsVars.F90 module_ForDiagnostics.F90 >& run_f2py.log
    77
    8 ## e.g. # diagnostics.py -d 'Time@time,bottom_top@ZNU,south_north@XLAT,west_east@XLONG' -v 'clt|CLDFRA,cllmh|CLDFRA@WRFp,RAINTOT|RAINC@RAINNC@XTIME' -f WRF_LMDZ/NPv31/wrfout_d01_1980-03-01_00:00:00
     8## e.g. # diagnostics.py -d 'Time@WRFtime,bottom_top@ZNU,south_north@XLAT,west_east@XLONG' -v 'clt|CLDFRA,cllmh|CLDFRA@WRFp,RAINTOT|RAINC@RAINNC@XTIME' -f WRF_LMDZ/NPv31/wrfout_d01_1980-03-01_00:00:00
    99## e.g. # diagnostics.py -f /home/lluis/PY/diagnostics.inf -d variable_combo -v WRFprc
    1010
     
    9090  'WRFp', 'WRFtd',                                                                   \
    9191  'WRFpos', 'WRFprc', 'WRFprls', 'WRFrh', 'LMDZrh', 'LMDZrhs', 'WRFrhs', 'WRFrvors', \
    92   'WRFt', 'WRFtime', 'WRFua', 'WRFva', 'WRFwds', 'WRFwss', 'WRFheight']
     92  'WRFt', 'WRFtime', 'WRFua', 'WRFva', 'WRFwds', 'WRFwss', 'WRFheight', 'WRFz']
    9393
    9494NONchkvardims = ['WRFtime']
     
    124124WRFpos_compute = False
    125125WRFtime_compute = False
     126WRFz_compute = False
    126127
    127128# File creation
     
    147148    if dnv == 'WRFpos': WRFpos_compute = True
    148149    if dnv == 'WRFtime': WRFtime_compute = True
     150    if dnv == 'WRFz':WRFz_compute = True
    149151
    150152# diagnostics to compute
     
    163165        if depvars == 'WRFpos': WRFpos_compute = True
    164166        if depvars == 'WRFtime': WRFtime_compute = True
     167        if depvars == 'WRFz': WRFz_compute = True
    165168    else:
    166169        depvars = diags[idiag].split('|')[1].split('@')
     
    173176        if gen.searchInlist(depvars, 'WRFpos'): WRFpos_compute = True
    174177        if gen.searchInlist(depvars, 'WRFtime'): WRFtime_compute = True
     178        if gen.searchInlist(depvars, 'WRFz'): WRFz_compute = True
    175179
    176180# Dictionary with the new computed variables to be able to add them
     
    325329    dictcompvars['WRFtime'] = {'name': 'time', 'standard_name': 'time',              \
    326330      'long_name': 'time', 'units': tunits, 'calendar': 'gregorian'}
     331
     332if WRFz_compute:
     333    print '  ' + main + ': Retrieving z: height above surface value from WRF as ' +  \
     334      'unstagger(PH + PHB)/9.8-hgt'
     335    dimv = ncobj.variables['PH'].shape
     336    WRFzg = (ncobj.variables['PH'][:] + ncobj.variables['PHB'][:])/9.8
     337
     338    unzgd = (dimv[0], dimv[1]-1, dimv[2], dimv[3])
     339    unzg = np.zeros(unzgd, dtype=np.float)
     340    unzg = 0.5*(WRFzg[:,0:dimv[1]-1,:,:] + WRFzg[:,1:dimv[1],:,:])
     341
     342    WRFz = np.zeros(unzgd, dtype=np.float)
     343    for iz in range(dimv[1]-1):
     344        WRFz[:,iz,:,:] = unzg[:,iz,:,:] - ncobj.variables['HGT'][:]
     345
     346    # Attributes of the variable
     347    Vvals = gen.variables_values('WRFz')
     348    dictcompvars['WRFz'] = {'name': Vvals[0], 'standard_name': Vvals[1],          \
     349      'long_name': Vvals[4].replace('|',' '), 'units': Vvals[5]}
    327350
    328351### ## #
     
    11231146        ncvar.insert_variable(ncobj, 'zmla', diagout, diagoutd, diagoutvd, newnc)
    11241147
    1125 # WRFzwind wind extrapolation at a given hieght computation from WRF U, V, WRFgeop,
    1126 #   U10, V10, HGT, SINALPHA, COSALPHA, z=[zval]
     1148# WRFzwind wind extrapolation at a given hieght computation from WRF U, V, WRFz,
     1149#   U10, V10, SINALPHA, COSALPHA, z=[zval]
    11271150    elif diagn == 'WRFzwind':
    11281151        var0 = ncobj.variables[depvars[0]][:]
    11291152        var1 = ncobj.variables[depvars[1]][:]
    1130         dimz = var0.shape[1]
    1131         var2 = WRFgeop[:,1:dimz+1,:,:]/9.8
     1153        var2 = WRFz
    11321154        var3 = ncobj.variables[depvars[3]][:]
    11331155        var4 = ncobj.variables[depvars[4]][:]
    11341156        var5 = ncobj.variables[depvars[5]][0,:,:]
    11351157        var6 = ncobj.variables[depvars[6]][0,:,:]
    1136         var7 = ncobj.variables[depvars[7]][0,:,:]
    1137         var8 = np.float(depvars[8].split('=')[1])
     1158        var7 = np.float(depvars[7].split('=')[1])
    11381159
    11391160        # un-staggering 3D winds
     
    11461167
    11471168        diagout1, diagout2, diagoutd, diagoutvd = diag.Forcompute_zwind(unvar0,      \
    1148           unvar1, var2, var3, var4, var5, var6, var7, var8, dnames, dvnames)
     1169          unvar1, var2, var3, var4, var5, var6, var7, dnames, dvnames)
    11491170
    11501171        # Removing the nonChecking variable-dimensions from the initial list
Note: See TracChangeset for help on using the changeset viewer.