source: issm/trunk/src/m/exp/expwrite.py@ 21341

Last change on this file since 21341 was 21341, checked in by Mathieu Morlighem, 8 years ago

merged trunk-jpl and trunk for revision 21337

File size: 1.4 KB
Line 
1import numpy as np
2
3def expwrite(contours,filename):
4 """
5 EXPWRITE - write an Argus file from a dictionary given in input
6
7 This routine writes an Argus file from a dict containing the fields:
8 x and y of the coordinates of the points.
9 The first argument is the list containing the points coordinates
10 and the second one the file to be written.
11
12 Usage:
13 expwrite(contours,filename)
14
15 Example:
16 expwrite(coordstruct,'domainoutline.exp')
17
18 See also EXPDOC, EXPREAD, EXPWRITEASVERTICES
19 """
20
21 fid=open(filename,'w')
22 for x,y in zip(contours['x'],contours['y']):
23 #if np.size(contour['x'])!=np.size(contour['y']):
24 if len(x)!=len(y):
25 raise RuntimeError("contours x and y coordinates must be of identical size")
26 if 'name' in contours:
27 fid.write("%s%s\n" % ('## Name:',contours['name']))
28 else:
29 fid.write("%s%s\n" % ('## Name:',filename))
30
31 #Add density if it's not there FIXME what is this ever used for?
32 #if 'density' not in contours:
33 # contours['density']=1
34 density=1
35
36 fid.write("%s\n" % '## Icon:0')
37 fid.write("%s\n" % '# Points Count Value')
38 #fid.write("%i %f\n" % (np.size(contour['x']),contour['density']))
39 fid.write("%i %f\n" % (np.size(x),density))
40 fid.write("%s\n" % '# X pos Y pos')
41 #for x,y in zip(contour['x'],contour['y']):
42 for xi,yi in zip(x,y):
43 fid.write("%10.10f %10.10f\n" % (xi,yi))
44 fid.write("\n")
45
46 fid.close()
47
Note: See TracBrowser for help on using the repository browser.