Changeset 2581 in lmdz_wrf


Ignore:
Timestamp:
Jun 2, 2019, 5:50:24 PM (6 years ago)
Author:
lfita
Message:

Replacing in `cur_ypolygon' 'bottom' by 'below'

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/geometry_tools.py

    r2580 r2581  
    455455    return btw
    456456
    457 def cut_ypolygon(polygon, yval, keep='bottom', Nadd=20):
     457def cut_ypolygon(polygon, yval, keep='below', Nadd=20):
    458458    """ Function to cut a polygon from a given value of the y-axis
    459459      polygon: polygon to cut
    460460      yval: value to use to cut the polygon
    461       keep: part to keep from the height ('bottom', default)
    462          'bottom': below the height
     461      keep: part to keep from the height ('below', default)
     462         'below': below the height
    463463         'above': above the height
    464464      Nadd: additional points to add to draw the line (20, default)
     
    467467
    468468    N = polygon.shape[0]
    469     availkeeps = ['bottom', 'above']
     469    availkeeps = ['below', 'above']
    470470
    471471    if not gen.searchInlist(availkeeps, keep):
     
    500500                    ipt.append([yval, polygon[ip,1]+dx*dd/dy])
    501501
    502                 if polygon[ip,0] >= yval and polygon[eep,0] <= yval:
     502                if val_between(polygon[ip,0], polygon[eep,0], yval):
    503503                    ecut.append(ip)
    504504                    dx = polygon[eep,1] - polygon[ip,1]
     
    513513            if eep == N: eep = 0
    514514     
    515             if polygon[ip,0] <= yval and polygon[eep,0] >= yval:
     515            if val_between(polygon[ip,0], polygon[eep,0], yval):
    516516                icut.append(ip)
    517517                dx = polygon[eep,1] - polygon[ip,1]
     
    520520                ipt.append([yval, polygon[ip,1]+dx*dd/dy])
    521521
    522             if polygon[ip,0] >= yval and polygon[eep,0] <= yval:
     522            if val_between(polygon[ip,0], polygon[eep,0], yval):
    523523                ecut.append(ip)
    524524                dx = polygon[eep,1] - polygon[ip,1]
     
    535535        print '    yval=', yval, 'cut, ip; ipt ep; ept ________'
    536536        for ic in range(Ncuts):
    537             print ic, icut[ic], ';', ipt[ic], ecut[ic], ';', ept[ic]
     537            print '      ', ic, icut[ic], ';', ipt[ic], ecut[ic], ';', ept[ic]
    538538
    539539    Nadds = []
     
    550550    iipc = 0
    551551    for ic in range(Ncuts):
    552         if keep == 'bottom':
     552        if keep == 'below':
    553553            Npts = icut[ic] + (N-ecut[ic]) + Nadds[ic]
    554554            cutpolygon = np.zeros((Npts,2), dtype=np.float)
     
    573573            cutline[ip,:] = ipt[ic] + np.array([dy*ip,dx*ip])
    574574        cutline[Nadds[ic]-1,:] = ept[ic]
    575         if keep == 'bottom':
     575        if keep == 'below':
    576576            cutpolygon[iip:iip+Nadds[ic],:] = cutline
    577577            cutpolygon[iip+Nadds[ic]:Npts,:] = polygon[ecut[ic]+1:N,:]
     
    581581    rmpolygon = []
    582582    Npts = cutpolygon.shape[0]
    583     if keep == 'bottom':
     583    if keep == 'below':
    584584        for ip in range(Npts):
    585585            if cutpolygon[ip,0] > yval:
     
    21602160    Height = np.max(buoy1v[:,0])
    21612161
    2162     Ncut, halfdown = cut_ypolygon(buoy1v, yval=Height/2., keep='bottom')
     2162    Ncut, halfdown = cut_ypolygon(buoy1v, yval=Height/2., keep='below')
    21632163    Ncut, halfup = cut_ypolygon(buoy1v, yval=Height/2., keep='above')
    21642164
     
    22152215    Height = np.max(buoy1v[:,0])
    22162216
    2217     Ncut, halfdown = cut_ypolygon(buoy1v, yval=Height/3., keep='bottom')
     2217    Ncut, halfdown = cut_ypolygon(buoy1v, yval=Height/3., keep='below')
    22182218    Ncut, halfbtw = cut_between_ypolygon(buoy1v, yval1=Height/3., yval2=Height*2./3.)
    22192219    Ncut, halfup = cut_ypolygon(buoy1v, yval=Height*2./3., keep='above')
     
    22722272    Height = np.max(buoy1v[:,0])
    22732273
    2274     Ncut, halfdown = cut_ypolygon(buoy1v, yval=Height/2., keep='bottom')
     2274    Ncut, halfdown = cut_ypolygon(buoy1v, yval=Height/2., keep='below')
    22752275    Ncut, halfup = cut_ypolygon(buoy1v, yval=Height/2., keep='above')
    22762276
     
    23272327    Height = np.max(buoy1v[:,0])
    23282328
    2329     Ncut, halfdown = cut_ypolygon(buoy1v, yval=Height/3., keep='bottom')
     2329    Ncut, halfdown = cut_ypolygon(buoy1v, yval=Height/3., keep='below')
    23302330    Ncut, halfbtw1 = cut_between_ypolygon(buoy1v, yval1=Height/3., yval2=Height*2./3.)
    23312331    Ncut, halfup = cut_ypolygon(buoy1v, yval=Height*2./3., keep='above')
     
    24932493
    24942494    # painting it
    2495     Ncut, third1 = cut_ypolygon(buoy1v, yval=Height/3., keep='bottom')
     2495    Ncut, third1 = cut_ypolygon(buoy1v, yval=Height/3., keep='below')
    24962496    Ncut, third2 = cut_between_ypolygon(buoy1v, yval1=Height/3., yval2=Height*2./3.)
    24972497    Ncut, third3 = cut_ypolygon(buoy1v, yval=Height*2./3., keep='above')
     
    25372537
    25382538    # painting it
    2539     Ncut, third1 = cut_ypolygon(buoy1v, yval=Height/3., keep='bottom')
     2539    Ncut, third1 = cut_ypolygon(buoy1v, yval=Height/3., keep='below')
    25402540    Ncut, third2 = cut_between_ypolygon(buoy1v, yval1=Height/3., yval2=Height*2./3.)
    25412541    Ncut, third3 = cut_ypolygon(buoy1v, yval=Height*2./3., keep='above')
     
    25812581    # painting it
    25822582    # painting it
    2583     Ncut, third1 = cut_ypolygon(buoy1v, yval=Height/3., keep='bottom')
     2583    Ncut, third1 = cut_ypolygon(buoy1v, yval=Height/3., keep='below')
    25842584    Ncut, third2 = cut_between_ypolygon(buoy1v, yval1=Height/3., yval2=Height*2./3.)
    25852585    Ncut, third3 = cut_ypolygon(buoy1v, yval=Height*2./3., keep='above')
     
    26252625    # painting it
    26262626    # painting it
    2627     Ncut, third1 = cut_ypolygon(buoy1v, yval=Height/3., keep='bottom')
     2627    Ncut, third1 = cut_ypolygon(buoy1v, yval=Height/3., keep='below')
    26282628    Ncut, third2 = cut_between_ypolygon(buoy1v, yval1=Height/3., yval2=Height*2./3.)
    26292629    Ncut, third3 = cut_ypolygon(buoy1v, yval=Height*2./3., keep='above')
     
    26802680    Height = np.max(buoy1v[:,0])
    26812681
    2682     Ncut, third1 = cut_ypolygon(buoy1v, yval=Height/3., keep='bottom')
     2682    Ncut, third1 = cut_ypolygon(buoy1v, yval=Height/3., keep='below')
    26832683    Ncut, third2 = cut_between_ypolygon(buoy1v, yval1=Height/3., yval2=Height*2./3.)
    26842684    Ncut, third3 = cut_ypolygon(buoy1v, yval=Height*2./3., keep='above')
Note: See TracChangeset for help on using the changeset viewer.