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
RevLine 
[21341]1import numpy as np
[13341]2
3def expwrite(contours,filename):
4 """
[20500]5 EXPWRITE - write an Argus file from a dictionary given in input
[13341]6
[20500]7 This routine writes an Argus file from a dict containing the fields:
[13341]8 x and y of the coordinates of the points.
[17989]9 The first argument is the list containing the points coordinates
10 and the second one the file to be written.
[13341]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')
[20500]22 for x,y in zip(contours['x'],contours['y']):
[21341]23 #if np.size(contour['x'])!=np.size(contour['y']):
[20500]24 if len(x)!=len(y):
[13341]25 raise RuntimeError("contours x and y coordinates must be of identical size")
[20500]26 if 'name' in contours:
27 fid.write("%s%s\n" % ('## Name:',contours['name']))
[13341]28 else:
[14310]29 fid.write("%s%s\n" % ('## Name:',filename))
[13341]30
[20500]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
[14310]35
[13341]36 fid.write("%s\n" % '## Icon:0')
37 fid.write("%s\n" % '# Points Count Value')
[21341]38 #fid.write("%i %f\n" % (np.size(contour['x']),contour['density']))
39 fid.write("%i %f\n" % (np.size(x),density))
[13341]40 fid.write("%s\n" % '# X pos Y pos')
[20500]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))
[13341]44 fid.write("\n")
45
46 fid.close()
47
Note: See TracBrowser for help on using the repository browser.