Changeset 2578 in lmdz_wrf for trunk/tools/geometry_tools.py


Ignore:
Timestamp:
Jun 1, 2019, 9:03:10 PM (5 years ago)
Author:
lfita
Message:

Adding 'emergency_buoy' ...

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/geometry_tools.py

    r2577 r2578  
    813813                    if eep == N: eep = 0
    814814     
    815                     if polygon[ip,1] <= xval and polygon[eep,1] >= xval:
     815                    if (polygon[ip,1] <= xval and polygon[eep,1] > xval) or          \
     816                      (polygon[ip,1] < xval and polygon[eep,1] >= xval):
    816817                        icut[ic] = ip
    817818                        dx[ic] = polygon[eep,1] - polygon[ip,1]
     
    820821                        ipt[ic,:] = [polygon[ip,0]+dy[ic]*dd/dx[ic], xval]
    821822
    822                     if polygon[ip,1] >= yval and polygon[eep,1] <= xval:
     823                    if (polygon[ip,1] >= yval and polygon[eep,1] < xval) or          \
     824                      (polygon[ip,1] > yval and polygon[eep,1] <= xval):
    823825                        ecut[ic] = ip
    824826                        dx[ic] = polygon[eep,1] - polygon[ip,1]
     
    832834                if eep == N: eep = 0
    833835     
    834                 if polygon[ip,1] <= xval and polygon[eep,1] >= xval:
     836                if (polygon[ip,1] <= xval and polygon[eep,1] > xval) or              \
     837                  (polygon[ip,1] < xval and polygon[eep,1] >= xval):
    835838                    icut[ic] = ip
    836839                    dx[ic] = polygon[eep,1] - polygon[ip,1]
     
    841844                    ipt[ic,:] = [polygon[ip,0]+dy[ic]*dd/dx[ic], xval]
    842845
    843                 if polygon[ip,1] >= xval and polygon[eep,1] <= xval:
     846                if (polygon[ip,1] >= xval and polygon[eep,1] < xval) or              \
     847                  (polygon[ip,1] > xval and polygon[eep,1] <= xval):
    844848                    ecut[ic] = ip
    845849                    dx[ic] = polygon[eep,1] - polygon[ip,1]
    846850                    dy[ic] = polygon[eep,0] - polygon[ip,0]
    847851                    dd = xval - polygon[ip,1]
    848                     ept[ic,:] = [polygon[ip,0]+dy[ic]*dd/dx[ic], xval]
     852                    if dx[ic] == 0.:
     853                        ept[ic,:] = [polygon[eep,0], xval]
     854                    else:
     855                        ept[ic,:] = [polygon[ip,0]+dy[ic]*dd/dx[ic], xval]
    849856
    850857        if ipt is None or ept is None:
     
    26682675    lsign = height*hsigns
    26692676    # up
    2670     cross, crosssecs, crossdic = p_cross_width(lsign, width=0.2*lsign, Narms=2, N=N3)
     2677    cross, crosssecs, crossdic = p_cross_width(lsign, width=0.3*lsign, Narms=2, N=N3)
    26712678    cross = rotate_polygon_2D(cross, 40.05)
    26722679    buoy[N2+1:N,:] = cross + [Height+1.1*lsign,0.]
     
    27092716    lsign = height*hsigns
    27102717    # up
    2711     cross, crosssecs, crossdic = p_cross_width(lsign, width=0.2*lsign, Narms=2, N=N3)
     2718    cross, crosssecs, crossdic = p_cross_width(lsign, width=0.3*lsign, Narms=2, N=N3)
    27122719    buoy[N2+1:N,:] = cross + [Height+1.1*lsign,0.]
    27132720
    27142721    # painting it
    2715     Ncut, quart1 = cut_xpolygon(buoy1v, xval=width/4., keep='left')
    2716     Ncut, quart2 = cut_between_xpolygon(buoy1v, xval1=width/4., xval2=width/2)
    2717     Ncut, quart3 = cut_between_xpolygon(buoy1v, xval1=width/2., xval2=width*3./4.)
    2718     Ncut, quart4 = cut_xpolygon(buoy1v, xval=width*3./4., keep='right')
     2722    ix = -width/2.
     2723    Ncut, fifth1 = cut_xpolygon(buoy1v, xval=ix+width/5., keep='left')
     2724    Ncut, fifth2 = cut_between_xpolygon(buoy1v,xval1=ix+width/5.,xval2=ix+width*2./5.)
     2725    Ncut, fifth3 = cut_between_xpolygon(buoy1v,xval1=ix+width*2./5.,xval2=ix+width*3./5.)
     2726    Ncut, fifth4 = cut_between_xpolygon(buoy1v,xval1=ix+width*3./5.,xval2=ix+width*4./5.)
     2727    Ncut, fifth5 = cut_xpolygon(buoy1v, xval=ix+width*4./5., keep='right')
    27192728
    27202729    buoy = ma.masked_equal(buoy, gen.fillValueF)
    27212730
    2722     buoysecs = ['buoy', 'sign']
     2731    buoysecs = ['buoy', 'sign', 'fifth1', 'fifth2', 'fifth3', 'fifth4', 'fifth5']
    27232732    buoydic = {'buoy': [buoy[0:N2,:],'-','#FFFF00',1.5],                             \
    2724       'sign': [buoy[N2+1:N,:],'-','#FFFF00',1.5],'quart1':[quart1,'-','#0000FF',1.5],\
    2725       'quart2': [quart2,'-','#FFFF00',1.5],'quart3': [quart3,'-','#0000FF',1.5],     \
    2726       'quart4': [quart4,'-','#FFFF00',1.5]}
     2733      'sign': [buoy[N2+1:N,:],'-','#FFFF00',1.5],'fifth1':[fifth1,'-','#FFFF00',1.5],\
     2734      'fifth2': [fifth2,'-','#FFFF00',1.5],'fifth3': [fifth3,'-','#0000FF',1.5],     \
     2735      'fifth4': [fifth4,'-','#FFFF00',1.5],'fifth5': [fifth5,'-','#0000FF',1.5]}
    27272736
    27282737    return buoy, buoysecs, buoydic
Note: See TracChangeset for help on using the changeset viewer.