- Timestamp:
- 06/07/17 10:50:54 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/branches/trunk-larour-NatGeoScience2016/src/m/exp/expcoarsen.py
r17480 r21759 1 1 import os.path 2 import numpy as npy2 import numpy as np 3 3 from collections import OrderedDict 4 4 from expread import expread … … 34 34 for contour in contours: 35 35 36 numpoints=np y.size(contour['x'])36 numpoints=np.size(contour['x']) 37 37 38 38 j=0 … … 44 44 45 45 #see whether we keep this point or not 46 distance=np y.sqrt((x[j]-x[j+1])**2+(y[j]-y[j+1])**2)46 distance=np.sqrt((x[j]-x[j+1])**2+(y[j]-y[j+1])**2) 47 47 if distance<resolution and j<numpoints-2: #do not remove last point 48 x=np y.delete(x,j+1,0)49 y=np y.delete(y,j+1,0)48 x=np.delete(x,j+1,0) 49 y=np.delete(y,j+1,0) 50 50 numpoints=numpoints-1 51 51 else: 52 division=int(np y.floor(distance/resolution)+1)52 division=int(np.floor(distance/resolution)+1) 53 53 if division>=2: 54 xi=np y.linspace(x[j],x[j+1],division)55 yi=np y.linspace(y[j],y[j+1],division)54 xi=np.linspace(x[j],x[j+1],division) 55 yi=np.linspace(y[j],y[j+1],division) 56 56 57 x=np y.hstack((x[0:j+1],xi[1:-1],x[j+1:]))58 y=np y.hstack((y[0:j+1],yi[1:-1],y[j+1:]))57 x=np.hstack((x[0:j+1],xi[1:-1],x[j+1:])) 58 y=np.hstack((y[0:j+1],yi[1:-1],y[j+1:])) 59 59 60 60 #update current point … … 65 65 j=j+1 66 66 67 if np y.size(x)>1:67 if np.size(x)>1: 68 68 #keep the (x,y) contour arond 69 69 newcontour=OrderedDict() 70 newcontour['nods']=np y.size(x)70 newcontour['nods']=np.size(x) 71 71 newcontour['density']=contour['density'] 72 72 newcontour['x']=x
Note:
See TracChangeset
for help on using the changeset viewer.