Changeset 1777 in lmdz_wrf for trunk


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
Location:
trunk/tools
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/diag_tools.py

    r1776 r1777  
    911911
    912912
    913 def Forcompute_zwind(ua, va, zsl, uas, vas, hgt, sina, cosa, zval, dimns, dimvns):
     913def Forcompute_zwind(ua, va, z, uas, vas, sina, cosa, zval, dimns, dimvns):
    914914    """ Function to compute the wind at a given height following the power law method
    915915    Forcompute_zwind(ua, va, zsl, uas, vas, hgt, sina, cosa, zval, dimns, dimvns)
    916916      [ua]= x-component of unstaggered 3D wind (assuming [[t],z,y,x]) [ms-1]
    917917      [va]= y-component of unstaggered 3D wind (assuming [[t],z,y,x]) [ms-1]
    918       [zsl]= height above sea level [m]
     918      [z]= height above surface [m]
    919919      [uas]= x-component of unstaggered 10 m wind (assuming [[t],z,y,x]) [ms-1]
    920920      [vas]= y-component of unstaggered 10 m wind (assuming [[t],z,y,x]) [ms-1]
    921       [hgt]= topographical height (assuming [m]
    922921      [sina]= local sine of map rotation [1.]
    923922      [cosa]= local cosine of map rotation [1.]
     
    944943
    945944        pvar1, pvar2= fdin.module_fordiagnostics.compute_zwind4d(ua=ua.transpose(),  \
    946           va=va[:].transpose(), zsl=zsl[:].transpose(), uas=uas.transpose(),         \
    947           vas=vas.transpose(), hgt=hgt.transpose(), sina=sina.transpose(),           \
    948           cosa=cosa.transpose(), zextrap=zval, d1=dx, d2=dy, d3=dz, d4=dt)
     945          va=va[:].transpose(), z=z[:].transpose(), uas=uas.transpose(),             \
     946          vas=vas.transpose(), sina=sina.transpose(), cosa=cosa.transpose(),         \
     947          zextrap=zval, d1=dx, d2=dy, d3=dz, d4=dt)
    949948        var1 = pvar1.transpose()
    950949        var2 = pvar2.transpose()
  • trunk/tools/diagnostics.inf

    r1776 r1777  
    3434ua, WRFua, U@V@SINALPHA@COSALPHA
    3535va, WRFva, U@V@SINALPHA@COSALPHA
    36 uavaz, WRFzwind, U@V@WRFgeop@U10@V10@HGT@SINALPHA@COSALPHA@z=100.
     36uavaz, WRFzwind, U@V@WRFz@U10@V10@SINALPHA@COSALPHA@z=100.
    3737wa, OMEGAw, vitw@pres@temp
    3838wds, TSwds, u@v
  • 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
  • trunk/tools/module_ForDiagnostics.f90

    r1776 r1777  
    643643  END SUBROUTINE compute_zmla_generic4D
    644644
    645   SUBROUTINE compute_zwind4D(ua, va, zsl, uas, vas, hgt, sina, cosa, zextrap, uaz, vaz, d1, d2, d3, d4)
     645  SUBROUTINE compute_zwind4D(ua, va, z, uas, vas, sina, cosa, zextrap, uaz, vaz, d1, d2, d3, d4)
    646646! Subroutine to compute extrapolate the wind at a given height following the 'power law' methodology
    647647
     
    649649
    650650    INTEGER, INTENT(in)                                  :: d1, d2, d3, d4
    651     REAL(r_k), DIMENSION(d1,d2,d3,d4), INTENT(in)        :: ua, va, zsl
     651    REAL(r_k), DIMENSION(d1,d2,d3,d4), INTENT(in)        :: ua, va, z
    652652    REAL(r_k), DIMENSION(d1,d2,d4), INTENT(in)           :: uas, vas
    653     REAL(r_k), DIMENSION(d1,d2), INTENT(in)              :: hgt, sina, cosa
     653    REAL(r_k), DIMENSION(d1,d2), INTENT(in)              :: sina, cosa
    654654    REAL(r_k), INTENT(in)                                :: zextrap
    655655    REAL(r_k), DIMENSION(d1,d2,d4), INTENT(out)          :: uaz, vaz
     
    661661! tpot: potential air temperature [K]
    662662! qratio: water vapour mixing ratio [kgkg-1]
    663 ! z: height above sea level [m]
    664 ! hgt: terrain height [m]
     663! z: height above surface [m]
    665664! sina, cosa: local sine and cosine of map rotation [1.]
    666665! zmla3D: boundary layer height from surface [m]
     
    671670      DO j=1, d2
    672671        DO it=1, d4
    673           CALL var_zwind(d3, ua(i,j,:,it), va(i,j,:,it), zsl(i,j,:,it), uas(i,j,it), vas(i,j,it),    &
    674             hgt(i,j), sina(i,j), cosa(i,j), zextrap, uaz(i,j,it), vaz(i,j,it))
     672          CALL var_zwind(d3, ua(i,j,:,it), va(i,j,:,it), z(i,j,:,it), uas(i,j,it), vas(i,j,it),       &
     673            sina(i,j), cosa(i,j), zextrap, uaz(i,j,it), vaz(i,j,it))
    675674        END DO
    676675      END DO
  • trunk/tools/module_ForDiagnosticsVars.f90

    r1776 r1777  
    10271027  END SUBROUTINE var_zmla_generic
    10281028
    1029   SUBROUTINE var_zwind(d1, u, v, z, u10, v10, sa, ca, topo, newz, unewz, vnewz)
     1029  SUBROUTINE var_zwind(d1, u, v, z, u10, v10, sa, ca, newz, unewz, vnewz)
    10301030! Subroutine to extrapolate the wind at a given height following the 'power law' methodology
    10311031!    wss[newz] = wss[z1]*(newz/z1)**alpha
     
    10391039    INTEGER, INTENT(in)                                  :: d1
    10401040    REAL(r_k), DIMENSION(d1), INTENT(in)                 :: u,v,z
    1041     REAL(r_k), INTENT(in)                                :: u10, v10, topo, sa, ca, newz
     1041    REAL(r_k), INTENT(in)                                :: u10, v10, sa, ca, newz
    10421042    REAL(r_k), INTENT(out)                               :: unewz, vnewz
    10431043
     
    10491049!!!!!!! Variables
    10501050! u,v: vertical wind components [ms-1]
    1051 ! z: height above surface [m]
     1051! z: height above surface on half-mass levels [m]
    10521052! u10,v10: 10-m wind components [ms-1]
    1053 ! topo: topographical height [m]
    10541053! sa, ca: local sine and cosine of map rotation [1.]
    10551054! newz: desired height above grpund of extrapolation
     
    10581057    fname = 'var_zwind'
    10591058
    1060     PRINT *,' ilev zaground newz z[ilev+1] z[ilev+2] _______'
     1059    !PRINT *,' ilev zaground newz z[ilev+1] z[ilev+2] _______'
    10611060    IF (z(1) < newz ) THEN
    10621061      DO inear = 1,d1-2
    10631062        zaground = z(inear+2)
    1064         PRINT *, inear, z(inear), newz, z(inear+1), z(inear+2)
     1063        !PRINT *, inear, z(inear), newz, z(inear+1), z(inear+2)
    10651064        IF ( zaground >= newz) EXIT
    10661065      END DO
    10671066    ELSE
    1068       PRINT *, 1, z(1), newz, z(2), z(3), ' z(1) > newz'
     1067      !PRINT *, 1, z(1), newz, z(2), z(3), ' z(1) > newz'
    10691068      inear = d1 - 2
    10701069    END IF
     
    10831082       v2(1) = u(inear+1)
    10841083       v2(2) = v(inear+1)
    1085        zz(1) = z(inear) - topo
    1086        zz(2) = z(inear+1) - topo
     1084       zz(1) = z(inear)
     1085       zz(2) = z(inear+1)
    10871086    END IF
    10881087
    10891088    ! Computing for each component
    10901089    alpha = (LOG(ABS(v2))-LOG(ABS(v1)))/(LOG(zz(2))-LOG(zz(1)))
    1091     PRINT *,' Computing with v1:', v1, ' ms-1 v2:', v2, ' ms-1'
    1092     PRINT *,' z1:', zz(1), 'm z2:', zz(2), ' m'
    1093     PRINT *,' alhpa u:', alpha(1), ' alpha 2:', alpha(2)
     1090    !PRINT *,' Computing with v1:', v1, ' ms-1 v2:', v2, ' ms-1'
     1091    !PRINT *,' z1:', zz(1), 'm z2:', zz(2), ' m'
     1092    !PRINT *,' alhpa u:', alpha(1), ' alpha 2:', alpha(2)
    10941093   
    10951094    uvnewz = v1*(newz/zz(1))**alpha
     
    10981097    vnewz = uvnewz(1)*sa + uvnewz(2)*ca
    10991098
    1100     PRINT *,'  result vz:', uvnewz
     1099    !PRINT *,'  result vz:', uvnewz
    11011100
    11021101    !STOP
  • trunk/tools/variables_values.dat

    r1776 r1777  
    643643Y, y, y,  0., 100., y, -, Blues
    644644z, z, z,  0., 100., z, -, Greens
     645WRFz, z, height, 0., 80000., height|above|surface, m, rainbow
    645646Z, z, z,  0., 100., z, -, Greens
    646647zhgt, zhgt, height,  0., 50000., sea|level|altitude, m, rainbow
Note: See TracChangeset for help on using the changeset viewer.