Changeset 2577 in lmdz_wrf


Ignore:
Timestamp:
Jun 1, 2019, 8:29:34 PM (6 years ago)
Author:
lfita
Message:

Avoiding point repetition in `buoy1'

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/geometry_tools.py

    r2576 r2577  
    837837                    dy[ic] = polygon[eep,0] - polygon[ip,0]
    838838                    dd = xval - polygon[ip,1]
     839                    print 'Lluis ip', ip, 'poly:', polygon[ip,:], 'xval:', xval, 'ip+1', polygon[eep,:]
     840                    print '  dx:', dx, 'dy:', dy, 'dd', dd
    839841                    ipt[ic,:] = [polygon[ip,0]+dy[ic]*dd/dx[ic], xval]
    840842
     
    861863
    862864    for ic in range(2):
     865        print ic, 'Lluis ipt:', ipt[ic,:], 'ept:', ept[ic,:]
    863866        dx = (ept[ic,1] - ipt[ic,1])/(Nadd2-2)
    864867        dy = (ept[ic,0] - ipt[ic,0])/(Nadd2-2)
     868        print '    dx:', dx, 'dy', dy
    865869        cutlines[ic,0,:] = ipt[ic,:]
    866870        for ip in range(1,Nadd2-1):
     
    18481852    iy = 0.
    18491853    dx = 0.
    1850     dy = height/(Np-1)
     1854    dy = height/(Np)
    18511855    for ip in range(Np):
    18521856        buoy[iip+ip,:] = [iy+dy*ip,ix+dx*ip]
     
    18571861    ix = -width/2.
    18581862    iy = height
    1859     dx = (width/2.-bradii*bfrac)/(Np-1)
     1863    dx = (width/2.-bradii*bfrac)/(Np)
    18601864    dy = 0.
    18611865    for ip in range(Np):
     
    18761880    iy = height
    18771881    Np = N3
    1878     dx = (width/2.-bradii*bfrac)/(Np-1)
     1882    dx = (width/2.-bradii*bfrac)/(Np)
    18791883    dy = 0.
    18801884    for ip in range(Np):
     
    18871891    iy = height
    18881892    dx = 0.
    1889     dy = -height/(Np-1)
     1893    dy = -height/(Np)
    18901894    for ip in range(Np):
    18911895        buoy[iip+ip,:] = [iy+dy*ip,ix+dx*ip]
     
    18961900    ix = width/2.
    18971901    iy = 0.
    1898     Np = N - int(2*N/3) - 4*N3
    1899     dx = -width/(Np-1)
     1902    Np = N - int(2*N/3) - 4*N3 - 1
     1903    dx = -width/(Np)
    19001904    dy = 0.
    19011905    for ip in range(Np):
     
    19031907    NNp = NNp + Np
    19041908    iip = NNp
     1909
     1910    buoy[N-1,:] = buoy[0,:]
    19051911
    19061912    buoysecs = ['base']
     
    26752681    return buoy, buoysecs, buoydic
    26762682
     2683def emergency_buoy1(height=5., width=10., bradii=1.75, bfrac=0.8, hsigns=0.5, N=300):
     2684    """ Function to draw an eergency mark buoy using buoy1
     2685      height: height of the prism (5., default)
     2686      width: width of the prism (10., default)
     2687      bradii: radii of the ball (1.75, default)
     2688      bfrac: fraction of the ball above the prism (0.8, default)
     2689      hisgns: height of the signs [as reg. triangle] as percentage of the height
     2690        (0.5, default)
     2691      N: total number of points of the buoy (300, default)
     2692    """
     2693    fname = 'emergency_buoy1'
     2694
     2695    buoy = np.ones((N,2), dtype=np.float)*gen.fillValueF
     2696
     2697    # buoy
     2698    N2 = int(N/2)
     2699    buoy1v, buoy1vsecs, buoy1vdic = buoy1(height=5., width=10., bradii=1.75,         \
     2700      bfrac=0.8, N=N2)
     2701    buoy[0:N2,:] = buoy1v
     2702
     2703    Height = np.max(buoy1v[:,0])
     2704
     2705    # sign
     2706    N3 = N - N2 - 1
     2707   
     2708    bottsigns = 2.*bradii+height
     2709    lsign = height*hsigns
     2710    # up
     2711    cross, crosssecs, crossdic = p_cross_width(lsign, width=0.2*lsign, Narms=2, N=N3)
     2712    buoy[N2+1:N,:] = cross + [Height+1.1*lsign,0.]
     2713
     2714    # 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')
     2719
     2720    buoy = ma.masked_equal(buoy, gen.fillValueF)
     2721
     2722    buoysecs = ['buoy', 'sign']
     2723    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]}
     2727
     2728    return buoy, buoysecs, buoydic
     2729
    26772730####### ####### ##### #### ### ## #
    26782731# Plotting
Note: See TracChangeset for help on using the changeset viewer.