Changeset 2563 in lmdz_wrf for trunk/tools


Ignore:
Timestamp:
May 29, 2019, 9:50:46 PM (6 years ago)
Author:
lfita
Message:

Adding:

  • `cut_xpolygon': Function to cut a polygon from a given value of the x-axis

New rule:

  • All objects must start from SW extreme
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/geometry_tools.py

    r2560 r2563  
    609609        print errormsg
    610610        print '  ' + fname + ': no cutting for polygon at y=', yval, '!!'
    611 
    612     print 'Lluis icut', icut, 'ipt:', ipt, 'ecut', ecut, 'ept:', ept, 'N', N
    613     print 'Lluis 00', polygon[0:7,:]
    614     print 'Lluis NN', polygon[ecut+1:N,:]
    615611
    616612    if keep == 'left':
     
    15161512    return island1, islandsecs, islanddic
    15171513
    1518 def buoy1(height=5., width=10., bradii=1.75, bfrac=0.8, N=200):
     1514def buoy1(height=5., width=10., bradii=1.75, bfrac=0.8, N=300):
    15191515    """ Function to draw a buoy as superposition of prism and section of ball
    15201516      height: height of the prism (5., default)
     
    15221518      bradii: radii of the ball (1.75, default)
    15231519      bfrac: fraction of the ball above the prism (0.8, default)
    1524       N: total number of points of the buoy (200, default)
     1520      N: total number of points of the buoy (300, default)
    15251521    """
    15261522    fname = 'buoy1'
     
    15281524    buoy = np.zeros((N,2), dtype=np.float)
    15291525
     1526    N3 = int(N/3/5)
    15301527    NNp = 0
    15311528    iip = 0
    1532     # Base
    1533     ix = width/2.
    1534     iy = 0.
    1535     Np = 4
    1536     dx = -width/(Np-1)
    1537     dy = 0.
    1538     for ip in range(Np):
    1539         buoy[iip+ip,:] = [iy+dy*ip,ix+dx*ip]
    1540     NNp = NNp + Np
    1541     iip = NNp
    1542 
    15431529    # left lateral
    15441530    ix = -width/2.
     1531    Np = N3
    15451532    iy = 0.
    1546     Np = 2
    15471533    dx = 0.
    15481534    dy = height/(Np-1)
     
    15551541    ix = -width/2.
    15561542    iy = height
    1557     Np = 4
    15581543    dx = (width/2.-bradii*bfrac)/(Np-1)
    15591544    dy = 0.
     
    15661551    p1 = np.array([height, -bradii*bfrac])
    15671552    p2 = np.array([height, bradii*bfrac])
    1568     Np = N - 2*(NNp)
     1553    Np = int(2*N/3)
    15691554    buoy[iip:iip+Np,:] = circ_sec(p1, p2, 2.*bradii, 'long', 'left', Np)
    15701555    NNp = NNp + Np
     
    15741559    ix = bradii*bfrac
    15751560    iy = height
    1576     Np = 4
     1561    Np = N3
    15771562    dx = (width/2.-bradii*bfrac)/(Np-1)
    15781563    dy = 0.
     
    15851570    ix = width/2.
    15861571    iy = height
    1587     Np = 2
    15881572    dx = 0.
    15891573    dy = -height/(Np-1)
     1574    for ip in range(Np):
     1575        buoy[iip+ip,:] = [iy+dy*ip,ix+dx*ip]
     1576    NNp = NNp + Np
     1577    iip = NNp
     1578
     1579    # Base
     1580    ix = width/2.
     1581    iy = 0.
     1582    Np = N - int(2*N/3) - 4*N3
     1583    dx = -width/(Np-1)
     1584    dy = 0.
    15901585    for ip in range(Np):
    15911586        buoy[iip+ip,:] = [iy+dy*ip,ix+dx*ip]
Note: See TracChangeset for help on using the changeset viewer.