Changeset 2212 in lmdz_wrf
- Timestamp:
- Nov 2, 2018, 7:01:51 PM (6 years ago)
- Location:
- trunk/tools
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/diag_tools.py
r2209 r2212 1370 1370 return var1, var2, vardims, varvdims 1371 1371 1372 def Forcompute_range_faces(lon, lat, hgt, face, dimns, dimvns):1372 def Forcompute_range_faces(lon, lat, hgt, face, Nfilt, dimns, dimvns): 1373 1373 """ Function to compute faces [uphill, valley, downhill] of sections of a mountain 1374 1374 rage, along a given face … … 1377 1377 [lat]= latitude values (assuming [y,x]) [degrees north] 1378 1378 [hgt]= height values (assuming [y,x]) [m] 1379 face= which face (axis along which produce slices) to use to compute the faces: WE, SN 1380 Nfilt= number of grid points to use to filter the topographic values 1379 1381 [dimns]= list of the name of the dimensions of [smois] 1380 1382 [dimvns]= list of the name of the variables with the values of the … … 1391 1393 dy = hgt.shape[0] 1392 1394 1393 facest=fdin.module_fordiagnostics.compute_range_faces(lon=lon[:].transpose(),\ 1394 lat=lat[:].transpose(), hgt=hgt[:].transpose(), face=face, d1=dx, d2=dy) 1395 faces = facest.transpose() 1395 dhgtt, peakst, valleyst, ofacest, ffacest = \ 1396 fdin.module_fordiagnostics.compute_range_faces(lon=lon[:].transpose(), \ 1397 lat=lat[:].transpose(), hgt=hgt[:].transpose(), face=face, nfilt=Nfilt, \ 1398 d1=dx, d2=dy) 1399 dhgt = dhgtt.transpose() 1400 peaks = peakst.transpose() 1401 valleys = valleyst.transpose() 1402 origfaces = ofacest.transpose() 1403 filtfaces = ffacest.transpose() 1396 1404 else: 1397 1405 print errormsg … … 1400 1408 quit(-1) 1401 1409 1402 return faces, vardims, varvdims1410 return dhgt, peaks, valleys, origfaces, filtfaces, vardims, varvdims 1403 1411 1404 1412 ####### ###### ##### #### ### ## # END Fortran diagnostics -
trunk/tools/diagnostics.py
r2209 r2212 101 101 102 102 # Variables not to check 103 NONcheckingvars = ['accum', 'cllmh', 'deaccum', 'face :WE', 'face:SN', 'TSrhs',\103 NONcheckingvars = ['accum', 'cllmh', 'deaccum', 'face', 'TSrhs', \ 104 104 'TStd', 'TSwds', 'TSwss', \ 105 105 'WRFbils', \ … … 415 415 if depvars[0] == 'accum': diagn='accum' 416 416 for depv in depvars: 417 # Checking without extra arguments of a depending variable (':', separated) 418 if depv.find(':') != -1: depv=depv.split(':')[0] 417 419 if not ncobj.variables.has_key(depv) and not \ 418 420 gen.searchInlist(NONcheckingvars, depv) and \ … … 679 681 ncvar.insert_variable(ncobj, 'hurs', diagout, diagoutd, diagoutvd, newnc) 680 682 681 # range_faces: LON, LAT, HGT, 'face:['WE'/'SN'] '683 # range_faces: LON, LAT, HGT, 'face:['WE'/'SN']:[Nptfilt]' 682 684 elif diagn == 'range_faces': 683 685 … … 685 687 var1 = ncobj.variables[depvars[1]][:] 686 688 var2 = ncobj.variables[depvars[2]][:] 687 var3 = depvars[3].split(':')[1] 688 689 face = depvars[3].split(':')[1] 690 Nptfilt = depvars[3].split(':')[2] 691 692 dnamesvar = list(ncobj.variables[depvars[0]].dimensions) 693 dvnamesvar = ncvar.var_dim_dimv(dnamesvar,dnames,dvnames) 689 694 lon, lat = gen.lonlat2D(var0, var1) 690 695 if len(var2.shape) == 3: … … 692 697 print ' ' + diagn + ": shapping to 2D variable '" + depvars[2] + "' !!" 693 698 hgt = var2[0,:,:] 699 dnamesvar.pop(0) 700 dvnamesvar.pop(0) 694 701 else: 695 702 hgt = var2[:] 696 703 697 dnamesvar = list(ncobj.variables[depvars[0]].dimensions) 698 dvnamesvar = ncvar.var_dim_dimv(dnamesvar,dnames,dvnames) 699 700 diagout, diagoutd, diagoutvd = diag.Forcompute_range_faces(lon, lat, hgt, \ 701 var3, dnamesvar, dvnamesvar) 702 703 # Removing the nonChecking variable-dimensions from the initial list 704 varsadd = [] 705 diagoutvd = list(dvnames) 706 for nonvd in NONchkvardims: 707 if gen.searchInlist(dvnames,nonvd): diagoutvd.remove(nonvd) 708 varsadd.append(nonvd) 709 ncvar.insert_variable(ncobj, 'range_faces', diagout, diagoutd, diagoutvd, \ 704 dhgt, peaks, valleys, origfaces, diagout, diagoutd, diagoutvd = \ 705 diag.Forcompute_range_faces(lon, lat, hgt, face, Nptfilt, dnamesvar, \ 706 dvnamesvar) 707 708 # Removing the nonChecking variable-dimensions from the initial list 709 varsadd = [] 710 diagoutvd = list(dvnames) 711 for nonvd in NONchkvardims: 712 if gen.searchInlist(dvnames,nonvd): diagoutvd.remove(nonvd) 713 varsadd.append(nonvd) 714 715 ncvar.insert_variable(ncobj, 'hgtderivdeg', dhgt, diagoutd, diagoutvd, \ 710 716 newnc) 717 ovar = newnc.variables['orogderivdeg'] 718 if face == 'WE': axis = 'lon' 719 elif face == 'SN': axis = 'lat' 720 ncvar.set_attribute(ovar, 'deriv', axis) 721 722 ncvar.insert_variable(ncobj, 'peak', peaks, diagoutd, diagoutvd, newnc) 723 ncvar.insert_variable(ncobj, 'valley', valleys, diagoutd, diagoutvd, newnc) 724 725 ncvar.insert_variable(ncobj, 'rangefaces', diagout, diagoutd, diagoutvd, \ 726 newnc) 727 newnc.renameVariable('rangefaces', 'rangefacesfilt') 728 ovar = newnc.variables['rangefacesfilt'] 729 ncvar.set_attribute(ovar, 'face', face) 730 ncvar.set_attributek(ovar, 'grid_points_filter', Nptfilt, 'I') 731 732 ncvar.insert_variable(ncobj, 'rangefaces', origfaces, diagoutd, diagoutvd, \ 733 newnc) 734 ovar = newnc.variables['rangefaces'] 735 ncvar.set_attribute(ovar, 'face', face) 711 736 712 737 # mrso: total soil moisture SMOIS, DZS -
trunk/tools/module_ForDiagnostics.f90
r2209 r2212 949 949 END SUBROUTINE compute_fog_FRAML50 950 950 951 SUBROUTINE compute_range_faces(d1, d2, lon, lat, hgt, face, faces) 951 SUBROUTINE compute_range_faces(d1, d2, lon, lat, hgt, face, Nfilt, derivhgt, peaks, valleys, & 952 origfaces, filtfaces) 952 953 ! Subroutine to compute faces [uphill, valleys, downhill] of a mountain range along a given face 953 954 954 955 IMPLICIT NONE 955 956 956 INTEGER, INTENT(in) :: d1, d2 957 INTEGER, INTENT(in) :: d1, d2, Nfilt 957 958 REAL(r_k), DIMENSION(d1,d2), INTENT(in) :: lon, lat, hgt 958 959 CHARACTER(len=*) :: face 959 INTEGER, DIMENSION(d1,d2), INTENT(out) :: faces 960 REAL(r_k), DIMENSION(d1,d2), INTENT(out) :: derivhgt 961 INTEGER, DIMENSION(d1,d2), INTENT(out) :: origfaces, filtfaces, peaks, valleys 960 962 961 963 ! Local 962 964 INTEGER :: i, j 965 INTEGER :: Npeaks, Nvalleys 966 INTEGER, DIMENSION(d1) :: ipeaks1, ivalleys1 967 INTEGER, DIMENSION(d2) :: ipeaks2, ivalleys2 963 968 964 969 !!!!!!! Variables … … 966 971 ! lat: latitude [degrees north] 967 972 ! hgt: topograpical height [m] 973 ! face: which face (axis along which produce slices) to use to compute the faces: WE, SN 974 ! Nfilt: number of grid points to use to filter the topographic values 975 ! derivhgt: topograpic derivative along axis [m deg-1] 976 ! peaks: peak point 977 ! valleys: valley point 978 ! origfaces: original faces (-1, downhill; 0: valley; 1: uphill) 979 ! filtfaces: filtered faces (-1, downhill; 0: valley; 1: uphill) 968 980 969 981 fname = 'compute_range_faces' 970 982 983 peaks = 0 984 valleys = 0 971 985 IF (TRIM(face) == 'WE') THEN 972 986 DO j=1, d2 973 CALL var_range_faces(d1, lon(:,j), lat(:,j), hgt(:,j), faces(:,j)) 987 PRINT *,'Lluis:',j 988 CALL var_range_faces(d1, lon(:,j), lat(:,j), hgt(:,j), Nfilt, derivhgt(:,j), Npeaks, & 989 ipeaks1, Nvalleys, ivalleys1, origfaces(:,j), filtfaces(:,j)) 990 DO i=1, Npeaks 991 peaks(ipeaks1(i),j) = 1 992 END DO 993 DO i=1, Nvalleys 994 valleys(ivalleys1(i),j) = 1 995 END DO 974 996 END DO 975 997 ELSE IF (TRIM(face) == 'SN') THEN 976 998 DO i=1, d1 977 CALL var_range_faces(d2, lon(i,:), lat(i,:), hgt(i,:), faces(i,:)) 999 CALL var_range_faces(d2, lon(i,:), lat(i,:), hgt(i,:), Nfilt, derivhgt(i,:), Npeaks, & 1000 ipeaks2, Nvalleys, ivalleys2, origfaces(i,:), filtfaces(i,:)) 1001 DO j=1, Npeaks 1002 peaks(i,ipeaks2(j)) = 1 1003 END DO 1004 DO j=1, Nvalleys 1005 valleys(i,ivalleys2(j)) = 1 1006 END DO 978 1007 END DO 979 1008 ELSE -
trunk/tools/module_ForDiagnosticsVars.f90
r2209 r2212 9 9 USE module_definitions 10 10 USE module_generic 11 USE module_scientific 11 12 12 13 IMPLICIT NONE … … 1579 1580 END SUBROUTINE var_fog_FRAML50 1580 1581 1581 SUBROUTINE var_range_faces(d, lon, lat, hgt, faces) 1582 SUBROUTINE var_range_faces(d, lon, lat, hgt, filt, dhgt, Npeaks, ipeaks, Nvalleys, ivalleys, & 1583 faces0, faces) 1582 1584 ! Subroutine to compute faces [uphill, valleys, downhill] of a monuntain range along a face 1583 1585 1584 1586 IMPLICIT NONE 1585 1587 1586 INTEGER, INTENT(in) :: d 1587 REAL, DIMENSION(d), INTENT(in) :: lon, lat, hgt 1588 INTEGER, DIMENSION(d), INTENT(out) :: faces 1588 INTEGER, INTENT(in) :: d, filt 1589 REAL(r_k), DIMENSION(d), INTENT(in) :: lon, lat, hgt 1590 REAL(r_k), DIMENSION(d), INTENT(out) :: dhgt 1591 INTEGER, DIMENSION(d), INTENT(out) :: ipeaks, ivalleys, faces0, faces 1592 INTEGER, INTENT(out) :: Npeaks, Nvalleys 1589 1593 1590 1594 ! Local 1591 INTEGER :: i, Nfaces, Npeaks 1595 INTEGER :: i, j, k, l, m 1596 INTEGER :: iface 1597 INTEGER :: Nfaces, Nfaces1, Npeaks1, Nvalleys1 1598 INTEGER :: fbeg, fend 1592 1599 INTEGER, DIMENSION(1) :: ihmax 1593 REAL :: hgtmax 1594 INTEGER, DIMENSION(d) :: ddhgt, Ndhgt, ipeaks 1595 REAL, DIMENSION(d) :: dhgt, peaks 1600 REAL(r_k) :: hgtmax 1601 INTEGER, DIMENSION(d) :: ddhgt, Ndhgt 1602 INTEGER, DIMENSION(d) :: faces1, Ndhgt1, ipeaks1, ivalleys1 1603 REAL(r_k), DIMENSION(d) :: peaks, valleys, peaks1, valleys1 1604 LOGICAL :: peakwithin, valleywithin 1596 1605 1597 1606 !!!!!!! Variables … … 1599 1608 ! lat: latitude [degrees north] 1600 1609 ! hgt: topograpical height [m] 1610 ! filt: number of grid points to use to filter the topographic values. used to define: 1611 ! the minimum length of a given section 1612 ! running mean filter 1601 1613 1602 1614 fname = 'var_range_faces' … … 1610 1622 PRINT *, 'height max:', hgtmax, 'location:', ihmax 1611 1623 1624 ! Filtering height [NOT needed] 1625 ! CALL runmean_F1D(d, hgt, filt, 'progressfill', hgtrunmean) 1626 1612 1627 ! range slope 1613 1628 dhgt(1:d) = hgt(2:d) - hgt(1:d-1) … … 1615 1630 PRINT *, 'slope:', dhgt 1616 1631 1617 ! Classification1632 ! Initial classification 1618 1633 Npeaks = 0 1634 Nvalleys = 0 1619 1635 DO i=1, d-1 1620 1636 IF (dhgt(i) > 0.) THEN 1621 faces (i) = 11637 faces0(i) = 1 1622 1638 ELSE IF (dhgt(i) < 0.) THEN 1623 faces (i) = -11639 faces0(i) = -1 1624 1640 ELSE 1625 faces (i) = 01641 faces0(i) = 0 1626 1642 END IF 1627 1643 ! peaks … … 1631 1647 ipeaks(Npeaks) = i+1 1632 1648 END IF 1649 ! valleys 1650 IF (dhgt(i) < 0. .AND. dhgt(i+1) > 0.) THEN 1651 Nvalleys = Nvalleys + 1 1652 valleys(Nvalleys) = hgt(i+1) 1653 ivalleys(Nvalleys) = i+1 1654 END IF 1633 1655 END DO 1634 1656 1635 PRINT *, 'faces:', faces 1657 PRINT *, 'faces:', faces0 1636 1658 PRINT *, Npeaks, ' peaks:', peaks(1:Npeaks), ' ipeak:', ipeaks(1:Npeaks) 1659 PRINT *, Nvalleys, ' valleys:', valleys(1:Nvalleys), ' ivalley:', ivalleys(1:Nvalleys) 1637 1660 1638 1661 ! tendency of the slope … … 1641 1664 Ndhgt(Nfaces) = 1 1642 1665 DO i=2, d-1 1643 IF (faces (i) /= faces(i-1)) THEN1666 IF (faces0(i) /= faces0(i-1)) THEN 1644 1667 Nfaces = Nfaces + 1 1645 1668 Ndhgt(Nfaces) = 1 … … 1653 1676 PRINT *, Nfaces, ' length faces:', Ndhgt(1:Nfaces) 1654 1677 1655 PRINT *, '# lon[0] lat[1] heights[2] slope[3] faces[4] ddhgt[5]' 1678 ! classification using filt. 1679 ! On that section of the hill smaller than the selected filter. Replace values by the ones from 1680 ! the previous section (except if it is already valley!) 1681 ! e.g.: filt= 3 1682 ! faces0 = 0, 0, 1, 1, 1, 1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1 -1, -1, 0, 0 1683 ! faces = 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1 -1, -1, 0, 0 1684 faces1 = faces0 1685 Nfaces1 = 1 1686 Npeaks1 = 0 1687 Nvalleys1 = 0 1688 Ndhgt1(1) = Ndhgt(1) 1689 DO i=2, Nfaces 1690 fbeg = SUM(Ndhgt(1:i-1)) 1691 fend = fbeg + Ndhgt(i) 1692 peakwithin = .FALSE. 1693 valleywithin = .FALSE. 1694 DO j=1, Npeaks 1695 IF (ipeaks(j) == fbeg) THEN 1696 k = j 1697 peakwithin = .TRUE. 1698 EXIT 1699 END IF 1700 END DO 1701 DO j=1, Nvalleys 1702 IF (ivalleys(j) == fbeg) THEN 1703 m = j 1704 valleywithin = .TRUE. 1705 EXIT 1706 END IF 1707 END DO 1708 1709 IF (Ndhgt(i) < filt) THEN 1710 PRINT *, 'Lluis replacing !!!', i, ':', fbeg, fend, '<>', faces0(fbeg-1) 1711 IF (faces0(fbeg) /= 0) faces1(fbeg:fend) = faces0(fbeg-1) 1712 Ndhgt1(Nfaces1) = Ndhgt1(Nfaces1) + fend - fbeg + 1 1713 peakwithin = .FALSE. 1714 valleywithin = .FALSE. 1715 ELSE 1716 Nfaces1 = Nfaces1 + 1 1717 Ndhgt1(Nfaces1) = Ndhgt(i) 1718 END IF 1719 1720 IF (peakwithin) THEN 1721 Npeaks1 = Npeaks1 + 1 1722 peaks1(Npeaks1) = peaks(k) 1723 END IF 1724 IF (valleywithin) THEN 1725 Nvalleys1 = Nvalleys1 + 1 1726 valleys1(Nvalleys1) = valleys(m) 1727 END IF 1728 END DO 1729 1730 ! Introducing valleys between peaks lower than the highest peak in the section 1731 faces = faces1 1732 IF (Npeaks1 > 1) THEN 1733 DO i=1,Npeaks1,2 1734 fbeg = ipeaks1(i) 1735 fend = ipeaks1(i+1) 1736 faces(fbeg:fend) = 0 1737 END DO 1738 END IF 1739 1740 PRINT *, '# lon[0] lat[1] heights[2] slope[3] faces0[4] faces1[5] faces1[6] ddhgt[7]' 1656 1741 DO i=1, d 1657 PRINT *, lon(i), lat(i), hgt(i), dhgt(i), faces (i), ddhgt(i)1742 PRINT *, lon(i), lat(i), hgt(i), dhgt(i), faces0(i), faces1(i), faces(i), ddhgt(i) 1658 1743 END DO 1659 1744 -
trunk/tools/variables_values.dat
r2209 r2212 296 296 HGT, orog, orography, 0., 3000., surface|altitude, m,terrain, $orog$, orog 297 297 HGT_M, orog, orography, 0., 3000., surface|altitude, m,terrain, $orog$, orog 298 orogderivdeg, orogderivdeg, orography_derivative_degrees, 0., 3000., derivative|along|degree|coordinate|of|surface|altitude, mdeg-1,seismic, $orog_{deri}^{deg}$, orog_deriv_deg 299 hgtderivdeg, orogderivdeg, orography_derivative_degrees, 0., 3000., derivative|along|degree|coordinate|of|surface|altitude, mdeg-1,seismic, $orog_{deri}^{deg}$, orog_deriv_deg 300 peak, peak, peak_point, 0., 1., peak|grd|point, 1, Binary, $peak$, peak 298 301 plfc, plfc, pressure_level_free_convection, 100., 101000., pressure|of|level|free|convection, Pa, BuPu, $lfc^{p}$, lfc_p 299 302 LFCP, plfc, pressure_level_free_convection, 100., 101000., pressure|of|level|free|convection, Pa, BuPu, $lfc^{p}$, lfc_p … … 539 542 Meridional wind, va, northward_wind, -30., 30., northward|wind, ms-1, seismic, $va$, va 540 543 LVITV, va, northward_wind, -30., 30., northward|wind, ms-1, seismic, $va$, va 544 valley, valley, valley_point, 0., 1., valley|grd|point, 1, Binary, $valley$, valley 541 545 vas, vas, northward_wind, -30., 30., northward|10m|wind, ms-1, seismic, $vas$, vas 542 546 VAS, vas, northward_wind, -30., 30., northward|10m|wind, ms-1, seismic, $vas$, vas
Note: See TracChangeset
for help on using the changeset viewer.