Index: issm/trunk/src/m/shp/shpread.py
===================================================================
--- issm/trunk/src/m/shp/shpread.py	(revision 25836)
+++ issm/trunk/src/m/shp/shpread.py	(revision 27035)
@@ -1,2 +1,3 @@
+import numpy as np
 from collections import OrderedDict
 from os import path
@@ -12,10 +13,10 @@
     """SHPREAD - read a shapefile and build a list of shapes
 
-    This routine reads a shapefile and builds a list of OrderedDict objects 
-    containing the fields x and y corresponding to the coordinates, one for the 
-    filename of the shp file, for the density, for the nodes, and a field 
-    closed to indicate if the domain is closed. If this initial shapefile is 
-    point only, the fields closed and points are ommitted. The first argument 
-    is the shapefile to be read and the second argument (optional) indicates if 
+    This routine reads a shapefile and builds a list of OrderedDict objects
+    containing the fields x and y corresponding to the coordinates, one for the
+    filename of the shp file, for the density, for the nodes, and a field
+    closed to indicate if the domain is closed. If this initial shapefile is
+    point only, the fields closed and points are ommitted. The first argument
+    is the shapefile to be read and the second argument (optional) indicates if
     the last point shall be read (1 to read it, 0 not to).
 
@@ -26,7 +27,7 @@
 
     Example:
-        From underling PyShp implementation, "The shapefile format is actually 
-        a collection of three files. You specify the base filename of the 
-        shapefile or the complete filename of any of the shapefile component 
+        From underling PyShp implementation, "The shapefile format is actually
+        a collection of three files. You specify the base filename of the
+        shapefile or the complete filename of any of the shapefile component
         files."
 
@@ -37,7 +38,7 @@
         list = shpread('domainoutline')
 
-        "OR any of the other 5+ formats which are potentially part of a 
-        shapefile. The library does not care about file extensions". We do, 
-        however, check that a file with the base filename or base filename with 
+        "OR any of the other 5+ formats which are potentially part of a
+        shapefile. The library does not care about file extensions". We do,
+        however, check that a file with the base filename or base filename with
         .shp extension exists.
 
@@ -46,13 +47,13 @@
 
     NOTE:
-    - OrderedDict objects are used instead of OrderedStruct objects (although 
-    addressing in the latter case is closer to the MATLAB struct type) in order 
+    - OrderedDict objects are used instead of OrderedStruct objects (although
+    addressing in the latter case is closer to the MATLAB struct type) in order
     to remain consistent with the pattern established by src/m/exp/expread.py.
 
     TODO:
-    - Create class that can be used to store and pretty print shape structs 
+    - Create class that can be used to store and pretty print shape structs
     (ala OrderedStruct from src/m/qmu/helpers.py).
-    - Convert returned data structure from list of OrderedDict objects to list 
-    of OrderedStruct objects and remove corresponding note (see also 
+    - Convert returned data structure from list of OrderedDict objects to list
+    of OrderedStruct objects and remove corresponding note (see also
     src/m/exp/expread.py). Also, modify handling of returned data structure in,
         - src/m/classes/basin.py
@@ -76,7 +77,6 @@
     Structs = []
     shapes = sf.shapes()
-    for i in range(len(shapes)):
+    for i, shape in enumerate(shapes):
         Struct = OrderedDict()
-        shape = shapes[i]
         if shape.shapeType == shapefile.POINT:
             Struct['x'] = shape.points[0][0]
@@ -88,6 +88,5 @@
             x = []
             y = []
-            for j in range(num_points):
-                point = shape.points[j]
+            for j, point in enumerate(shape.points):
                 x.append(point[0])
                 y.append(point[1])
@@ -103,6 +102,5 @@
             x = []
             y = []
-            for j in range(num_points):
-                point = shape.points[j]
+            for j, point in enumerate(shape.points):
                 x.append(point[0])
                 y.append(point[1])
@@ -115,8 +113,8 @@
             Struct['Geometry'] = 'Polygon'
         else:
-            # NOTE: We could do this once before looping over shapes as all 
-            #       shapes in the file must be of the same type, but we would 
-            #       need to have a second check anyway in order to know how to 
-            #       parse the points. So, let's just assume the file is not 
+            # NOTE: We could do this once before looping over shapes as all
+            #       shapes in the file must be of the same type, but we would
+            #       need to have a second check anyway in order to know how to
+            #       parse the points. So, let's just assume the file is not
             #       malformed.
             #
@@ -125,11 +123,11 @@
         name = ''
         fields = sf.fields
-        for j in range(1, len(fields)): # skip over first field, which is "DeletionFlag"
+        for j in range(1, len(fields)):  # skip over first field, which is "DeletionFlag"
             fieldname = fields[j][0]
             # 'id' field gets special treatment
-            if fieldname == 'id':
-                name = str(sf.record(i)[j - 1]) # record index is offset by one, again, because of "DeletionFlag"
+            if fieldname in ['id', 'fid']:
+                name = str(sf.record(i)[j - 1])  # record index is offset by one, again, because of "DeletionFlag"
             else:
-                setattr(Struct, str(fieldname), sf.record(i)[j - 1]) # cast to string removes "u" from "u'fieldname'"
+                setattr(Struct, str(fieldname), sf.record(i)[j - 1])  # cast to string removes "u" from "u'fieldname'"
         Struct['name'] = name
         Structs.append(Struct)
