[13341] | 1 | import numpy
|
---|
| 2 |
|
---|
| 3 | def expwrite(contours,filename):
|
---|
| 4 | """
|
---|
| 5 | EXPWRITE - write an Argus file from a structure given in input
|
---|
| 6 |
|
---|
| 7 | This routine write an Argus file form a structure containing the fields:
|
---|
| 8 | x and y of the coordinates of the points.
|
---|
| 9 | The first argument is the structure containing the points coordinates
|
---|
| 10 | and the second one the file to be write.
|
---|
| 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 contour in contours:
|
---|
| 23 | if numpy.size(contour['x'])!=numpy.size(contour['y']):
|
---|
| 24 | raise RuntimeError("contours x and y coordinates must be of identical size")
|
---|
| 25 |
|
---|
| 26 | if 'name' in contour:
|
---|
[14310] | 27 | fid.write("%s%s\n" % ('## Name:',contour['name']))
|
---|
[13341] | 28 | else:
|
---|
[14310] | 29 | fid.write("%s%s\n" % ('## Name:',filename))
|
---|
[13341] | 30 |
|
---|
[14310] | 31 | #Add density if it's not there
|
---|
| 32 | if 'density' not in contour:
|
---|
| 33 | contour['density']=1
|
---|
| 34 |
|
---|
[13341] | 35 | fid.write("%s\n" % '## Icon:0')
|
---|
| 36 | fid.write("%s\n" % '# Points Count Value')
|
---|
| 37 | fid.write("%i %f\n" % (numpy.size(contour['x']),contour['density']))
|
---|
| 38 | fid.write("%s\n" % '# X pos Y pos')
|
---|
| 39 | for x,y in zip(contour['x'],contour['y']):
|
---|
| 40 | fid.write("%10.10f %10.10f\n" % (x,y))
|
---|
| 41 | fid.write("\n")
|
---|
| 42 |
|
---|
| 43 | fid.close()
|
---|
| 44 |
|
---|