Changeset 2570 in lmdz_wrf for trunk


Ignore:
Timestamp:
May 29, 2019, 11:06:08 PM (6 years ago)
Author:
lfita
Message:

Adding:

  • `isolateddanger_buoy1': Function to draw an isolated danger buoy using buoy1
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/geometry_tools.py

    r2569 r2570  
    5151# ellipse_polar: Function to determine an ellipse from its center and polar coordinates
    5252# green_buoy1: Function to draw a green mark buoy using buoy1
     53# isolateddanger_buoy1: Function to draw an isolated danger buoy using buoy1
    5354# p_angle_triangle: Function to draw a triangle by an initial point and two
    5455#   consecutive angles and the first length of face. The third angle and 2 and 3rd
     
    24092410    return buoy, buoysecs, buoydic
    24102411
     2412def isolateddanger_buoy1(height=5., width=10., bradii=1.75, bfrac=0.8, hsigns=0.5,   \
     2413  N=300):
     2414    """ Function to draw an isolated danger buoy using buoy1
     2415      height: height of the prism (5., default)
     2416      width: width of the prism (10., default)
     2417      bradii: radii of the ball (1.75, default)
     2418      bfrac: fraction of the ball above the prism (0.8, default)
     2419      hisgns: height of the signs [as reg. triangle] as percentage of the height
     2420        (0.5, default)
     2421      N: total number of points of the buoy (300, default)
     2422    """
     2423    fname = 'isolateddanger_buoy1'
     2424
     2425    buoy = np.ones((N,2), dtype=np.float)*gen.fillValueF
     2426
     2427    # buoy
     2428    N2 = int(N/2)
     2429    buoy1v, buoy1vsecs, buoy1vdic = buoy1(height=5., width=10., bradii=1.75,         \
     2430      bfrac=0.8, N=N2)
     2431    buoy[0:N2,:] = buoy1v
     2432
     2433    # signs
     2434    N3 = N - N2 - 2
     2435   
     2436    bottsigns = 2.*bradii+height
     2437    lsign = height*hsigns
     2438    # up
     2439    N32 = int(N3/2)
     2440    circle = p_circle(lsign/2., N=N32)
     2441    trib = circle + [0.,0.]
     2442
     2443    buoy[N2+1:N2+1+N32,:] = trib + [bottsigns+3.2*lsign,0.]
     2444
     2445    # up
     2446    N323 = N - N32 - N2 - 2
     2447    trid = p_circle(lsign/2., N=N32)
     2448    trib = circle + [0.,0.]
     2449    buoy[N2+N32+2:N,:] = trib + [bottsigns+2.*lsign,0.]
     2450
     2451    # painting it
     2452    Height = np.max(buoy1v[:,0])
     2453
     2454    Ncut, third1 = cut_ypolygon(buoy1v, yval=Height/3., keep='bottom')
     2455    Ncut, third2 = cut_between_ypolygon(buoy1v, yval1=Height/3., yval2=Height*2./3.)
     2456    Ncut, third3 = cut_ypolygon(buoy1v, yval=Height*2./3., keep='above')
     2457
     2458    buoy = ma.masked_equal(buoy, gen.fillValueF)
     2459
     2460    buoysecs = ['buoy', 'sign1', 'sign2', 'halfk', 'halfy']
     2461    buoydic = {'buoy': [buoy[0:N2,:],'-','k',1.5],                                   \
     2462      'sign1': [buoy[N2+1:N2+N32+1,:],'-','k',1.5],                                  \
     2463      'sign2': [buoy[N2+N32+2:N,:],'-','k',1.5], 'third1': [third1, '-', 'k', 1.],   \
     2464      'third2': [third2, '-', 'r', 1.], 'third3': [third3, '-', 'k', 1.]}
     2465
     2466    return buoy, buoysecs, buoydic
     2467
    24112468####### ####### ##### #### ### ## #
    24122469# Plotting
Note: See TracChangeset for help on using the changeset viewer.