Changeset 2609 in lmdz_wrf
- Timestamp:
- Jun 17, 2019, 11:42:22 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/geometry_tools.py
r2608 r2609 23 23 24 24 ####### Contents: 25 # add_secpolygon_list: Function to add a range of points of a polygon into a list 25 26 # cut_between_[x/y]polygon: Function to cut a polygon between 2 given value of the [x/y]-axis 26 27 # cut_[x/y]polygon: Function to cut a polygon from a given value of the [x/y]-axis … … 35 36 # cartesian coordinates over an sphere 36 37 # read_join_poly: Function to read an ASCII file with the combination of polygons 38 # rm_consecpt_polygon: Function to remove consecutive same point of a polygon 37 39 # rotate_2D: Function to rotate a vector by a certain angle in the plain 38 40 # rotate_polygon_2D: Function to rotate 2D plain the vertices of a polygon … … 483 485 484 486 return 487 488 def rm_consecpt_polygon(polygon): 489 """ Function to remove consecutive same point of a polygon 490 poly: polygon 491 >>> poly = np.ones((5,2), dtype=np.float) 492 >>> poly[2,:] = [2., 1.] 493 rm_consecpt_polygon(poly) 494 [[ 1. 1.] 495 [ 2. 1.] 496 [ 1. 1.]] 497 """ 498 fname = 'rm_consecpt_polygon' 499 500 newpolygon = [] 501 prevpt = polygon[0,:] 502 newpolygon.append(prevpt) 503 for ip in range(1,polygon.shape[0]-1): 504 if polygon[ip,0] != prevpt[0] or polygon[ip,1] != prevpt[1]: 505 prevpt = polygon[ip,:] 506 newpolygon.append(prevpt) 507 508 newpolygon = np.array(newpolygon) 509 510 return newpolygon 485 511 486 512 def cut_ypolygon(polygon, yval, keep='below', Nadd=20): … … 961 987 rmpolygon.append(cutpolygon[ip,:]) 962 988 Npts = len(rmpolygon) 963 cutpolygon = np.array(rmpolygon) 989 990 rmpolygon = np.array(rmpolygon) 991 cutpolygon = rm_consecpt_polygon(rmpolygon) 964 992 965 993 cutpolygon = ma.masked_equal(cutpolygon, gen.fillValueF)
Note: See TracChangeset
for help on using the changeset viewer.