Changeset 2765 in lmdz_wrf for trunk/tools
- Timestamp:
- Nov 16, 2019, 10:51:32 PM (5 years ago)
- Location:
- trunk/tools
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/diag_tools.py
r2682 r2765 1037 1037 1038 1038 return mslpv, mslpdims, mslpvdims 1039 1040 def Forcompute_gradient2Dh(var, x, y, dimns, dimvns): 1041 """ Function to compute 1st order horizontal 2D gradient of any given variable 1042 Forcompute_gradient(var, x, y, dimns, dimvns) 1043 [var]= variable (assuming [[t],z,y,x]) [??] 1044 [x]= distance along x-axis (assuming [y,x]) [?] 1045 [y]= distance along y-axis (assuming [y,x]) [?] 1046 [dimns]= list of the name of the dimensions of [pa] 1047 [dimvns]= list of the name of the variables with the values of the 1048 dimensions 1049 """ 1050 fname = 'Forcompute_gradient' 1051 1052 vardims = dimns[:] 1053 varvdims = dimvns[:] 1054 1055 if len(var.shape) == 2: 1056 dx = var.shape[1] 1057 dy = var.shape[0] 1058 gradt=fdin.module_fordiagnostics.compute_gradient2dh1rk( \ 1059 var=var[:].transpose(), x=x[:].transpose(), y=y[:].transpose(), d1=dx, \ 1060 d2=dy) 1061 elif len(var.shape) == 3: 1062 dx = var.shape[2] 1063 dy = var.shape[1] 1064 dt = var.shape[0] 1065 gradt=fdin.module_fordiagnostics.compute_gradient2dh3rk( \ 1066 var=var[:].transpose(), x=x[:].transpose(), y=y[:].transpose(), d1=dx, \ 1067 d2=dy, d3=dt) 1068 elif len(var.shape) == 4: 1069 dx = var.shape[3] 1070 dy = var.shape[2] 1071 dz = var.shape[1] 1072 dt = var.shape[0] 1073 gradt=fdin.module_fordiagnostics.compute_gradient2dh4rk( \ 1074 var=var[:].transpose(), x=x[:].transpose(), y=y[:].transpose(), d1=dx, \ 1075 d2=dy, d3=dt) 1076 else: 1077 print errormsg 1078 print ' ' + fname + ': rank', len(var.shape), 'not ready !!' 1079 print ' it only computes 2D [y,x], 3D [t,y,x], or 4D [t,y,x] rank values' 1080 quit(-1) 1081 grad = gradt.transpose() 1082 1083 return grad, vardims, varvdims 1039 1084 1040 1085 def Forcompute_psl_ecmwf(ps, hgt, ta1, pa2, unpa1, dimns, dimvns): -
trunk/tools/diagnostics.py
r2681 r2765 91 91 ####### 92 92 availdiags = ['ACRAINTOT', 'accum', 'clt', 'cllmh', 'convini', 'deaccum', 'fog_K84', \ 93 'fog_RUC', 'front_R04', 'frontogenesis', ' rhs_tas_tds', 'LMDZrh', 'mslp', 'OMEGAw',\94 ' RAINTOT', 'range_faces',\93 'fog_RUC', 'front_R04', 'frontogenesis', 'gradient2Dh', 'rhs_tas_tds', 'LMDZrh', \ 94 'mslp', 'OMEGAw', 'RAINTOT', 'range_faces', \ 95 95 'rvors', 'td', 'timemax', 'timeoverthres', 'turbulence', 'tws', 'uavaFROMwswd', \ 96 96 'WRFbnds', 'WRFcape_afwa', 'WRFclivi', 'WRFclwvi', 'WRF_denszint', 'WRFgeop', \ … … 1181 1181 newnc.sync() 1182 1182 1183 # gradient2Dh: 1st order Horizontal 2D-gradient of any variable [variable], [distx], 1184 # [disty] 1185 elif diagn == 'gradient2Dh': 1186 1187 var0 = ncobj.variables[depvars[0]] 1188 var1 = ncobj.variables[depvars[1]] 1189 var2 = ncobj.variables[depvars[2]] 1190 1191 dnamesvar = var0.dimensions 1192 dvnamesvar = ncvar.var_dim_dimv(dnamesvar,dnames,dvnames) 1193 1194 diagout, diagoutd, diagoutvd = diag.Forcompute_gradient2Dh(var0, var1, var2, \ 1195 dnamesvar, dvnamesvar) 1196 # Removing the nonChecking variable-dimensions from the initial list 1197 varsadd = [] 1198 diagoutvd = list(dvnames) 1199 for nonvd in NONchkvardims: 1200 if gen.searchInlist(dvnames,nonvd): diagoutvd.remove(nonvd) 1201 varsadd.append(nonvd) 1202 1203 CFvarn = ncvar.variables_values(depvars[0])[0] 1204 ncvar.insert_variable(ncobj, depvars[0], diagout, diagoutd, diagoutvd, \ 1205 newnc, gen.fillValueF) 1206 newnc.sync() 1207 ovar = newnc.variables[depvars[0]] 1208 varu = ovar.units 1209 newnc.renameVariable(depvars[0], depvars[0]+'2Dhgrad') 1210 ovar.setncattr('units', varu+'ds-1') 1211 1183 1212 # LMDZrh (pres, t, r) 1184 1213 elif diagn == 'LMDZrh': -
trunk/tools/module_ForDiagnostics.f90
r2675 r2765 34 34 ! compute_front_R04d3: Subroutine to compute presence of a front following Rodrigues et al.(2004) 35 35 ! compute_frontogenesis: Subroutine to compute the frontogenesis 36 ! compute_gradient2Dh4RK: calculation of 1st order horizontal 2D gradient on 4D RK variable 37 ! compute_gradient2Dh3RK: calculation of 1st order horizontal 2D gradient on 3D RK variable 38 ! compute_gradient2Dh2RK: calculation of 1st order horizontal 2D gradient on 2D RK variable 36 39 ! compute_massvertint1D: Subroutine to vertically integrate a 1D variable in eta vertical coordinates 37 40 ! compute_psl_ecmwf: Compute sea level pressure using ECMWF method following Mats Hamrud and Philippe Courtier [Pa] … … 1635 1638 END SUBROUTINE compute_frontogenesis 1636 1639 1640 SUBROUTINE compute_gradient2Dh4RK(v,x,y,d1,d2,d3,d4,grad) 1641 ! calculation of 1st order horizontal 2D gradient on 4D RK variable 1642 1643 IMPLICIT NONE 1644 1645 INTEGER, INTENT(in) :: d1, d2, d3, d4 1646 REAL(r_k), DIMENSION(d1,d2,d3,d4), INTENT(in) :: v 1647 REAL(r_k), DIMENSION(d1,d2), INTENT(in) :: x, y 1648 REAL(r_k), DIMENSION(d1,d2,d3,d4), INTENT(out) :: grad 1649 1650 ! Local 1651 INTEGER :: k,l 1652 1653 !!!!!!! Variables 1654 ! v: variable to compute its gradient 1655 ! x: distances along x-axis 1656 ! y: distances along y-axis 1657 1658 fname = 'compute_gradiend2Dh4RK' 1659 1660 DO k=1, d3 1661 DO l=1, d4 1662 CALL gradient2D_1o(d1, d2, v(:,:,k,l), x, y, grad(:,:,k,l)) 1663 END DO 1664 END DO 1665 1666 END SUBROUTINE compute_gradient2Dh4RK 1667 1668 SUBROUTINE compute_gradient2Dh3RK(v,x,y,d1,d2,d3,grad) 1669 ! calculation of 1st order horizontal 2D gradient on 3D RK variable 1670 1671 IMPLICIT NONE 1672 1673 INTEGER, INTENT(in) :: d1, d2, d3 1674 REAL(r_k), DIMENSION(d1,d2,d3), INTENT(in) :: v 1675 REAL(r_k), DIMENSION(d1,d2), INTENT(in) :: x, y 1676 REAL(r_k), DIMENSION(d1,d2,d3), INTENT(out) :: grad 1677 1678 ! Local 1679 INTEGER :: k 1680 1681 !!!!!!! Variables 1682 ! v: variable to compute its gradient 1683 ! x: distances along x-axis 1684 ! y: distances along y-axis 1685 1686 fname = 'compute_gradiend2Dh3RK' 1687 1688 DO k=1, d3 1689 CALL gradient2D_1o(d1, d2, v(:,:,k), x, y, grad(:,:,k)) 1690 END DO 1691 1692 END SUBROUTINE compute_gradient2Dh3RK 1693 1694 SUBROUTINE compute_gradient2Dh2RK(v,x,y,d1,d2,grad) 1695 ! calculation of 1st order horizontal 2D gradient on 2D RK variable 1696 1697 IMPLICIT NONE 1698 1699 INTEGER, INTENT(in) :: d1, d2 1700 REAL(r_k), DIMENSION(d1,d2), INTENT(in) :: v 1701 REAL(r_k), DIMENSION(d1,d2), INTENT(in) :: x, y 1702 REAL(r_k), DIMENSION(d1,d2), INTENT(out) :: grad 1703 1704 ! Local 1705 INTEGER :: k 1706 1707 !!!!!!! Variables 1708 ! v: variable to compute its gradient 1709 ! x: distances along x-axis 1710 ! y: distances along y-axis 1711 1712 fname = 'compute_gradiend2Dh2RK' 1713 1714 CALL gradient2D_1o(d1, d2, v, x, y, grad) 1715 1716 END SUBROUTINE compute_gradient2Dh2RK 1717 1637 1718 END MODULE module_ForDiagnostics
Note: See TracChangeset
for help on using the changeset viewer.