Changeset 1783 in lmdz_wrf


Ignore:
Timestamp:
Feb 28, 2018, 3:26:43 AM (7 years ago)
Author:
lfita
Message:

Adding:

  • `WRFzwindMO': wind extrapolation at a given height computation using Monin-Obukhow
Location:
trunk/tools
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/diag_tools.py

    r1777 r1783  
    2929# compute_WRFuasvas: Fucntion to compute geographical rotated WRF 2-meter winds
    3030# derivate_centered: Function to compute the centered derivate of a given field
    31 # def Forcompute_cllmh: Function to compute cllmh: low/medium/hight cloud fraction following newmicro.F90 from LMDZ via Fortran subroutine
     31# Forcompute_cllmh: Function to compute cllmh: low/medium/hight cloud fraction following newmicro.F90 from LMDZ via Fortran subroutine
    3232# Forcompute_clt: Function to compute the total cloud fraction following 'newmicro.F90' from LMDZ via a Fortran module
     33# Forcompute_psl_ptarget: Function to compute the sea-level pressure following target_pressure value found in `p_interp.F'
     34# Forcompute_zmla_gen: Function to compute the boundary layer height following a generic method with Fortran
     35# Forcompute_zwind: Function to compute the wind at a given height following the power law method
     36# Forcompute_zwindMO: Function to compute the wind at a given height following the Monin-Obukhov theory
    3337# W_diagnostic: Class to compute WRF diagnostics variables
    34 # Forcompute_psl_ptarget: Function to compute the sea-level pressure following target_pressure value found in `p_interp.F'
    3538
    3639# Others just providing variable values
     
    910913    return zmla, zmladims, zmlavdims
    911914
    912 
    913915def Forcompute_zwind(ua, va, z, uas, vas, sina, cosa, zval, dimns, dimvns):
    914916    """ Function to compute the wind at a given height following the power law method
     
    952954        print '  ' + fname + ': rank', len(ua.shape), 'not ready !!'
    953955        print '  it only computes 4D [t,z,y,x] rank values'
     956        quit(-1)
     957
     958    return var1, var2, vardims, varvdims
     959
     960def Forcompute_zwindMO(ust, znt, rmol, uas, vas, sina, cosa, zval, dimns, dimvns):
     961    """ Function to compute the wind at a given height following the Monin-Obukhov theory
     962    Forcompute_zwind(ust, znt, rmol, uas, vas, sina, cosa, zval, dimns, dimvns)
     963      [ust]: u* in similarity theory (assuming [[t],y,x]) [ms-1]
     964      [znt]: thermal time-varying roughness length (assuming [[t],y,x]) [m]
     965      [rmol]: inverse of Obukhov length (assuming [[t],y,x]) [m-1]
     966      [uas]= x-component of unstaggered 10 m wind (assuming [[t],y,x]) [ms-1]
     967      [vas]= y-component of unstaggered 10 m wind (assuming [[t],y,x]) [ms-1]
     968      [sina]= local sine of map rotation [1.]
     969      [cosa]= local cosine of map rotation [1.]
     970      [zval]= desired height for winds [m]
     971      [dimns]= list of the name of the dimensions of [uas]
     972      [dimvns]= list of the name of the variables with the values of the
     973        dimensions of [uas]
     974    """
     975    fname = 'Forcompute_zwindMO'
     976
     977    vardims = dimns[:]
     978    varvdims = dimvns[:]
     979
     980    if len(uas.shape) == 3:
     981        var1= np.zeros((uas.shape[0],uas.shape[1],uas.shape[2]), dtype=np.float)
     982        var2= np.zeros((uas.shape[0],uas.shape[1],uas.shape[2]), dtype=np.float)
     983
     984        dx = uas.shape[2]
     985        dy = uas.shape[1]
     986        dt = uas.shape[0]
     987
     988        pvar1, pvar2 = fdin.module_fordiagnostics.compute_zwindmo3d(                 \
     989          ust=ust.transpose(), znt=znt[:].transpose(), rmol=rmol[:].transpose(),     \
     990          uas=uas.transpose(), vas=vas.transpose(), sina=sina.transpose(),           \
     991          cosa=cosa.transpose(), newz=zval, d1=dx, d2=dy, d3=dt)
     992        var1 = pvar1.transpose()
     993        var2 = pvar2.transpose()
     994    else:
     995        print errormsg
     996        print '  ' + fname + ': rank', len(uas.shape), 'not ready !!'
     997        print '  it only computes 3D [t,y,x] rank values'
    954998        quit(-1)
    955999
  • trunk/tools/diagnostics.inf

    r1777 r1783  
    3535va, WRFva, U@V@SINALPHA@COSALPHA
    3636uavaz, WRFzwind, U@V@WRFz@U10@V10@SINALPHA@COSALPHA@z=100.
     37uavaz, WRFzwindMO, UST@ZNT@RMOL@U10@V10@SINALPHA@COSALPHA@z=100.
    3738wa, OMEGAw, vitw@pres@temp
    3839wds, TSwds, u@v
  • trunk/tools/diagnostics.py

    r1777 r1783  
    8181  'WRFmrso', 'WRFp',                                                                 \
    8282  'WRFpsl_ptarget', 'WRFrvors', 'WRFslw', 'ws', 'wds', 'wss', 'WRFheight',           \
    83   'WRFheightrel', 'WRFua', 'WRFva', 'WRzwind']
     83  'WRFheightrel', 'WRFua', 'WRFva', 'WRFzwind', 'WRFzwindMO']
    8484
    8585methods = ['accum', 'deaccum']
     
    11781178        ncvar.insert_variable(ncobj, 'vaz', diagout2, diagoutd, diagoutvd, newnc)
    11791179
     1180# WRFzwindMO wind extrapolation at a given height computation using Monin-Obukhow
     1181#   theory from WRF UST, ZNT, RMOL, U10, V10, SINALPHA, COSALPHA, z=[zval]
     1182    elif diagn == 'WRFzwindMO':
     1183        var0 = ncobj.variables[depvars[0]][:]
     1184        var1 = ncobj.variables[depvars[1]][:]
     1185        var2 = ncobj.variables[depvars[2]][:]
     1186        var3 = ncobj.variables[depvars[3]][:]
     1187        var4 = ncobj.variables[depvars[4]][:]
     1188        var5 = ncobj.variables[depvars[5]][0,:,:]
     1189        var6 = ncobj.variables[depvars[6]][0,:,:]
     1190        var7 = np.float(depvars[7].split('=')[1])
     1191
     1192        diagout1, diagout2, diagoutd, diagoutvd = diag.Forcompute_zwindMO(var0, var1,\
     1193          var2, var3, var4, var5, var6, var7, dnames, dvnames)
     1194
     1195        # Removing the nonChecking variable-dimensions from the initial list
     1196        varsadd = []
     1197        for nonvd in NONchkvardims:
     1198            if gen.searchInlist(dvnames,nonvd): diagoutvd.remove(nonvd)
     1199            varsadd.append(nonvd)
     1200
     1201        ncvar.insert_variable(ncobj, 'uaz', diagout1, diagoutd, diagoutvd, newnc)
     1202        ncvar.insert_variable(ncobj, 'vaz', diagout2, diagoutd, diagoutvd, newnc)
     1203
    11801204    else:
    11811205        print errormsg
  • trunk/tools/module_ForDiagnostics.f90

    r1777 r1783  
    2929! compute_zmla_generic4D: Subroutine to compute pbl-height following a generic method
    3030! compute_zwind4D: Subroutine to compute extrapolate the wind at a given height following the 'power law' methodology
     31! compute_zwindMCO3D: Subroutine to compute extrapolate the wind at a given height following the 'power law' methodolog
    3132
    3233!!!
     
    680681  END SUBROUTINE compute_zwind4D
    681682
     683  SUBROUTINE compute_zwindMO3D(d1, d2, d3, ust, znt, rmol, uas, vas, sina, cosa, newz, uznew, vznew)
     684! Subroutine to compute extrapolate the wind at a given height following the 'power law' methodology
     685
     686    IMPLICIT NONE
     687
     688    INTEGER, INTENT(in)                                  :: d1, d2, d3
     689    REAL(r_k), DIMENSION(d1,d2,d3), INTENT(in)           :: ust, znt, rmol
     690    REAL(r_k), DIMENSION(d1,d2,d3), INTENT(in)           :: uas, vas
     691    REAL(r_k), DIMENSION(d1,d2), INTENT(in)              :: sina, cosa
     692    REAL(r_k), INTENT(in)                                :: newz
     693    REAL(r_k), DIMENSION(d1,d2,d3), INTENT(out)          :: uznew, vznew
     694 
     695! Local
     696    INTEGER                                              :: i, j, it
     697
     698!!!!!!! Variables
     699! ust: u* in similarity theory [ms-1]
     700! znt: thermal time-varying roughness length [m]
     701! rmol: Inverse of the Obukhov length [m-1]
     702! uas: x-component 10-m wind speed [ms-1]
     703! vas: y-component 10-m wind speed [ms-1]
     704! sina, cosa: local sine and cosine of map rotation [1.]
     705
     706    fname = 'compute_zwindMO3D'
     707
     708    DO i=1, d1
     709      DO j=1, d2
     710        DO it=1, d3
     711          CALL var_zwind_MOtheor(ust(i,j,it), znt(i,j,it), rmol(i,j,it), uas(i,j,it), vas(i,j,it),    &
     712            sina(i,j), cosa(i,j), newz, uznew(i,j,it), vznew(i,j,it))
     713        END DO
     714      END DO
     715    END DO
     716
     717    RETURN
     718
     719  END SUBROUTINE compute_zwindMO3D
     720
    682721END MODULE module_ForDiagnostics
  • trunk/tools/module_ForDiagnosticsVars.f90

    r1778 r1783  
    3030! var_zmla_generic: Subroutine to compute pbl-height following a generic method
    3131! var_zwind: Subroutine to extrapolate the wind at a given height following the 'power law' methodology
     32! var_zwind_MOtheor: Subroutine of wind extrapolation following Moin-Obukhov theory
    3233! VirtualTemp1D: Function for 1D calculation of virtual temperaure
    3334! VirtualTemperature: WRF's AFWA method to compute virtual temperature
     35! stabfunc_businger: Fucntion of the stability function after Businger et al. (1971)
    3436
    3537!!!!!!! Calculations
     
    11091111  END SUBROUTINE var_zwind
    11101112
     1113  SUBROUTINE var_zwind_MOtheor(ust, znt, rmol, u10, v10, sa, ca, newz, uznew, vznew)
     1114  ! Subroutine of wind extrapolation following Moin-Obukhov theory R. B. Stull, 1988,
     1115  !   Springer (p376-383)
     1116
     1117    IMPLICIT NONE
     1118
     1119    REAL, INTENT(in)                                     :: ust, znt, rmol, u10, v10, sa, ca
     1120    REAL, INTENT(in)                                     :: newz
     1121    REAL, INTENT(out)                                    :: uznew, vznew
     1122
     1123! Local
     1124    REAL                                                 :: OL
     1125    REAL                                                 :: stability
     1126    REAL                                                 :: wsz, alpha
     1127    REAL, DIMENSION(2)                                   :: uvnewz
     1128
     1129!!!!!!! Variables
     1130! ust: u* in similarity theory [ms-1]
     1131! z0: roughness length [m]
     1132!!! L. Fita, CIMA. Feb. 2018
     1133!! NOT SURE if it should be z0 instead?
     1134! znt: thermal time-varying roughness length [m]
     1135! rmol: inverse of Obukhov length [m-1]
     1136! u10: x-component 10-m wind speed [ms-1]
     1137! v10: y-component 10-m wind speed [ms-1]
     1138! sa, ca: local sine and cosine of map rotation [1.]
     1139!
     1140    fname = 'var_zwind_MOtheor'
     1141
     1142    ! Obukhov Length (using the Boussinesq approximation giving Tv from t2)
     1143    OL = 1/rmol
     1144
     1145    ! Wind speed at desired height
     1146    PRINT *,'ust:', ust, 'znt:', znt, 'OL:', OL
     1147
     1148    CALL stabfunc_businger(newz,OL,stability)
     1149    PRINT *,'  z/L:', newz/OL,' stabfunc:', stability, 'log:', LOG(newz/znt), 'log+stability:', LOG(newz/znt) + stability
     1150    PRINT *,'  ust/karman:', ust/karman
     1151
     1152    wsz = ust/karman*( LOG(newz/znt) + stability)
     1153    PRINT *,'  wsz:', wsz
     1154
     1155    ! Without taking into account Ekcman pumping, etc... redistributed by components unsing 10-m wind
     1156    !   as reference...
     1157    alpha = ATAN2(v10,u10)
     1158    uvnewz(1) = wsz*COS(alpha)
     1159    uvnewz(2) = wsz*SIN(alpha)
     1160    PRINT *,'  uvnewz:', uvnewz
     1161
     1162    ! Earth-rotation
     1163    uznew = uvnewz(1)*ca - uvnewz(2)*sa
     1164    vznew = uvnewz(1)*sa + uvnewz(2)*ca
     1165    PRINT *,'  uznew:', uznew, ' vznew:', vznew
     1166
     1167    RETURN
     1168
     1169  END SUBROUTINE var_zwind_MOtheor
     1170
     1171  ! L. Fita, CIMA. Feb. 2018
     1172  ! WRF seems to have problems with my functions, let'suse subroutine instead
     1173  !REAL FUNCTION stabfunc_businger(z,L)
     1174  SUBROUTINE stabfunc_businger(z,L,stabfunc_busingerv)
     1175  ! Fucntion of the stability function after Businger et al. (1971), JAS, 28(2), 181–189
     1176
     1177    IMPLICIT NONE
     1178
     1179    REAL, INTENT(in)                                     :: z,L
     1180    REAL, INTENT(out)                                    :: stabfunc_busingerv
     1181
     1182! Local
     1183    REAL                                                 :: zL, X
     1184
     1185!!!!!!! Variables
     1186! z: height [m]
     1187! L: Obukhov length [-]
     1188
     1189    fname = 'stabfunc_businger'
     1190
     1191    IF (L /= 0.) THEN
     1192      zL = z/L
     1193    ELSE
     1194      ! Neutral
     1195      zL = 0.
     1196    END IF
     1197
     1198    IF (zL > 0.) THEN
     1199    ! Stable case
     1200      stabfunc_busingerv = 4.7*z/L
     1201    ELSE IF (zL < 0.) THEN
     1202    ! unstable
     1203      X = (1. - 15.*z/L)**(0.25)
     1204      !stabfunc_busingerv = -2.*LOG((1.+X)/2.)-LOG((1.+X**2)/2.)+2.*ATAN(X)-piconst/2.
     1205      stabfunc_busingerv = LOG( ((1.+X**2)/2.)*((1.+X)/2.)**2)-2.*ATAN(X)+piconst/2.
     1206    ELSE
     1207      stabfunc_busingerv = 0.
     1208    END IF
     1209
     1210    RETURN
     1211
     1212!  END FUNCTION stabfunc_businger
     1213  END SUBROUTINE stabfunc_businger
     1214
    11111215END MODULE module_ForDiagnosticsVars
  • trunk/tools/module_definitions.f90

    r1773 r1783  
    5757! epislon r_d/r_v for Virtual temperature
    5858  REAL(r_k), PARAMETER                                   :: epsilonv = 0.622
     59! pi
     60  REAL(r_k), PARAMETER                                   :: piconst = 3.1415926535897932384626433
     61! Karman constant
     62  REAL(r_k), PARAMETER                                   :: karman = 0.4
     63
    5964
    6065END MODULE module_definitions
Note: See TracChangeset for help on using the changeset viewer.