Changeset 2565 in lmdz_wrf


Ignore:
Timestamp:
May 29, 2019, 10:20:10 PM (6 years ago)
Author:
lfita
Message:

Adding:

  • `safewater_buoy1': Function to draw a safe water mark buoy using buoy1
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/geometry_tools.py

    r2564 r2565  
    6161# p_triangle: Function to provide the polygon of a triangle from its 3 vertices
    6262# band_lighthouse: Function to plot a lighthouse with spiral bands
     63# safewater_buoy1: Function to draw a safe water mark buoy using buoy1
    6364# surface_sphere: Function to provide an sphere as matrix of x,y,z coordinates
    6465# z_boat: Function to define an schematic boat from the z-plane
     
    20702071    return buoy, buoysecs, buoydic
    20712072
     2073def safewater_buoy1(height=5., width=10., bradii=1.75, bfrac=0.8, hsigns=0.3, N=300):
     2074    """ Function to draw a safe water mark buoy using buoy1
     2075      height: height of the prism (5., default)
     2076      width: width of the prism (10., default)
     2077      bradii: radii of the ball (1.75, default)
     2078      bfrac: fraction of the ball above the prism (0.8, default)
     2079      hisgns: height of the signs [as reg. triangle] as percentage of the height
     2080        (0.3, default)
     2081      N: total number of points of the buoy (300, default)
     2082    """
     2083    fname = 'safewater_buoy1'
     2084
     2085    buoy = np.ones((N,2), dtype=np.float)*gen.fillValueF
     2086
     2087    # buoy
     2088    N2 = int(N/2)
     2089    buoy1v, buoy1vsecs, buoy1vdic = buoy1(height=5., width=10., bradii=1.75,         \
     2090      bfrac=0.8, N=N2)
     2091    buoy[0:N2,:] = buoy1v
     2092
     2093    # signs
     2094    N3 = N - N2 - 1
     2095    lsign = height*hsigns
     2096   
     2097    Height = np.max(buoy1v[:,0])
     2098    sign = p_circle(lsign, N3)
     2099    buoy[N2+1:N2+2+N3,:] = sign + [Height+1.2*lsign,0.]
     2100
     2101    # painting it
     2102    ix = -width/2.
     2103    Ncut, quarter1 = cut_xpolygon(buoy1v, xval=ix+width/4., keep='left')
     2104    Ncut, quarter2 = cut_between_xpolygon(buoy1v, xval1=ix+width/4., xval2=ix+width/2.)
     2105    Ncut, quarter3 = cut_between_xpolygon(buoy1v, xval1=ix+width/2., xval2=ix+3.*width/4.)
     2106    Ncut, quarter4 = cut_xpolygon(buoy1v, xval=ix+3.*width/4., keep='right')
     2107
     2108    buoy = ma.masked_equal(buoy, gen.fillValueF)
     2109
     2110    buoysecs = ['buoy', 'sign', 'quarter1', 'quarter2', 'quarter3', 'quarter4']
     2111    buoydic = {'buoy': [buoy[0:N2,:],'-','k',1.5],                                   \
     2112      'sign': [buoy[N2+1:N2+N3+1,:],'-','r',1.5], 'quarter1': [quarter1,'-','r',1.], \
     2113      'quarter2': [quarter2,'-','#FFFFFF',1.], 'quarter3': [quarter3,'-','r',1.],    \
     2114      'quarter4': [quarter4,'-','#FFFFFF',1.]}
     2115
     2116    return buoy, buoysecs, buoydic
     2117
    20722118####### ####### ##### #### ### ## #
    20732119# Plotting
Note: See TracChangeset for help on using the changeset viewer.