Changeset 19421


Ignore:
Timestamp:
07/03/15 00:41:51 (10 years ago)
Author:
cborstad
Message:

CHG:Python: adding expdisp module; updating expwrite so that a dict is passed rather than a list of dicts to fix a bug with multiple contours/polygons/lines in a shapefile

Location:
issm/trunk-jpl/src/m/exp
Files:
1 added
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/m/exp/expwrite.py

    r17898 r19421  
    33def expwrite(contours,filename):
    44        """
    5         EXPWRITE - write an Argus file from a structure given in input
     5        EXPWRITE - write an Argus file from a dictionary given in input
    66
    7            This routine writes an Argus file from a list of dict's containing the fields:
     7           This routine writes an Argus file from a dict containing the fields:
    88           x and y of the coordinates of the points.
    99           The first argument is the list containing the points coordinates
     
    2020
    2121        fid=open(filename,'w')
    22         for contour in contours:
    23                 if numpy.size(contour['x'])!=numpy.size(contour['y']):
     22        for x,y in zip(contours['x'],contours['y']):
     23                #if numpy.size(contour['x'])!=numpy.size(contour['y']):
     24                if len(x)!=len(y):
    2425                        raise RuntimeError("contours x and y coordinates must be of identical size")
    25    
    26                 if 'name' in contour:
     26                if 'name' in contours:
    2727                        fid.write("%s%s\n" % ('## Name:',contour['name']))
    2828                else:
    2929                        fid.write("%s%s\n" % ('## Name:',filename))
    3030   
    31                 #Add density if it's not there
    32                 if 'density' not in contour:
    33                         contour['density']=1
     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
    3435
    3536                fid.write("%s\n" % '## Icon:0')
    3637                fid.write("%s\n" % '# Points Count Value')
    37                 fid.write("%i %f\n" % (numpy.size(contour['x']),contour['density']))
     38                #fid.write("%i %f\n" % (numpy.size(contour['x']),contour['density']))
     39                fid.write("%i %f\n" % (numpy.size(x),density))
    3840                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                #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))
    4144                fid.write("\n")
    4245
Note: See TracChangeset for help on using the changeset viewer.