Changeset 2506 in lmdz_wrf for trunk/tools


Ignore:
Timestamp:
May 4, 2019, 4:35:35 PM (6 years ago)
Author:
lfita
Message:

Adding:

  • `join_circ_sec': Function to join aa series of points by circular segments
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/geometry_tools.py

    r2496 r2506  
    2323# deg_deci: Function to pass from degrees [deg, minute, sec] to decimal angles [rad]
    2424# dist_points: Function to provide the distance between two points
     25# join_circ_sec: Function to join aa series of points by circular segments
    2526# max_coords_poly: Function to provide the extremes of the coordinates of a polygon
    2627# mirror_polygon: Function to reflex a polygon for a given axis
     
    285286
    286287    return reflex
     288
     289def join_circ_sec(points, radfrac=3., N=200):
     290    """ Function to join aa series of points by circular segments
     291      points: main points of the island (clockwise ordered, to be joined by circular
     292        segments of radii as the radfrac factor of the distance between
     293        consecutive points)
     294      radfrac: multiplicative factor of the distance between consecutive points to
     295        draw the circular segment (3., default)
     296      N: number of points (200, default)
     297    """
     298    fname = 'join_circ_sec'
     299
     300    jcirc_sec = np.ones((N,2), dtype=np.float)
     301
     302    # main points
     303    lpoints = list(points)
     304    Npts = len(lpoints)
     305    Np = int(N/(Npts+1))
     306    for ip in range(Npts-1):
     307        dps = dist_points(lpoints[ip], lpoints[ip+1])
     308        jcirc_sec[Np*ip:Np*(ip+1),:] = circ_sec(lpoints[ip], lpoints[ip+1],          \
     309          dps*radfrac, Np)
     310
     311    Np2 = N - (Npts-1)*Np
     312    dps = dist_points(lpoints[Npts-1], lpoints[0])
     313    jcirc_sec[(Npts-1)*Np:N,:] = circ_sec(lpoints[Npts-1], lpoints[0], dps*3., Np2)
     314
     315    return jcirc_sec
    287316
    288317####### ###### ##### #### ### ## #
     
    910939    # Coastline
    911940   
    912     # main points
    913     lmainpts = list(mainpts)
    914     Npts = len(lmainpts)
    915     Np = int(N/(Npts+1))
    916     for ip in range(Npts-1):
    917         dps = dist_points(lmainpts[ip], lmainpts[ip+1])
    918         island1[Np*ip:Np*(ip+1),:] = circ_sec(lmainpts[ip], mainpts[ip+1],          \
    919           dps*radfrac, Np)
    920 
    921     Np2 = N - (Npts-1)*Np
    922     dps = dist_points(lmainpts[Npts-1], lmainpts[0])
    923     island1[(Npts-1)*Np:N,:] = circ_sec(lmainpts[Npts-1], lmainpts[0], dps*3., Np2)
     941    island1 = join_circ_sec(mainpts, radfrac=3., N=200)
    924942
    925943    islandsecs = ['coastline']
Note: See TracChangeset for help on using the changeset viewer.