Changeset 2622 in lmdz_wrf for trunk


Ignore:
Timestamp:
Jun 22, 2019, 8:45:35 PM (5 years ago)
Author:
lfita
Message:

Adding:

  • `mod_vec': Function to compute the module of a vector
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/geometry_tools.py

    r2617 r2622  
    3333# max_coords_poly: Function to provide the extremes of the coordinates of a polygon
    3434# mirror_polygon: Function to reflex a polygon for a given axis
     35# mod_vec: Function to compute the module of a vector
    3536# position_sphere: Function to tranform fom a point in lon, lat deg coordinates to
    3637#   cartesian coordinates over an sphere
     
    267268
    268269    return dist
     270
     271def mod_vec(vec):
     272    """ Function to compute the module of a vector
     273      vec: vector [y, x]
     274    >>> mod_vec([1., 1.])
     275    1.41421356237
     276    """
     277    fname = 'mod_vec'
     278
     279    mod = np.sqrt(vec[0]*vec[0] + vec[1]*vec[1])
     280
     281    return mod
     282
     283print mod_vec([1., 1.])
     284quit()
     285
     286def angle_vectors2D(veca, vecb):
     287    """ Angle between two vectors
     288      veca: angle A [ya, xa]
     289      vecb: angle B [yb, xb]
     290      NOTE: angle from A to B
     291    >>> angle_vectors2D([1.,0.], [0.,1.])
     292   
     293    """
     294    fname = 'angle_vectors2D'
     295
     296    moda = mod_vec(veca)
     297    modb = mod_vec(vecb)
     298
     299    return alpha
    269300
    270301def max_coords_poly(polygon):
     
    15231554    >>> plgs = {'sqra': polya, 'sqrb': polyb}
    15241555    >>> pile_polygons(pns, plgs)
    1525 
     1556    [[-0.75 -0.5 ]
     1557     [ 0.75 -0.5 ]
     1558     [ 0.75  0.5 ]
     1559     [-0.75  0.5 ]]
    15261560    """
    15271561    fname = 'pile_polygons'
     
    15371571        poly = polygons[polyn]
    15381572        Npts = poly.shape[0]
    1539         print ' LLuis shapes ipoly', ipoly.shape, 'poly', poly.shape
    15401573        Nint, inti, intp, pts = fsci.module_scientific.crossingpoints_polys(         \
    15411574          nvertexa=iNpts, nvertexb=Npts, nvertexab=iNpts*Npts, polya=ipoly,          \
    15421575          polyb=poly)
    1543         print Nint
    1544         for ip in range(Nint):
    1545             print ip, ':', inti[ip], intp[ip], '=', pts[ip]
     1576        iip=0
     1577        for ip in Nint:
     1578            newipoly = ipoly[iip:inti]
     1579       
    15461580       
    15471581    return pilepolygons
    1548 
    1549 #pns = ['sqra', 'sqrb']
    1550 #polya = np.array([[-0.5, -0.75], [0.5, -0.75], [0.5, 0.75], [-0.5, 0.75]])
    1551 #polyb = np.array([[-0.75, -0.5], [0.75, -0.5], [0.75, 0.5], [-0.75, 0.5]])
    1552 #plgs = {'sqra': polya, 'sqrb': polyb}
    1553 #pile_polygons(pns, plgs)
    1554 
    1555 
    15561582
    15571583####### ###### ##### #### ### ## #
Note: See TracChangeset for help on using the changeset viewer.