Changeset 2655 in lmdz_wrf


Ignore:
Timestamp:
Jul 2, 2019, 8:37:56 PM (5 years ago)
Author:
lfita
Message:

Adding:

  • `front_R04': generalization of front calculation from Rodrigues, 2004
Location:
trunk/tools
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/diag_tools.py

    r2643 r2655  
    15331533      varvdims, ranges, rangeshgtmax, ptrangeshgtmax
    15341534
    1535 def Forcompute_front_R04(tas, uas, vas, dxs, dys, dimns, dimvns):
     1535def Forcompute_front_R04(tas, uas, vas, dxs, dys, dtas, dwss, dimns, dimvns):
    15361536    """ Function to compute front following Rodrigues et al.(2004), Rev. Bras.
    15371537          Geofis. 22, 135-151
     
    15421542      [dxs]= grid spacing between grid points along x-axis (assuming [y,x]) [m]
    15431543      [dys]= grid spacing between grid points along y-axis (assuming [y,x]) [m]
     1544      [dtas]= sensitivity to the thermal temporal increment [K]
     1545      [ddwss]= sensitivity to the wind gradient [ms-1m-1]
    15441546      [dimns]= list of the name of the dimensions of [pa]
    15451547      [dimvns]= list of the name of the variables with the values of the
     
    15481550    fname = 'Forcompute_front_R04'
    15491551
    1550     psldims = dimns[:]
    1551     pslvdims = dimvns[:]
    1552 
    1553     if len(pa.shape) == 3:
     1552    frontdims = dimns[:]
     1553    frontvdims = dimvns[:]
     1554
     1555    if len(tas.shape) == 3:
    15541556        front = np.zeros((tas.shape[0],tas.shape[1],tas.shape[2]), dtype=np.float)
    15551557
     
    15581560        dt = tas.shape[0]
    15591561
    1560         pfront=fdin.module_fordiagnostics.compute_front_R04d3(tas=tas[:].transpose(),\
    1561           uas=uas[:].transpose(), vas=vas[:].transpose(), dxs=dxs[:].transpose(),    \
    1562           dys=dys[:].transpose(), d1=dx, d2=dy, d3=dt)
     1562        pfront, pdt1tas, pdd1wss, pdt2tas =                                          \
     1563          fdin.module_fordiagnostics.compute_front_r04d3(tas=tas[:].transpose(),     \
     1564          uas=uas[:].transpose(), vas=vas[:].transpose(), ddtas=dtas, ddwss=dwss,    \
     1565          dsx=dxs[:].transpose(), dsy=dys[:].transpose(), d1=dx, d2=dy, d3=dt)
    15631566        front = pfront.transpose()
     1567        dt1tas = pdt1tas.transpose()
     1568        dd1wss = pdd1wss.transpose()
     1569        dt2tas = pdt2tas.transpose()
     1570
    15641571    else:
    15651572        print errormsg
    1566         print '  ' + fname + ': rank', len(pa.shape), 'not ready !!'
     1573        print '  ' + fname + ': rank', len(tas.shape), 'not ready !!'
    15671574        print '  it only computes 3D [t,y,x] rank values'
    15681575        quit(-1)
    15691576
    1570     return front
     1577    return front, dt1tas, dd1wss, dt2tas, frontdims, frontvdims
    15711578
    15721579####### ###### ##### #### ### ## # END Fortran diagnostics
  • trunk/tools/diagnostics.inf

    r2390 r2655  
    1717fog, fog_RUC, QVAPOR@WRFt@WRFp
    1818fog, fog_RUC, Q2@T2@PSFC
     19front, front_R04, T2@U10@V10@WRFdx@WRFdy@params:1.:0.0001
    1920hur, LMDZrh, pres@t@r
    2021hur, WRFrh, WRFrh@T@P@PB
  • trunk/tools/diagnostics.py

    r2643 r2655  
    103103# Variables not to check
    104104NONcheckingvars = ['accum', 'cllmh', 'deaccum', 'face', 'LONLATdxdy',                \
    105   'reglonlatbnds', 'TSrhs', 'TStd', 'TSwds', 'TSwss',                                \
     105  'params', 'reglonlatbnds', 'TSrhs', 'TStd', 'TSwds', 'TSwss',                      \
    106106  'WRFbils',  'WRFbnds',                                                             \
    107107  'WRFclivi', 'WRFclwvi', 'WRFdens', 'WRFdx', 'WRFdxdy', 'WRFdxdywps', 'WRFdy',      \
     
    167167WRFtime_compute = False
    168168WRFz_compute = False
     169WRFdx_compute = False
     170WRFdx_compute = False
    169171WRFdxdy_compute = False
    170172WRFdxdywps_compute = False
     
    194196    if dnv == 'WRFtime': WRFtime_compute = True
    195197    if dnv == 'WRFz':WRFz_compute = True
     198    if dnv == 'WRFdx':WRFdx_compute = True
     199    if dnv == 'WRFdy':WRFdy_compute = True
    196200    if dnv == 'WRFdxdy':WRFdxdy_compute = True
    197201    if dnv == 'WRFdxdywps':WRFdxdywps_compute = True
     
    225229        if gen.searchInlist(depvars, 'WRFtime'): WRFtime_compute = True
    226230        if gen.searchInlist(depvars, 'WRFz'): WRFz_compute = True
     231        if gen.searchInlist(depvars, 'WRFdx'): WRFdx_compute = True
     232        if gen.searchInlist(depvars, 'WRFdy'): WRFdy_compute = True
    227233        if gen.searchInlist(depvars, 'WRFdxdy'): WRFdxdy_compute = True
    228234        if gen.searchInlist(depvars, 'WRFdxdywps'): WRFdxdywps_compute = True
     
    410416      'long_name': Vvals[4].replace('|',' '), 'units': Vvals[5]}
    411417
    412 if WRFdxdy_compute:
     418if WRFdxdy_compute or WRFdx_compute or WRFdy_copute:
    413419    print '  ' + main + ': Retrieving dxdy: real distance between grid points ' +    \
    414420      'from WRF as dx=(XLONG(i+1)-XLONG(i))*DX/MAPFAC_M, dy=(XLAT(j+1)-XLAT(i))*DY/'+\
     
    775781
    776782# front_R04: Computation of the presence of a front as defined by Rodrigues et al.
    777 #     (2004) (vas, tas, dxs, dys)
     783#     (2004) (tas, uas, vas, dxs, dys, 'params',[dtas],[dwss])
    778784#   Rodrigues et al. 2004: Climatologia de frentes frias no litoral de Santa Catarina,
    779785#     Rev. Bras. Geof. v.22 n.2 Sao Paulo maio/ago. DOI: 10.1590/S0102-261X2004000200004 
     
    783789        var1 = ncobj.variables[depvars[1]]
    784790        var2 = ncobj.variables[depvars[2]]
    785         var3 = ncobj.variables[depvars[3]]
     791        if depvars[3] == 'WRFdx': var3 = WRFdx
     792        else: var3 = ncobj.variables[depvars[3]]
     793        if depvars[4] == 'WRFdy': var4 = WRFdy
     794        else: var4 = ncobj.variables[depvars[4]]
     795        par1 = np.float(depvars[5].split(':')[1])
     796        par2 = np.float(depvars[5].split(':')[2])
    786797
    787798        dnamesvar = list(var0.dimensions)
    788799        dvnamesvar = ncvar.var_dim_dimv(dnamesvar,dnames,dvnames)
    789800
    790         diag1, diagoutd, diagoutvd = diag.Forcompute_front_R04(var0, var1,           \
    791           var2, var3, dnamesvar, dvnamesvar)
    792 
    793         # Removing the nonChecking variable-dimensions from the initial list
    794         varsadd = []
    795         diagoutvd = list(dvnames)
    796         for nonvd in NONchkvardims:
    797             if gen.searchInlist(dvnames,nonvd): diagoutvd.remove(nonvd)
    798             varsadd.append(nonvd)
    799         ncvar.insert_variable(ncobj, 'front', diag1, diagoutd, diagoutvd, newnc)
     801        diag1, diag2, diag3, diag4, diagoutd, diagoutvd = diag.Forcompute_front_R04( \
     802          var0, var1, var2, var3, var4, par1, par2, dnamesvar, dvnamesvar)
     803
     804        # Removing the nonChecking variable-dimensions from the initial list
     805        varsadd = []
     806        diagoutvd = list(dvnames)
     807        for nonvd in NONchkvardims:
     808            if gen.searchInlist(dvnames,nonvd): diagoutvd.remove(nonvd)
     809            varsadd.append(nonvd)
     810        ncvar.insert_variable(ncobj, 'front', diag1, diagoutd, diagoutvd, newnc,     \
     811          fill=gen.fillValueF)
     812        ovar = newnc.variables['front']
     813        ovar.setncattr('description', 'front defintion after a generalization of ' + \
     814          'Rodrigues et al. 2004, Rev. Bras. Geof. v.22 n.2, ' +                     \
     815          'doi: 10.1590/S0102-261X2004000200004')
     816        ovar.setncattr('details1', 'N-S wind gradient replaced by gradient of uas, '+\
     817          'vas')
     818        ovar.setncattr('dtas', par1)
     819        ovar.setncattr('dwss', par2)
     820        newnc.sync()
     821        ncvar.insert_variable(ncobj, 'dt1', diag2, diagoutd, diagoutvd, newnc,       \
     822          fill=gen.fillValueF)
     823        ovar = newnc.variables['dt1']
     824        vu = var0.getncattr('units')
     825        ncvar.set_attribute(ovar, 'units', vu)
     826        attrv = ovar.getncattr('standard_name')
     827        ncvar.set_attribute(ovar, 'standard_name', attrv + depvars[0])
     828        attrv = ovar.getncattr('long_name')
     829        ncvar.set_attribute(ovar, 'long_name', attrv + ' of ' + depvars[0])
     830        ncvar.insert_variable(ncobj, 'gradh', diag3, diagoutd, diagoutvd, newnc,     \
     831          fill=gen.fillValueF)
     832        ovar = newnc.variables['gradh']
     833        vu = var1.getncattr('units')
     834        ncvar.set_attribute(ovar, 'units', vu+'m-1')
     835        attrv = ovar.getncattr('standard_name')
     836        ncvar.set_attribute(ovar, 'standard_name', attrv + 'wss')
     837        attrv = ovar.getncattr('long_name')
     838        ncvar.set_attribute(ovar, 'long_name', attrv + ' of wss')
     839        ncvar.insert_variable(ncobj, 'dt2', diag4, diagoutd, diagoutvd, newnc,       \
     840          fill=gen.fillValueF)
     841        vu = var0.getncattr('units')
     842        ncvar.set_attribute(ovar, 'units', vu)
     843        attrv = ovar.getncattr('standard_name')
     844        ncvar.set_attribute(ovar, 'standard_name', attrv + depvars[0])
     845        attrv = ovar.getncattr('long_name')
     846        ncvar.set_attribute(ovar, 'long_name', attrv + ' of ' + depvars[0])
    800847
    801848# LMDZrh (pres, t, r)
  • trunk/tools/module_ForDiagnostics.f90

    r2642 r2655  
    15501550  END SUBROUTINE compute_tws_RK4
    15511551
    1552   SUBROUTINE compute_front_R04d3(d1, d2, d3, tas, uas, vas, dsx, dsy, front)
     1552  SUBROUTINE compute_front_R04d3(d1, d2, d3, tas, uas, vas, ddtas, ddwss, dsx, dsy, front, dt1tas,    &
     1553    dd1wss, d2tas)
    15531554! Subroutine to compute presence of a front following Rodrigues et al.(2004), Rev. Bras.  Geofis. 22,
    15541555!    135-151
     
    15571558
    15581559    INTEGER, INTENT(in)                                  :: d1, d2, d3
    1559     REAL(r_k), DIMENSION(d1,d2,d3), INTENT(in)           :: tas, uas, vas, dsx, dsy
     1560    REAL(r_k), DIMENSION(d1,d2,d3), INTENT(in)           :: tas, uas, vas
     1561    REAL(r_k), DIMENSION(d1,d2), INTENT(in)              :: dsx, dsy
     1562    REAL(r_k), INTENT(in)                                :: ddtas, ddwss
    15601563    INTEGER, DIMENSION(d1,d2,d3), INTENT(out)            :: front
     1564    REAL(r_k), DIMENSION(d1,d2,d3), INTENT(out)          :: dt1tas, dd1wss, d2tas
    15611565 
    15621566! Local
     
    15681572! dxs: grid spacing betweeen grid points along x-axis [m]
    15691573! dys: grid spacing betweeen grid points along y-axis [m]
     1574! ddtas: sensitivity to the thermal temporal increment [K]
     1575! ddwss: sensitivity to the wind gradient [ms-1m-1]
     1576! front: presence of a front in the grid point [-1: cold front, 0: no, 1: warm front]
     1577! dt1tas: 1-time-step temporal gradient of tas
     1578! dd1wss: first order divergence of winds
     1579! dt2tas: 2-time-step temporal gradient of tas
    15701580
    15711581    fname = 'compute_front_R04d3'
    15721582
    1573     CALL var_front_R04(d1, d2, d3, tas, uas, vas, dsx, dsy, front)
     1583    CALL var_front_R04(d1, d2, d3, tas, uas, vas, ddtas, ddwss, dsx,dsy, front, dt1tas, dd1wss, d2tas)
    15741584
    15751585    RETURN
  • trunk/tools/module_ForDiagnosticsVars.f90

    r2642 r2655  
    19771977  END SUBROUTINE Svar_tws_S11
    19781978
    1979   SUBROUTINE var_front_R04(dx, dy, dt, tas, uas, vas, ddx, ddy, front)
     1979  SUBROUTINE var_front_R04(dx, dy, dt, tas, uas, vas, dtas, dwss, ddx, ddy, front, dt1tas, dd1wss,    &
     1980    d2tas)
    19801981! Subroutine to compute presence of a front following
    19811982!   Rodrigues et al.(2004), Rev. Bras.  Geofis. 22, 135-151, doi: 10.1590/S0102-261X2004000200004
     
    19861987    REAL(r_k), DIMENSION(dx,dy), INTENT(in)              :: ddx, ddy
    19871988    REAL(r_k), DIMENSION(dx,dy,dt), INTENT(in)           :: tas, uas, vas
     1989    REAL(r_k), INTENT(in)                                :: dtas, dwss
    19881990    INTEGER, DIMENSION(dx,dy,dt), INTENT(out)            :: front
     1991    REAL(r_k), DIMENSION(dx,dy,dt), INTENT(out)          :: dt1tas, dd1wss, d2tas
    19891992
    19901993! Local
    19911994    INTEGER                                              :: i, j, l
    1992     REAL, DIMENSION(dx,dy,dt)                            :: dt1uas, dt1vas, dt1tas, dc1wss, d2tas
     1995!    REAL, DIMENSION(dx,dy,dt)                            :: dt1uas, dt1vas, dt1tas, dc1wss, d2tas
    19931996
    19941997!!!!!!! Variables
     
    19972000! uas: 10m eastward wind speed [ms-1]
    19982001! vas: 10m northward wind speed [ms-1]
    1999 ! front: presence of a front in the grid point [0: no, 1: yes]
     2002! dtas: sensitivity to thermal temporal difference to determine presence of a front
     2003! dwss: sensitivity to wind gradient to determine presence of a front
     2004! front: presence of a front in the grid point [-1: cold front, 0: no, 1: warm front]
     2005! dt1tas: 1-time-step temporal gradient of tas
     2006! dd1wss: first order divergence of winds
     2007! dt2tas: 2-time-step temporal gradient of tas
    20002008
    20012009    fname = 'var_front_R04'
    20022010
    2003     dt1uas = zeroRK
    2004     dt1vas = zeroRK
    2005     dt1tas = zeroRK
    2006     dc1wss = zeroRK
    2007     d2tas = zeroRK
     2011    dt1tas = fillval64
     2012    dd1wss = fillval64
     2013    d2tas = fillval64
    20082014
    20092015    ! 1-time-step derivatives
    20102016    DO l=1,dt-1
    2011       dt1tas(:,:,l) = ABS(tas(:,:,l+1) - tas(:,:,l))
    2012       dt1vas(:,:,l) = ABS(vas(:,:,l+1) - vas(:,:,l))
     2017      dt1tas(:,:,l) = tas(:,:,l+1) - tas(:,:,l)
    20132018    END DO
    20142019
    2015     ! First order curl
     2020    ! First order gradient
    20162021    DO l=1,dt-1
    2017       CALL curl2D_1o(dx,dy,ddx,ddy,uas(:,:,l),vas(:,:,l),dc1wss(:,:,l))
     2022      CALL divergence2D_1o(dx,dy,ddx,ddy,uas(:,:,l),vas(:,:,l),dd1wss(:,:,l))
    20182023    END DO
    20192024
    2020     ! 2-time-step centered derivatives
     2025    ! 2-time-step centered gradient
    20212026    DO l=2,dt-1
    2022       d2tas(:,:,l) = ABS(tas(:,:,l+1) - tas(:,:,l-1))
     2027      d2tas(:,:,l) = tas(:,:,l+1) - tas(:,:,l-1)
    20232028    END DO
    20242029
     
    20272032      DO i=1,dx
    20282033        DO j=1,dy
    2029           IF ( (dc1wss(i,j,l) /= zeroRK) .AND. (d2tas(i,j,l) > 0.5) ) front(i,j,l) = 1
     2034          IF ( (ABS(dd1wss(i,j,l)) >= dwss) .AND. (ABS(d2tas(i,j,l)) >= dtas) ) THEN
     2035            IF (d2tas(i,j,l) > 0.) THEN
     2036              front(i,j,l) = oneRK
     2037            ELSE
     2038              front(i,j,l) = -oneRK
     2039            END IF
     2040          END IF
    20302041        END DO
    20312042      END DO
  • trunk/tools/variables_values.dat

    r2387 r2655  
    8383fbase, clmf, cloud_base_mass_flux, -0.3, 0.3, cloud|base|mass|flux, kgm-2s-1, seismic, $clmf$, clmf
    8484LFBASE, clmf, cloud_base_mass_flux, -0.3, 0.3, cloud|base|mass|flux, kgm-2s-1, seismic, $clmf$, clmf
     85front, front, front, -1., 1., presence|of|front|(-1:|cold|front;|1:|warm|front), 1, seismic, $front$, front
    8586clp, clp, cloud_base_pressure, -0.3, 0.3, cloud|base|pressure, Pa, Reds, $clp$, clp
    8687pbase, clp, cloud_base_pressure, -0.3, 0.3, cloud|base|pressure, Pa, Reds, $clp$, clp
     
    125126ds, ds, horizontal_grid_distance, 0., 200., total|distance|between|grid|points, m, Reds, $ds$, ds
    126127WRFds, ds, horizontal_grid_distance, 0., 200., total|distance|between|grid|points, m, Reds, $ds$, ds
     128dt1, dt1, tendency, -3.e-3, 3.e-3, 1 time-step tendency, 1, seismic, $\Delta_{t}{\mathcal{X}}$, dt1
     129dt2, dt2, tendency, -3.e-3, 3.e-3, 2 time-steps tendency, 1, seismic, $\Delta2_{t}{\mathcal{X}}$, dt2
    127130dta, dta, tendency_air_temperature, -3.e-3, 3.e-3, tendency|of|air|temperature, K/s, seismic, $\partial_{t}{ta}$, dtta
    128131tnt, dta, tendency_air_temperature, -3.e-3, 3.e-3, tendency|of|air|temperature, K/s, seismic, $\partial_{t}{ta}$, dtta
     
    192195EVSPSBLPOT, evspsblpot, potential_water_evapotranspiration_flux, 0., 1.5e-4, potential|evapotranspiration|flux, kgm-2s-1, Blues, $evspsblpot$, evspsblpot
    193196fog, fog, fog, 0, 1, presence|of|fog|(0:no|1:yes), 1, Purples, $fog$, fog
     197gradh, gradh, gradient_horizontal, -3.e-3, 3.e-3, horizontal gradient, m-1, seismic, $\nabla\cdot{\mathcal{X}}$, /\.
    194198g, g, grauepl_mixing_ratio, 0., 0.0003, graupel|mixing|ratio, kgkg-1, Purples, $qg$, qg
    195199QGRAUP, g, grauepl_mixing_ratio, 0., 0.0003, graupel|mixing|ratio, kgkg-1, Purples, $qg$, qg
Note: See TracChangeset for help on using the changeset viewer.