Changeset 2215 in lmdz_wrf for trunk/tools


Ignore:
Timestamp:
Nov 6, 2018, 8:14:36 PM (6 years ago)
Author:
lfita
Message:

Final working version of `range_faces'

Location:
trunk/tools
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/diag_tools.py

    r2214 r2215  
    13701370    return var1, var2, vardims, varvdims
    13711371
    1372 def Forcompute_range_faces(lon, lat, hgt, face, Nfilt, newrng, dimns, dimvns):
     1372def Forcompute_range_faces(lon, lat, hgt, ds, face, dsfilt, dsnewrng, hvalleyrng,    \
     1373  dimns, dimvns):
    13731374    """ Function to compute faces [uphill, valley, downhill] of sections of a mountain
    13741375      rage, along a given face
     
    13771378      [lat]= latitude values (assuming [y,x]) [degrees north]
    13781379      [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
    1381       newrng= number of grid points as distance to start a new mountain range
     1380      [ds]= distance between grid points (assuming [y,x]) [m]
     1381      face= which face (axis along which produce slices) to use to compute the
     1382        faces: WE, SN
     1383      dsfilt= distance to filter orography smaller scale of it [m]
     1384      dsnewrng= distance to start a new mountain range [m]
     1385      hvalleyrng: maximum height of a valley to mark change of range [m]
    13821386      [dimns]= list of the name of the dimensions of [smois]
    13831387      [dimvns]= list of the name of the variables with the values of the
     
    13851389    """
    13861390    fname = 'Forcompute_range_faces'
     1391
     1392    print fname + 'Lluis:', dsfilt, dsnewrng, hvalleyrng
    13871393
    13881394    vardims = dimns[:]
     
    13971403          ptrnghgtmaxt =                                                             \
    13981404          fdin.module_fordiagnostics.compute_range_faces(lon=lon[:].transpose(),     \
    1399           lat=lat[:].transpose(), hgt=hgt[:].transpose(), face=face, nfilt=Nfilt,    \
    1400           newrange=newrng, d1=dx, d2=dy)
     1405          lat=lat[:].transpose(), hgt=hgt[:].transpose(), dist=ds[:].transpose(),    \
     1406          face=face, dsfilt=dsfilt, dsnewrange=dsnewrng, hvalrng=hvalleyrng, d1=dx,  \
     1407          d2=dy)
     1408        print 'Finished!'
    14011409        hgtmax = hgtmaxt.transpose()
    14021410        pthgtmax = pthgtmaxt.transpose()
  • trunk/tools/diagnostics.inf

    r2206 r2215  
    3434psl, WRFpsl_ecmwf, PSFC@HGT@WRFt@WRFp@ZNU@ZNW
    3535psl, WRFpsl_ptarget, WRFp@PSFC@WRFt@HGT@QVAPOR
     36rangefaces, range_faces, XLONG@XLAT@HGT@WRFdxdy@face:WE:10.:30.:200.
    3637rvor, rvor, U@V
    3738rvors, WRFrvors, U10@V10@WRFpos
  • trunk/tools/diagnostics.py

    r2214 r2215  
    104104  'TStd', 'TSwds', 'TSwss',                                                          \
    105105  'WRFbils',                                                                         \
    106   'WRFclivi', 'WRFclwvi', 'WRFdens', 'WRFgeop',                                      \
     106  'WRFclivi', 'WRFclwvi', 'WRFdens', 'WRFdx', 'WRFdxdy', 'WRFdy', 'WRFgeop',         \
    107107  'WRFp', 'WRFtd',                                                                   \
    108108  'WRFpos', 'WRFprc', 'WRFprls', 'WRFrh', 'LMDZrh', 'LMDZrhs',                       \
    109109  'WRFrhs', 'WRFrvors',                                                              \
    110   'WRFt', 'WRFtime', 'WRFua', 'WRFva', 'WRFwds', 'WRFwss', 'WRFheight', 'WRFz']
     110  'WRFt', 'WRFtime', 'WRFua', 'WRFva', 'WRFwds', 'WRFwss', 'WRFheight', 'WRFz',      \
     111  'WRFzg']
    111112
    112113# diagnostics not to check their dependeny
     
    165166WRFtime_compute = False
    166167WRFz_compute = False
     168WRFdxdy_compute = False
    167169
    168170# File creation
     
    189191    if dnv == 'WRFtime': WRFtime_compute = True
    190192    if dnv == 'WRFz':WRFz_compute = True
     193    if dnv == 'WRFdxdy':WRFdxdy_compute = True
    191194
    192195# diagnostics to compute
     
    217220        if gen.searchInlist(depvars, 'WRFtime'): WRFtime_compute = True
    218221        if gen.searchInlist(depvars, 'WRFz'): WRFz_compute = True
     222        if gen.searchInlist(depvars, 'WRFdxdy'): WRFdxdy_compute = True
    219223
    220224# Dictionary with the new computed variables to be able to add them
     
    396400    # Attributes of the variable
    397401    Vvals = gen.variables_values('WRFz')
    398     dictcompvars['WRFz'] = {'name': Vvals[0], 'standard_name': Vvals[1],          \
     402    dictcompvars['WRFz'] = {'name': Vvals[0], 'standard_name': Vvals[1],             \
     403      'long_name': Vvals[4].replace('|',' '), 'units': Vvals[5]}
     404
     405if WRFdxdy_compute:
     406    print '  ' + main + ': Retrieving dxdy: real distance between grid points ' +    \
     407      'from WRF as dx=(XLONG(i+1)-XLONG(i))*DX/MAPFAC_M, dy=(XLAT(j+1)-XLAT(i))*DY/'+\
     408      'MAPFAC_M, ds=sqrt(dx**2+dy**2)'
     409    dimv = ncobj.variables['XLONG'].shape
     410    WRFlon = ncobj.variables['XLONG'][0,:,:]
     411    WRFlat = ncobj.variables['XLAT'][0,:,:]
     412    WRFmapfac_m = ncobj.variables['MAPFAC_M'][0,:,:]
     413    DX = ncobj.DX
     414    DY = ncobj.DY
     415
     416    dimx = dimv[2]
     417    dimy = dimv[1]
     418
     419    WRFdx = np.zeros((dimy,dimx), dtype=np.float)
     420    WRFdy = np.zeros((dimy,dimx), dtype=np.float)
     421
     422    WRFdx[:,0:dimx-1]=(WRFlon[:,1:dimx]-WRFlon[:,0:dimx-1])*DX/WRFmapfac_m[:,0:dimx-1]
     423    WRFdy[0:dimy-1,:]=(WRFlat[1:dimy,:]-WRFlat[0:dimy-1,:])*DY/WRFmapfac_m[0:dimy-1,:]
     424    WRFds = np.sqrt(WRFdx**2 + WRFdy**2)
     425
     426    # Attributes of the variable
     427    Vvals = gen.variables_values('WRFdx')
     428    dictcompvars['WRFdx'] = {'name': Vvals[0], 'standard_name': Vvals[1],             \
     429      'long_name': Vvals[4].replace('|',' '), 'units': Vvals[5]}
     430    Vvals = gen.variables_values('WRFdy')
     431    dictcompvars['WRFdy'] = {'name': Vvals[0], 'standard_name': Vvals[1],             \
     432      'long_name': Vvals[4].replace('|',' '), 'units': Vvals[5]}
     433    Vvals = gen.variables_values('WRFds')
     434    dictcompvars['WRFds'] = {'name': Vvals[0], 'standard_name': Vvals[1],             \
    399435      'long_name': Vvals[4].replace('|',' '), 'units': Vvals[5]}
    400436
     
    681717        ncvar.insert_variable(ncobj, 'hurs', diagout, diagoutd, diagoutvd, newnc)
    682718
    683 # range_faces: LON, LAT, HGT, 'face:['WE'/'SN']:[Nptfilt]:[Nptnewrange]'
     719# range_faces: LON, LAT, HGT, WRFdxdy, 'face:['WE'/'SN']:[dsfilt]:[dsnewrange]:[hvalleyrange]'
    684720    elif diagn == 'range_faces':
    685721           
     
    687723        var1 = ncobj.variables[depvars[1]][:]
    688724        var2 = ncobj.variables[depvars[2]][:]
    689         face = depvars[3].split(':')[1]
    690         Nptfilt = int(depvars[3].split(':')[2])
    691         Nptnewrange = int(depvars[3].split(':')[3])
     725        face = depvars[4].split(':')[1]
     726        dsfilt = np.float(depvars[4].split(':')[2])
     727        dsnewrange = np.float(depvars[4].split(':')[3])
     728        hvalleyrange = np.float(depvars[4].split(':')[4])
    692729
    693730        dnamesvar = list(ncobj.variables[depvars[0]].dimensions)
     
    705742        orogmax, ptorogmax, dhgt, peaks, valleys, origfaces, diagout, diagoutd,      \
    706743          diagoutvd, rngorogmax, ptrngorogmax = diag.Forcompute_range_faces(lon, lat,\
    707           hgt, face, Nptfilt, Nptnewrange, dnamesvar, dvnamesvar)
    708 
    709         # Removing the nonChecking variable-dimensions from the initial list
    710         varsadd = []
    711         diagoutvd = list(dvnames)
    712         for nonvd in NONchkvardims:
    713             if gen.searchInlist(dvnames,nonvd): diagoutvd.remove(nonvd)
    714             varsadd.append(nonvd)
     744          hgt, WRFds, face, dsfilt, dsnewrange, hvalleyrange, dnamesvar, dvnamesvar)
     745
     746        # Removing the nonChecking variable-dimensions from the initial list
     747        varsadd = []
     748        diagoutvd = list(dvnames)
     749        for nonvd in NONchkvardims:
     750            if gen.searchInlist(dvnames,nonvd): diagoutvd.remove(nonvd)
     751            varsadd.append(nonvd)
     752
     753        ncvar.insert_variable(ncobj, 'dx', WRFdx, diagoutd, diagoutvd, newnc)
     754        ncvar.insert_variable(ncobj, 'dy', WRFdy, diagoutd, diagoutvd, newnc)
     755        ncvar.insert_variable(ncobj, 'ds', WRFds, diagoutd, diagoutvd, newnc)
    715756
    716757        # adding variables to output file
     
    748789        ncvar.set_attribute(ovar, 'deriv', axis)
    749790
    750         ncvar.insert_variable(ncobj, 'hgtderivdeg', dhgt, diagoutd, diagoutvd,       \
    751           newnc)
    752         ovar = newnc.variables['orogderivdeg']
     791        ncvar.insert_variable(ncobj, 'orogderiv', dhgt, diagoutd, diagoutvd, newnc)
     792        ovar = newnc.variables['orogderiv']
    753793        ncvar.set_attribute(ovar, 'deriv', axis)
    754794
     
    761801        ovar = newnc.variables['rangefacesfilt']
    762802        ncvar.set_attribute(ovar, 'face', face)
    763         ncvar.set_attributek(ovar, 'grid_points_filter', Nptfilt, 'I')
     803        ncvar.set_attributek(ovar, 'dist_filter', dsfilt, 'F')
    764804
    765805        ncvar.insert_variable(ncobj, 'rangefaces', origfaces, diagoutd, diagoutvd,  \
    766           newnc)
     806          newnc, fill=gen.fillValueI)
    767807        ovar = newnc.variables['rangefaces']
    768808        ncvar.set_attribute(ovar, 'face', face)
     809        ncvar.set_attributek(ovar, 'dist_newrange', dsnewrange, 'F')
     810        ncvar.set_attributek(ovar, 'h_valley_newrange', hvalleyrange, 'F')
    769811
    770812# mrso: total soil moisture SMOIS, DZS
  • trunk/tools/module_ForDiagnostics.f90

    r2214 r2215  
    949949  END SUBROUTINE compute_fog_FRAML50
    950950
    951   SUBROUTINE compute_range_faces(d1, d2, lon, lat, hgt, face, Nfilt, newrange, hgtmax, pthgtmax,      &
    952     derivhgt, peaks, valleys, origfaces, filtfaces, rangeshgtmax, ptrangeshgtmax)
     951  SUBROUTINE compute_range_faces(d1, d2, lon, lat, hgt, dist, face, dsfilt, dsnewrange, hvalrng,      &
     952    hgtmax, pthgtmax, derivhgt, peaks, valleys, origfaces, filtfaces, rangeshgtmax, ptrangeshgtmax)
    953953! Subroutine to compute faces [uphill, valleys, downhill] of a mountain range along a given face
    954954
    955955    IMPLICIT NONE
    956956
    957     INTEGER, INTENT(in)                                  :: d1, d2, Nfilt, newrange
    958     REAL(r_k), DIMENSION(d1,d2), INTENT(in)              :: lon, lat, hgt
     957    INTEGER, INTENT(in)                                  :: d1, d2
     958    REAL(r_k), INTENT(in)                                :: dsfilt, dsnewrange, hvalrng
     959    REAL(r_k), DIMENSION(d1,d2), INTENT(in)              :: lon, lat, hgt, dist
    959960    CHARACTER(len=*)                                     :: face
    960961    REAL(r_k), DIMENSION(d1,d2), INTENT(out)             :: derivhgt, hgtmax, rangeshgtmax
     
    977978! hgt: topograpical height [m]
    978979! face: which face (axis along which produce slices) to use to compute the faces: WE, SN
    979 ! Nfilt: number of grid points to use to filter the topographic values
    980 ! newrange: number of grid points as distance to start a new mountain range
     980! dsfilt: distance to filter orography smaller scale of it [m]
     981! dsnewrange: distance to start a new mountain range [m]
     982! hvalrng: maximum height of a valley to mark change of range [m]
    981983! hgtmax: maximum height of the face [m]
    982984! pthgtmax: grid point of the maximum height [1]
     
    994996    valleys = 0
    995997    pthgtmax = 0
     998    rangeshgtmax = fillVal64
    996999    IF (TRIM(face) == 'WE') THEN
    9971000      DO j=1, d2
    998         CALL var_range_faces(d1, lon(:,j), lat(:,j), hgt(:,j), Nfilt, newrange, hgtmax1, pthgtmax1,   &
    999           derivhgt(:,j), Npeaks, ipeaks1, Nvalleys, ivalleys1, origfaces(:,j), filtfaces(:,j),        &
    1000           Nranges, ranges1, rangeshgtmax1, irangeshgtmax1)
     1001        PRINT *,'Lluis:', j-1, '***'
     1002        CALL var_range_faces(d1, lon(:,j), lat(:,j), hgt(:,j), dist(:,j), dsfilt, dsnewrange, hvalrng,&
     1003          hgtmax1, pthgtmax1, derivhgt(:,j), Npeaks, ipeaks1, Nvalleys, ivalleys1, origfaces(:,j),    &
     1004          filtfaces(:,j), Nranges, ranges1, rangeshgtmax1, irangeshgtmax1)
    10011005        hgtmax(:,j) = hgtmax1
    10021006        pthgtmax(pthgtmax1,j) = 1
     
    10141018    ELSE IF (TRIM(face) == 'SN') THEN
    10151019      DO i=1, d1
    1016         CALL var_range_faces(d2, lon(i,:), lat(i,:), hgt(i,:), Nfilt, newrange, hgtmax1, pthgtmax1,   &
    1017           derivhgt(i,:), Npeaks, ipeaks2, Nvalleys, ivalleys2, origfaces(i,:), filtfaces(i,:),        &
    1018           Nranges, ranges2, rangeshgtmax2, irangeshgtmax2)
     1020        CALL var_range_faces(d2, lon(i,:), lat(i,:), hgt(i,:), dist(i,:), dsfilt, dsnewrange, hvalrng,&
     1021          hgtmax1, pthgtmax1, derivhgt(i,:), Npeaks, ipeaks2, Nvalleys, ivalleys2, origfaces(i,:),    &
     1022          filtfaces(i,:), Nranges, ranges2, rangeshgtmax2, irangeshgtmax2)
    10191023        hgtmax(i,:) = hgtmax1
    10201024        pthgtmax(i,pthgtmax1) = 1
  • trunk/tools/module_ForDiagnosticsVars.f90

    r2214 r2215  
    15801580  END SUBROUTINE var_fog_FRAML50
    15811581
    1582   SUBROUTINE var_range_faces(d, lon, lat, hgt, filt, newrange, hgtmax, ihgtmax, dhgt, Npeaks, ipeaks, &
    1583     Nvalleys, ivalleys, faces0, faces, Nranges, ranges, rangeshgtmax, irangeshgtmax)
     1582  SUBROUTINE var_range_faces(d, lon, lat, hgt, dist, filt, newrange, hvalleyrange, hgtmax, ihgtmax,   &
     1583    dhgt, Npeaks, ipeaks, Nvalleys, ivalleys, faces0, faces, Nranges, ranges, rangeshgtmax,           &
     1584    irangeshgtmax)
    15841585! Subroutine to compute faces [uphill, valleys, downhill] of a monuntain range along a face
    15851586
    15861587    IMPLICIT NONE
    15871588
    1588     INTEGER, INTENT(in)                                  :: d, filt, newrange
    1589     REAL(r_k), DIMENSION(d), INTENT(in)                  :: lon, lat, hgt
     1589    INTEGER, INTENT(in)                                  :: d
     1590    REAL(r_k), INTENT(in)                                :: filt, newrange, hvalleyrange
     1591    REAL(r_k), DIMENSION(d), INTENT(in)                  :: lon, lat, hgt, dist
    15901592    INTEGER, INTENT(out)                                 :: ihgtmax, Npeaks, Nvalleys, Nranges
    15911593    INTEGER, DIMENSION(d), INTENT(out)                   :: ipeaks, ivalleys, faces0, faces,          &
     
    16001602    INTEGER                                              :: Nfaces, Nfaces1, Npeaks1, Nvalleys1
    16011603    INTEGER                                              :: fbeg, fend
     1604    REAL(r_k)                                            :: dd
    16021605    INTEGER, DIMENSION(1)                                :: ihmax
    16031606    INTEGER, DIMENSION(d)                                :: ddhgt, Ndhgt
     
    16061609    REAL(r_k), DIMENSION(d)                              :: sortedpeaks
    16071610    INTEGER, DIMENSION(d)                                :: isortedpeaks
    1608     LOGICAL                                              :: rangewithin, peakwithin, valleywithin
     1611    LOGICAL                                              :: firstvalley, rangewithin, peakwithin,      &
     1612      valleywithin
    16091613
    16101614!!!!!!! Variables
     
    16121616! lat: latitude [degrees north]
    16131617! hgt: topograpical height [m]
    1614 ! filt: number of grid points to use to filter the topographic values. used to define:
     1618! dist: distance between grid points [m]
     1619! filt: distance to use to filter the topographic values [m]. used to define:
    16151620!   the minimum length of a given section
    1616 !   running mean filter
    1617 ! newrange: number of grid points as distance to start a new mountain range
     1621! newrange: distance to start a new mountain range [m]
     1622! hvalleyrange: maximum height of a valley to mark change of range [m]
    16181623
    16191624    fname = 'var_range_faces'
     
    16321637
    16331638    ! range slope
    1634     dLl = SQRT((lon(2:d)-lon(1:d-1))**2+(lat(2:d)-lat(1:d-1))**2)
    16351639    dhgt(1:d) = hgt(2:d) - hgt(1:d-1)
    1636     dhgt = dhgt/dLl
     1640    dhgt = dhgt/dist(1:d)
    16371641
    16381642    !PRINT *, 'slope:', dhgt
     
    16431647    DO i=1, d-1
    16441648      IF (dhgt(i) > 0.) THEN
    1645         faces0(i) = 1
     1649        IF (hgt(i) < hvalleyrange) THEN
     1650          faces0(i) = fillValI
     1651        ELSE
     1652          faces0(i) = 1
     1653        END IF
    16461654      ELSE IF (dhgt(i) < 0.) THEN
    1647         faces0(i) = -1
     1655        IF (hgt(i) < hvalleyrange) THEN
     1656          faces0(i) = fillValI
     1657        ELSE
     1658          faces0(i) = -1
     1659        END IF
    16481660      ELSE
    1649         faces0(i) = 0
     1661        IF (hgt(i) == zeroRK .AND. hgt(i+1) == zeroRK) THEN
     1662          faces0(i) = fillValI
     1663        ELSE
     1664          faces0(i) = 0
     1665        END IF
    16501666      END IF
    16511667      ! peaks
     
    16861702    ! Defining quantitiy of ranges within the face
    16871703    !   sorting peaks within the face and defining ranges as maximum peaks distanced > newrage
    1688     sortedpeaks = peaks
    1689     CALL SortR_K(sortedpeaks, Npeaks)
    1690     isortedpeaks = 0
    1691     DO i=1, Npeaks
    1692       DO j=1, Npeaks
    1693         IF (peaks(j) == sortedpeaks(i)) isortedpeaks(i) = ipeaks(j)
     1704
     1705    !sortedpeaks = peaks
     1706    !CALL SortR_K(sortedpeaks, Npeaks)
     1707    !isortedpeaks = 0
     1708    !DO i=1, Npeaks
     1709    !  DO j=1, Npeaks
     1710    !    IF (peaks(j) == sortedpeaks(i)) isortedpeaks(i) = ipeaks(j)
     1711    !  END DO
     1712    !END DO
     1713 
     1714    ranges = -1
     1715    Nranges = 0
     1716    l = 0
     1717    DO i=1,d
     1718      IF (hgt(i) >= hvalleyrange) THEN
     1719        IF (Nranges == 0) THEN
     1720          Nranges = 1
     1721          ranges(1,Nranges) = i
     1722        ELSE
     1723          IF (ranges(2,Nranges) /= -1) THEN
     1724            Nranges = Nranges + 1
     1725            ranges(1,Nranges) = i
     1726          END IF
     1727        END IF
     1728      ELSE
     1729        IF ((ranges(1,Nranges) /= -1) .AND. (ranges(2,Nranges) == -1)) ranges(2,Nranges) = i-1
     1730      END IF
     1731    END DO
     1732    IF (ranges(2,Nranges) == -1) ranges(2,Nranges) = d
     1733
     1734    ! Getting characteristics of ranges
     1735    irangeshgtmax = -1
     1736    rangeshgtmax = -1000.
     1737    k = 1
     1738    DO i=1, Nranges
     1739      DO j=ranges(1,i), ranges(2,i)
     1740       IF (hgt(j) > rangeshgtmax(i)) THEN
     1741         irangeshgtmax(i) = j
     1742         rangeshgtmax(i) = hgt(j)
     1743        END IF
    16941744      END DO
    16951745    END DO
    1696  
    1697     ranges = -1
    1698     Nranges = 1
    1699     ranges(1,Nranges) = ipeaks(1)
    1700     ranges(2,Nranges) = ipeaks(1)
    1701     irangeshgtmax(Nranges) = ipeaks(1)
    1702     rangeshgtmax(Nranges) = peaks(1)
    1703     IF (Npeaks >= 2) THEN
    1704       DO j=2, Npeaks
    1705         rangewithin = .FALSE.
    1706         IF (ranges(1,Nranges) - isortedpeaks(j) < newrange) THEN
    1707           ranges(2,Nranges) = ipeaks(j)
    1708           IF (peaks(j) > rangeshgtmax(Nranges)) THEN
    1709             rangeshgtmax(Nranges) = peaks(j)
    1710             irangeshgtmax(Nranges) = ipeaks(j)
    1711           END IF
    1712         ELSE
    1713           Nranges = Nranges + 1
    1714           ranges(1,Nranges) = ipeaks(j)
    1715           ranges(2,Nranges) = ipeaks(j)
    1716           rangeshgtmax(Nranges) = peaks(j)
    1717           irangeshgtmax(Nranges) = ipeaks(j)
    1718         END IF
    1719       END DO
    1720     END IF
    17211746    !PRINT *, Nranges, ' _______'
    1722     !DO i=, Nranges
    1723     !   PRINT *,i,':', ranges(:,i),' max:', rangeshgtmax(i), ' ,', irangeshgtmax(i)
     1747    !DO i=1, Nranges
     1748    !  PRINT *,i,':', ranges(:,i),' max:', rangeshgtmax(i), ' ,', irangeshgtmax(i)
    17241749    !END DO
    17251750
     
    17431768    END IF
    17441769
     1770    ! Using defined ranges for the last refinement.
     1771    !   Uphills after range maximum peak as valley: if dhgt[i] > 0. and i > rangemax --> face[i] = 0
     1772    !   Downhills before range maximum peak as valley: if dhgt[i] < 0. and i < rangemax --> face[i] = 0
     1773    !   face values before first range, removed: if dhgt[i] != 0. and i < range[1,1] --> face[i] = fillvalueI
     1774    !   face values after last range, removed: if dhgt[i] != 0. and i < range[2,Nranges] --> face[i] = fillvalueI
     1775    DO i=1,Nranges
     1776      DO j=ranges(1,i), ranges(2,i)
     1777        IF (dhgt(j) > 0. .AND. j > irangeshgtmax(i)) faces0(j) = 0
     1778        IF (dhgt(j) < 0. .AND. j < irangeshgtmax(i)) faces0(j) = 0
     1779      END DO
     1780    END DO
     1781    IF (dhgt(j) /= 0. .AND. j < ranges(1,1)) faces0(j) = fillValI
     1782    IF (dhgt(j) /= 0. .AND. j > ranges(2,Nranges)) faces0(j) = fillValI
     1783
    17451784    ! classification using filt.
    17461785    !   On that section of the hill smaller than the selected filter. Replace values by the ones from
     
    17491788    !       faces0 = 0, 0, 1, 1, 1, 1, -1, -1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1 -1, -1, 0, 0
    17501789    !       faces = 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1 -1, -1, 0, 0
    1751     faces1 = faces0
    1752     Nfaces1 = 1
    1753     Npeaks1 = 0
    1754     Nvalleys1 = 0
    1755     Ndhgt1(1) = Ndhgt(1)
    1756     DO i=2, Nfaces
    1757       fbeg = SUM(Ndhgt(1:i-1))
    1758       fend = fbeg + Ndhgt(i)
    1759       peakwithin = .FALSE.
    1760       valleywithin = .FALSE.
    1761       DO j=1, Npeaks
    1762         IF (ipeaks(j) == fbeg) THEN
    1763           k = j
    1764           peakwithin = .TRUE.
    1765           EXIT
    1766         END IF
    1767       END DO
    1768       DO j=1, Nvalleys
    1769         IF (ivalleys(j) == fbeg) THEN
    1770           m = j
    1771           valleywithin = .TRUE.
    1772           EXIT
    1773         END IF
    1774       END DO
    1775 
    1776       IF (Ndhgt(i) < filt) THEN
    1777         PRINT *, 'Lluis replacing !!!', i, ':', fbeg, fend, '<>', faces0(fbeg-1)
    1778         IF (faces0(fbeg) /= 0) faces1(fbeg:fend) = faces0(fbeg-1)
    1779         Ndhgt1(Nfaces1) = Ndhgt1(Nfaces1) + fend - fbeg + 1
    1780         peakwithin = .FALSE.
    1781         valleywithin = .FALSE.
    1782       ELSE
    1783         Nfaces1 = Nfaces1 + 1
    1784         Ndhgt1(Nfaces1) = Ndhgt(i)
    1785       END IF
    1786 
    1787       IF (peakwithin) THEN
    1788         Npeaks1 = Npeaks1 + 1
    1789         peaks1(Npeaks1) = peaks(k)
    1790       END IF
    1791       IF (valleywithin) THEN
    1792         Nvalleys1 = Nvalleys1 + 1
    1793         valleys1(Nvalleys1) = valleys(m)
    1794       END IF
    1795     END DO
     1790    !!faces1 = faces0
     1791    !!Nfaces1 = 1
     1792    !!Npeaks1 = 0
     1793    !!Nvalleys1 = 0
     1794    !!Ndhgt1(1) = Ndhgt(1)
     1795    !!DO i=2, Nfaces
     1796    !!  fbeg = SUM(Ndhgt(1:i-1))
     1797    !!  fend = fbeg + Ndhgt(i)
     1798    !!  peakwithin = .FALSE.
     1799    !!  valleywithin = .FALSE.
     1800    !!  DO j=1, Npeaks
     1801    !!    IF (ipeaks(j) == fbeg) THEN
     1802    !!      k = j
     1803    !!      peakwithin = .TRUE.
     1804    !!      EXIT
     1805    !!    END IF
     1806    !!  END DO
     1807    !!  DO j=1, Nvalleys
     1808    !!    IF (ivalleys(j) == fbeg) THEN
     1809    !!      m = j
     1810    !!      valleywithin = .TRUE.
     1811    !!      EXIT
     1812    !!    END IF
     1813    !!  END DO
     1814
     1815    !!  dd = SUM(dist(fbeg:fend))
     1816    !!  IF (Ndhgt(i) < filt) THEN
     1817    !!    PRINT *, 'Lluis replacing !!!', i, ':', fbeg, fend, '<>', faces0(fbeg-1)
     1818    !!    IF (faces0(fbeg) /= 0) faces1(fbeg:fend) = faces0(fbeg-1)
     1819    !!    Ndhgt1(Nfaces1) = Ndhgt1(Nfaces1) + fend - fbeg + 1
     1820    !!    peakwithin = .FALSE.
     1821    !!    valleywithin = .FALSE.
     1822    !!  ELSE
     1823    !!    Nfaces1 = Nfaces1 + 1
     1824    !!    Ndhgt1(Nfaces1) = Ndhgt(i)
     1825    !!  END IF
     1826
     1827    !!  IF (peakwithin) THEN
     1828    !!    Npeaks1 = Npeaks1 + 1
     1829    !!    peaks1(Npeaks1) = peaks(k)
     1830    !!  END IF
     1831    !!  IF (valleywithin) THEN
     1832    !!    Nvalleys1 = Nvalleys1 + 1
     1833    !!    valleys1(Nvalleys1) = valleys(m)
     1834    !!  END IF
     1835    !!END DO
    17961836
    17971837    ! Introducing valleys between peaks lower than the highest peak in the section
     
    18051845    END IF
    18061846
     1847
     1848    ! Removing above sea points
     1849    DO i=1, d-1
     1850      IF (hgt(i) == zeroRK .AND. hgt(i+1) == zeroRK) dhgt(i) = fillVal64
     1851    END DO
     1852
    18071853    !PRINT *, '# lon[0] lat[1] heights[2] slope[3] faces0[4] faces1[5] faces1[6] ddhgt[7]'
    18081854    !DO i=1, d
  • trunk/tools/variables_values.dat

    r2213 r2215  
    123123dqwak, dqwak, wake_water_vapor_tendency, -3.e-7, 3.e-7, wake|water|vapor|tendency, kg/kg/s, seismic, $\partial_{t}{qv}^{wak}$, dtqvwak
    124124LDQWAK, dqwak, wake_water_vapor_tendency, -3.e-7, 3.e-7, wake|water|vapor|tendency, kg/kg/s, seismic, $\partial_{t}{qv}^{wak}$, dtqvwak
     125ds, ds, horizontal_grid_distance, 0., 200., total|distance|between|grid|points, m, Reds, $ds$, ds
     126WRFds, ds, horizontal_grid_distance, 0., 200., total|distance|between|grid|points, m, Reds, $ds$, ds
    125127dta, dta, tendency_air_temperature, -3.e-3, 3.e-3, tendency|of|air|temperature, K/s, seismic, $\partial_{t}{ta}$, dtta
    126128tnt, dta, tendency_air_temperature, -3.e-3, 3.e-3, tendency|of|air|temperature, K/s, seismic, $\partial_{t}{ta}$, dtta
     
    173175dvvdf, dvvdf, vertical_difussion_northward_wind_tendency, -3.e-3, 3.e-3, vertical|difussion|northward|wind|tendency, ms-2, seismic, $\partial_{t}{va}^{zdiff}$, dtvazdiff
    174176LDVVDF, dvvdf, vertical_difussion_northward_wind_tendency, -3.e-3, 3.e-3, vertical|difussion|northward|wind|tendency, ms-2, seismic, $\partial_{t}{va}^{zdiff}$, dtvazdiff
     177dx, dx, eastward_horizontal_grid_distance, 0., 200., eastward|distance|between|grid|points, m, Reds, $dx$, dx
     178WRFdx, dx, eastward_horizontal_grid_distance, 0., 200., eastward|distance|between|grid|points, m, Reds, $dx$, dx
     179dy, dy, northward_horizontal_grid_distance, 0., 200., northward|distance|between|grid|points, m, Blues, $dy$, dy
     180WRFdy, dy, northward_horizontal_grid_distance, 0., 200., northward|distance|between|grid|points, m, Blues, $dy$, dy
    175181etau, etau, etau, 0., 1, eta|values|on|half|(mass)|levels, -, reds, $\eta_{hm}$, eta_hm
    176182ZNU, etau, etau, 0., 1, eta|values|on|half|(mass)|levels, -, reds, $\eta_{hm}$, eta_hm
     
    296302HGT, orog, orography,  0., 3000., surface|altitude, m,terrain, $orog$, orog
    297303HGT_M, orog, orography,  0., 3000., surface|altitude, m,terrain, $orog$, orog
     304orogderiv, orogderiv, orography_derivative_degrees,  0., 3000., derivative|along|degree|coordinate|of|surface|altitude, m m-1,seismic, $orog_{deri}$, orog_deriv
     305hgtderiv, orogderiv, orography_derivative_degrees,  0., 3000., derivative|along|degree|coordinate|of|surface|altitude, m m-1,seismic, $orog_{deri}$, orog_deriv
    298306orogderivdeg, orogderivdeg, orography_derivative_degrees,  0., 3000., derivative|along|degree|coordinate|of|surface|altitude, mdeg-1,seismic, $orog_{deri}^{deg}$, orog_deriv_deg
    299307hgtderivdeg, orogderivdeg, orography_derivative_degrees,  0., 3000., derivative|along|degree|coordinate|of|surface|altitude, mdeg-1,seismic, $orog_{deri}^{deg}$, orog_deriv_deg
Note: See TracChangeset for help on using the changeset viewer.