Changeset 2208 in lmdz_wrf for trunk/tools
- Timestamp:
- Oct 31, 2018, 8:23:47 PM (6 years ago)
- Location:
- trunk/tools
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/diag_tools.py
r2140 r2208 1367 1367 1368 1368 return var1, var2, vardims, varvdims 1369 1370 def Forcompute_range_faces(lon, lat, hgt, face, dimns, dimvns): 1371 """ Function to compute faces [uphill, valley, downhill] of sections of a mountain 1372 rage, along a given face 1373 Forcompute_range_faces(lon, lat, hgt, face, dimns, dimvns) 1374 [lon]= longitude values (assuming [y,x]) [degrees east] 1375 [lat]= latitude values (assuming [y,x]) [degrees north] 1376 [hgt]= height values (assuming [y,x]) [m] 1377 [dimns]= list of the name of the dimensions of [smois] 1378 [dimvns]= list of the name of the variables with the values of the 1379 dimensions of [smois] 1380 """ 1381 fname = 'Forcompute_range_faces' 1382 1383 vardims = dimns[:] 1384 varvdims = dimvns[:] 1385 1386 if len(var.shape) == 2: 1387 faces = np.zeros((var.shape[0],var.shape[1]), dtype=np.float) 1388 dx = var.shape[1] 1389 dy = var.shape[0] 1390 1391 facest=fdin.module_fordiagnostics.compute_range_faces(lon=lon[:].transpose(),\ 1392 lat=lat[:].transpose(), hgt=hgt[:].transpose(), face=face, d1=dx, d2=dy) 1393 faces = facest.transpose() 1394 else: 1395 print errormsg 1396 print ' ' + fname + ': rank', len(var.shape), 'not ready !!' 1397 print ' it only computes 2D [y,x] rank values' 1398 quit(-1) 1399 1400 return faces, vardims, varvdims 1369 1401 1370 1402 ####### ###### ##### #### ### ## # END Fortran diagnostics -
trunk/tools/diagnostics.py
r2207 r2208 676 676 ncvar.insert_variable(ncobj, 'hurs', diagout, diagoutd, diagoutvd, newnc) 677 677 678 # range_faces: LON, LAT, HGT, 'face,[WE],[SN]' 679 elif diagn == 'range_faces': 680 681 var0 = ncobj.variables[depvars[0]][:] 682 var1 = ncobj.variables[depvars[1]][:] 683 var2 = ncobj.variables[depvars[2]][:] 684 var3 = depvars[3].split(',')[1] 685 686 dnamesvar = list(ncobj.variables[depvars[0]].dimensions) 687 dvnamesvar = ncvar.var_dim_dimv(dnamesvar,dnames,dvnames) 688 689 diagout, diagoutd, diagoutvd = diag.Forcompute_range_faces(var0, var1, var2, \ 690 var3, dnamesvar, dvnamesvar) 691 692 # Removing the nonChecking variable-dimensions from the initial list 693 varsadd = [] 694 diagoutvd = list(dvnames) 695 for nonvd in NONchkvardims: 696 if gen.searchInlist(dvnames,nonvd): diagoutvd.remove(nonvd) 697 varsadd.append(nonvd) 698 ncvar.insert_variable(ncobj, 'range_faces', diagout, diagoutd, diagoutvd, \ 699 newnc) 700 678 701 # mrso: total soil moisture SMOIS, DZS 679 702 elif diagn == 'WRFmrso': -
trunk/tools/module_ForDiagnostics.f90
r1909 r2208 948 948 END SUBROUTINE compute_fog_FRAML50 949 949 950 SUBROUTINE compute_range_faces(d1, d2, lon, lat, hgt, face, faces) 951 ! Subroutine to compute faces [uphill, valleys, downhill] of a mountain range along a given face 952 953 IMPLICIT NONE 954 955 INTEGER, INTENT(in) :: d1, d2 956 REAL(r_k), DIMENSION(d1,d2), INTENT(in) :: lon, lat, hgt 957 CHARACTER(len=*) :: face 958 INTEGER, DIMENSION(d1,d2), INTENT(out) :: faces 959 960 ! Local 961 INTEGER :: i, j 962 963 !!!!!!! Variables 964 ! lon: longitude [degrees east] 965 ! lat: latitude [degrees north] 966 ! hgt: topograpical height [m] 967 968 fname = 'compute_range_faces' 969 970 IF (TRIM(face) == 'WE') THEN 971 DO j=1, d2 972 CALL var_range_faces(d1, lon(:,j), lat(:,j), hgt(:,j), faces(:,j)) 973 END DO 974 ELSE IF (TRIM(face) == 'SN') THEN 975 DO i=1, d1 976 CALL var_range_faces(d2, lon(i,:), lat(i,:), hgt(i,:), faces(i,:)) 977 END DO 978 ELSE 979 PRINT *,TRIM(ErrWarnMsg('err')) 980 PRINT *,' ' // TRIM(fname) // ": wrong face: '" // TRIM(face) // "' !!" 981 PRINT *,' accepted ones: WE, SN' 982 STOP 983 END IF 984 985 RETURN 986 987 END SUBROUTINE compute_range_faces 988 950 989 END MODULE module_ForDiagnostics -
trunk/tools/module_ForDiagnosticsVars.f90
r1909 r2208 1578 1578 END SUBROUTINE var_fog_FRAML50 1579 1579 1580 SUBROUTINE var_range_faces(d, lon, lat, hgt, faces) 1581 ! Subroutine to compute faces of a monuntain range along a face 1582 1583 IMPLICIT NONE 1584 1585 INTEGER, INTENT(in) :: d 1586 REAL, DIMENSION(d), INTENT(in) :: lon, lat, hgt 1587 INTEGER, DIMENSION(d), INTENT(out) :: faces 1588 1589 ! Local 1590 INTEGER :: i, Nfaces, Npeaks 1591 INTEGER, DIMENSION(1) :: ihmax 1592 REAL :: hgtmax 1593 INTEGER, DIMENSION(d) :: ddhgt, Ndhgt, ipeaks 1594 REAL, DIMENSION(d) :: dhgt, peaks 1595 1596 !!!!!!! Variables 1597 ! lon: longitude [degrees east] 1598 ! lat: latitude [degrees north] 1599 ! hgt: topograpical height [m] 1600 1601 fname = 'var_range_faces' 1602 1603 PRINT *, 'heights:', hgt 1604 1605 ! Looking for the maximum height 1606 hgtmax = MAXVAL(hgt) 1607 ihmax = MAXLOC(hgt) 1608 1609 PRINT *, 'height max:', hgtmax, 'location:', ihmax 1610 1611 ! range slope 1612 dhgt(1:d) = hgt(2:d) - hgt(1:d-1) 1613 1614 PRINT *, 'slope:', dhgt 1615 1616 ! Classification 1617 Npeaks = 0 1618 DO i=1, d-1 1619 IF (dhgt(i) > 0.) THEN 1620 faces(i) = 1 1621 ELSE 1622 faces(i) = -1 1623 END IF 1624 ! peaks 1625 IF (dhgt(i) > 0. .AND. dhgt(i+1) < 0.) THEN 1626 Npeaks = Npeaks + 1 1627 peaks(Npeaks) = hgt(i+1) 1628 ipeaks(Npeaks) = i+1 1629 END IF 1630 END DO 1631 1632 PRINT *, 'faces:', faces 1633 PRINT *, Npeaks, ' peaks:', peaks(1:Npeaks), ' ipeak:', ipeaks(1:Npeaks) 1634 1635 ! tendency of the slope 1636 ddhgt(1) = 1 1637 Nfaces = 1 1638 Ndhgt(Nfaces) = 1 1639 DO i=2, d-1 1640 IF (faces(i) /= faces(i-1)) THEN 1641 ddhgt(i) = ddhgt(i-1) + 1 1642 Nfaces = Nfaces + 1 1643 Ndhgt(Nfaces) = 1 1644 ELSE 1645 Ndhgt(Nfaces) = Ndhgt(Nfaces) + 1 1646 END IF 1647 END DO 1648 1649 PRINT *, 'ddhgt:', ddhgt 1650 PRINT *, Nfaces, ' length faces:', Ndhgt(1:Nfaces) 1651 1652 RETURN 1653 1654 END SUBROUTINE var_range_faces 1655 1580 1656 SUBROUTINE var_hur(t, press, qv, hur) 1581 1657 ! Subroutine to compute relative humidity using August-Roche-Magnus approximation [1]
Note: See TracChangeset
for help on using the changeset viewer.