Changeset 13341
- Timestamp:
- 09/12/12 11:20:47 (13 years ago)
- Location:
- issm/trunk-jpl/src/m/exp
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/m/exp/expread.py
r13338 r13341 16 16 17 17 Usage: 18 Struct=expread(filename)18 contours=expread(filename) 19 19 20 20 Example: 21 Struct=expread('domainoutline.exp')22 Struct=expread('domainoutline.exp')21 contours=expread('domainoutline.exp') 22 contours=expread('domainoutline.exp') 23 23 24 24 See also EXPDOC, EXPWRITEASVERTICES … … 30 30 31 31 #initialize number of profile 32 Structs=[]32 contours=[] 33 33 34 34 #open file … … 39 39 40 40 #update number of profiles 41 Struct=OrderedDict()41 contour=OrderedDict() 42 42 43 43 #Get file name … … 51 51 break 52 52 if len(A[1])>5: 53 Struct['name']=A[1][5:-1]53 contour['name']=A[1][5:-1] 54 54 else: 55 Struct['name']=''55 contour['name']='' 56 56 57 57 #Get Icon … … 67 67 #Get number of nodes and density 68 68 A=fid.readline().split() 69 Struct['nods'] =float(A[0])70 Struct['density']=float(A[1])69 contour['nods'] =float(A[0]) 70 contour['density']=float(A[1]) 71 71 72 72 #Get Info … … 77 77 78 78 #Get Coordinates 79 Struct['x']=numpy.empty(Struct['nods'])80 Struct['y']=numpy.empty(Struct['nods'])81 for i in xrange(int( Struct['nods'])):79 contour['x']=numpy.empty(contour['nods']) 80 contour['y']=numpy.empty(contour['nods']) 81 for i in xrange(int(contour['nods'])): 82 82 A=fid.readline().split() 83 Struct['x'][i]=float(A[0]) 84 Struct['y'][i]=float(A[1]) 85 86 # if(Struct['nods']~=length(Struct['x']))error(['Profile ' num2str ' reports incorrect length']); end; 83 contour['x'][i]=float(A[0]) 84 contour['y'][i]=float(A[1]) 87 85 88 86 #Check if closed 89 if ( Struct['nods'] > 1) and \90 ( Struct['x'][-1] == Struct['x'][0]) and \91 ( Struct['y'][-1] == Struct['y'][0]):92 Struct['closed']=True87 if (contour['nods'] > 1) and \ 88 (contour['x'][-1] == contour['x'][0]) and \ 89 (contour['y'][-1] == contour['y'][0]): 90 contour['closed']=True 93 91 else: 94 Struct['closed']=False92 contour['closed']=False 95 93 96 Structs.append(Struct)94 contours.append(contour) 97 95 98 96 #close file 99 97 fid.close() 100 98 101 return Structs99 return contours 102 100 -
issm/trunk-jpl/src/m/exp/expwrite.m
r13021 r13341 21 21 end 22 22 23 24 25 26 27 28 29 30 31 23 if isfield(a,'name'), 24 if ~isempty(a(n).name), 25 fprintf(fid,'%s%s\n','## Name:',a(n).name); 26 else 27 fprintf(fid,'%s\n','## Name:'); 28 end 29 else 30 fprintf(fid,'%s\n','## Name:'); 31 end 32 32 33 34 35 36 33 fprintf(fid,'%s\n','## Icon:0'); 34 fprintf(fid,'%s\n','# Points Count Value'); 35 fprintf(fid,'%i %f\n',[length(a(n).x) a(n).density]); 36 fprintf(fid,'%s\n','# X pos Y pos'); 37 37 fprintf(fid,'%10.10f %10.10f\n',[a(n).x a(n).y]'); 38 fprintf(fid,'\n' ,'');39 38 fprintf(fid,'\n'); 39 40 40 end 41 41 fclose(fid);
Note:
See TracChangeset
for help on using the changeset viewer.