Index: inundation/geospatial_data/test_geospatial_data.py
===================================================================
--- inundation/geospatial_data/test_geospatial_data.py	(revision 2928)
+++ inundation/geospatial_data/test_geospatial_data.py	(revision 2940)
@@ -52,5 +52,5 @@
         attributes = [2, 4]
         G = Geospatial_data(points, attributes,
-                            geo_reference = Geo_reference(56, 100, 200))
+                            geo_reference=Geo_reference(56, 100, 200))
 
         assert G.geo_reference.zone == 56
@@ -64,11 +64,11 @@
         attributes = [2, 4]
         G = Geospatial_data(points, attributes,
-                            geo_reference = Geo_reference(56, 100, 200))
-
-
-        P = G.get_data_points(absolute = False)
+                            geo_reference=Geo_reference(56, 100, 200))
+
+
+        P = G.get_data_points(absolute=False)
         assert allclose(P, [[1.0, 2.1], [3.0, 5.3]])        
 
-        P = G.get_data_points(absolute = True)
+        P = G.get_data_points(absolute=True)
         assert allclose(P, [[101.0, 202.1], [103.0, 205.3]])        
 
@@ -87,9 +87,9 @@
         attributes = {'a0': [0, 0], 'a1': [2, 4], 'a2': [79.4, -7]}
         G = Geospatial_data(points, attributes,
-                            geo_reference = Geo_reference(56, 100, 200),
-                            default_attribute_name = 'a1')
-
-
-        P = G.get_data_points(absolute = False)
+                            geo_reference=Geo_reference(56, 100, 200),
+                            default_attribute_name='a1')
+
+
+        P = G.get_data_points(absolute=False)
         assert allclose(P, [[1.0, 2.1], [3.0, 5.3]])        
         
@@ -122,6 +122,6 @@
         attributes = {'a0': [0, 0], 'a1': [2, 4], 'a2': [79.4, -7]}
         G = Geospatial_data(points, attributes,
-                            geo_reference = Geo_reference(56, 100, 200),
-                            default_attribute_name = 'a1')
+                            geo_reference=Geo_reference(56, 100, 200),
+                            default_attribute_name='a1')
 
 
@@ -165,5 +165,5 @@
         G = points_dictionary2geospatial_data(points_dict)
 
-        P = G.get_data_points(absolute = False)
+        P = G.get_data_points(absolute=False)
         assert allclose(P, [[1.0, 2.1], [3.0, 5.3]])        
         
@@ -342,11 +342,11 @@
         G1 = Geospatial_data(points, att_dict, geo_ref)
 
-        G1.export_points_file(FN, absolute = True)
+        G1.export_points_file(FN, absolute=True)
 
         #Create object from file
         G = Geospatial_data(file_name = FN)
         
-        assert allclose(G.get_data_points(absolute = True), 
-                        G1.get_data_points(absolute = True))
+        assert allclose(G.get_data_points(absolute=True), 
+                        G1.get_data_points(absolute=True))
         assert allclose(G.get_attributes('att1'), attributes)
         assert allclose(G.get_attributes('att2'), array(attributes) + 1)
@@ -365,10 +365,10 @@
 1.0, 0.0, 10.4, 40.0\n")
         file.close()
-        results = Geospatial_data(fileName, delimiter = ',')
+        results = Geospatial_data(fileName, delimiter=',')
         os.remove(fileName)
 #        print 'data', results.get_data_points()
         assert allclose(results.get_data_points(), [[1.0, 0.0],[0.0, 1.0],[1.0, 0.0]])
-        assert allclose(results.get_attributes(attribute_name = 'elevation'), [10.0, 0.0, 10.4])
-        assert allclose(results.get_attributes(attribute_name = 'speed'), [0.0, 10.0, 40.0])
+        assert allclose(results.get_attributes(attribute_name='elevation'), [10.0, 0.0, 10.4])
+        assert allclose(results.get_attributes(attribute_name='speed'), [0.0, 10.0, 40.0])
 
     def test_loadxya2(self):
@@ -386,11 +386,11 @@
         file.close()
 
-        results = Geospatial_data(fileName, delimiter = ' ')
+        results = Geospatial_data(fileName, delimiter=' ')
 
         os.remove(fileName)
 
         assert allclose(results.get_data_points(), [[1.0, 0.0],[0.0, 1.0],[1.0, 0.0]])
-        assert allclose(results.get_attributes(attribute_name = 'elevation'), [10.0, 0.0, 10.4])
-        assert allclose(results.get_attributes(attribute_name = 'speed'), [0.0, 10.0, 40.0])
+        assert allclose(results.get_attributes(attribute_name='elevation'), [10.0, 0.0, 10.4])
+        assert allclose(results.get_attributes(attribute_name='speed'), [0.0, 10.0, 40.0])
      
     def test_loadxya3(self):
@@ -412,10 +412,10 @@
         file.close()
 
-        results = Geospatial_data(fileName, delimiter = ' ')
-
-        os.remove(fileName)
-        assert allclose(results.get_data_points(absolute = False), [[1.0, 0.0],[0.0, 1.0],[1.0, 0.0]])
-        assert allclose(results.get_attributes(attribute_name = 'elevation'), [10.0, 0.0, 10.4])
-        assert allclose(results.get_attributes(attribute_name = 'speed'), [0.0, 10.0, 40.0])
+        results = Geospatial_data(fileName, delimiter=' ')
+
+        os.remove(fileName)
+        assert allclose(results.get_data_points(absolute=False), [[1.0, 0.0],[0.0, 1.0],[1.0, 0.0]])
+        assert allclose(results.get_attributes(attribute_name='elevation'), [10.0, 0.0, 10.4])
+        assert allclose(results.get_attributes(attribute_name='speed'), [0.0, 10.0, 40.0])
 
     def test_read_write_points_file_bad2(self):
@@ -424,5 +424,5 @@
         att_dict['elevation'] = array([10.0, 0.0, 10.4])
         att_dict['brightness'] = array([10.0, 0.0, 10.4])
-        geo_reference = Geo_reference(56,1.9,1.9)
+        geo_reference=Geo_reference(56,1.9,1.9)
         
         G = Geospatial_data(pointlist, att_dict, geo_reference)
@@ -451,5 +451,5 @@
         #print fileName
         try:
-            results = Geospatial_data(fileName, delimiter = ' ')
+            results = Geospatial_data(fileName, delimiter=' ')
         except IOError:
             pass
@@ -473,5 +473,5 @@
         #print fileName
         try:
-            results = Geospatial_data(fileName, delimiter = ' ')
+            results = Geospatial_data(fileName, delimiter=' ')
         except IOError:
             pass
@@ -495,5 +495,5 @@
         file.close()
         try:
-            results = Geospatial_data(fileName, delimiter = ' ')
+            results = Geospatial_data(fileName, delimiter=' ')
         except IOError:
             pass
@@ -505,8 +505,7 @@
     def test_loadxy_bad4(self):
         """
-        specifying wrong delimiter
+         specifying wrong delimiter
         """
         import os
-       
         fileName = tempfile.mktemp(".xya")
         file = open(fileName,"w")
@@ -515,11 +514,12 @@
 0.0 1.0 0.0 10.0\n\
 1.0 0.0 10.4 40.0\n\
-#geocrap")
+#geo\n\
+56\n\
+1.1\n\
+1.0\n")
+
         file.close()
         try:
-#            dict = import_points_file(fileName,delimiter = ' ')
-#            results = Geospatial_data()
-            results = Geospatial_data(fileName, delimiter = ',')
-#            results.import_points_file(fileName, delimiter = ' ')
+            results = Geospatial_data(fileName, delimiter=',')
         except IOError:
             pass
@@ -528,6 +528,4 @@
             raise msg
 
-#            self.failUnless(0 ==1,
-#                        'bad xya file did not raise error!')    
         os.remove(fileName)
 
@@ -548,8 +546,8 @@
         file.close()
         try:
-#            dict = import_points_file(fileName,delimiter = ' ')
+#            dict = import_points_file(fileName,delimiter=' ')
 #            results = Geospatial_data()
-            results = Geospatial_data(fileName, delimiter = ' ')
-#            results.import_points_file(fileName, delimiter = ' ')
+            results = Geospatial_data(fileName, delimiter=' ', verbose=True)
+#            results.import_points_file(fileName, delimiter=' ')
         except IOError:
             pass
@@ -567,5 +565,5 @@
         fileName = tempfile.mktemp(".xya")
         try:
-            results = Geospatial_data(fileName, delimiter = ' ')
+            results = Geospatial_data(fileName, delimiter=' ')
         except IOError:
             pass
@@ -590,10 +588,10 @@
         att_dict['brightness'] = array([10.0, 0.0, 10.4])
 #        dict['attributelist'] = att_dict
-        geo_reference = Geo_reference(56,1.9,1.9)
+        geo_reference=Geo_reference(56,1.9,1.9)
         
         
         fileName = tempfile.mktemp(".xya")
         G = Geospatial_data(pointlist, att_dict, geo_reference)
-        G.export_points_file(fileName)
+        G.export_points_file(fileName, False)
 
 #        dict2 = import_points_file(fileName)
@@ -603,7 +601,7 @@
         
         assert allclose(results.get_data_points(absolute=False),[[1.0, 0.0],[0.0, 1.0],[1.0, 0.0]])
-        assert allclose(results.get_attributes(attribute_name = 'elevation'), [10.0, 0.0, 10.4])
+        assert allclose(results.get_attributes(attribute_name='elevation'), [10.0, 0.0, 10.4])
         answer = [10.0, 0.0, 10.4]
-        assert allclose(results.get_attributes(attribute_name = 'brightness'), answer)
+        assert allclose(results.get_attributes(attribute_name='brightness'), answer)
         #print "dict2['geo_reference']",dict2['geo_reference'] 
         self.failUnless(results.get_geo_reference() == geo_reference,
@@ -637,5 +635,5 @@
         att_dict['elevation'] = array([10.0, 0.0, 10.4])
         att_dict['brightness'] = array([10.0, 0.0, 10.4])
-        geo_reference = Geo_reference(56,1.9,1.9)
+        geo_reference=Geo_reference(56,1.9,1.9)
         
         
@@ -650,8 +648,8 @@
         assert allclose(results.get_data_points(),
                         [[2.9, 1.9],[1.9, 2.9],[2.9, 1.9]])
-        assert allclose(results.get_attributes(attribute_name = 'elevation'),
+        assert allclose(results.get_attributes(attribute_name='elevation'),
                          [10.0, 0.0, 10.4])
         answer = [10.0, 0.0, 10.4]
-        assert allclose(results.get_attributes(attribute_name = 'brightness'), answer)
+        assert allclose(results.get_attributes(attribute_name='brightness'), answer)
         self.failUnless(results.get_geo_reference() == geo_reference,
                          'test_writepts failed. Test geo_reference')                         
@@ -676,7 +674,7 @@
         
         assert allclose(results.get_data_points(),[[1.0, 0.0],[0.0, 1.0],[1.0, 0.0]])
-        assert allclose(results.get_attributes(attribute_name = 'elevation'), [10.1, 0.0, 10.4])
+        assert allclose(results.get_attributes(attribute_name='elevation'), [10.1, 0.0, 10.4])
         answer = [10.0, 1.0, 10.4]
-        assert allclose(results.get_attributes(attribute_name = 'brightness'), answer)
+        assert allclose(results.get_attributes(attribute_name='brightness'), answer)
 
     def test_new_export_absolute_pts_file(self):
@@ -698,7 +696,7 @@
         
         assert allclose(results.get_data_points(), G.get_data_points(True))
-        assert allclose(results.get_attributes(attribute_name = 'elevation'), [10.1, 0.0, 10.4])
+        assert allclose(results.get_attributes(attribute_name='elevation'), [10.1, 0.0, 10.4])
         answer = [10.0, 1.0, 10.4]
-        assert allclose(results.get_attributes(attribute_name = 'brightness'), answer)
+        assert allclose(results.get_attributes(attribute_name='brightness'), answer)
 
     def test_loadpts(self):
@@ -736,5 +734,5 @@
         answer =  [[1.0, 0.0],[0.0, 1.0],[1.0, 0.0]]
         assert allclose(results.get_data_points(), [[1.0, 0.0],[0.0, 1.0],[1.0, 0.0]])
-        assert allclose(results.get_attributes(attribute_name = 'elevation'), [10.0, 0.0, 10.4])
+        assert allclose(results.get_attributes(attribute_name='elevation'), [10.0, 0.0, 10.4])
         
     def test_writepts(self):
@@ -743,5 +741,5 @@
         att_dict['elevation'] = array([10.0, 0.0, 10.4])
         att_dict['brightness'] = array([10.0, 0.0, 10.4])
-        geo_reference = Geo_reference(56,1.9,1.9)
+        geo_reference=Geo_reference(56,1.9,1.9)
         
         fileName = tempfile.mktemp(".pts")
@@ -749,5 +747,5 @@
         G = Geospatial_data(pointlist, att_dict, geo_reference)
         
-        G.export_points_file(fileName)
+        G.export_points_file(fileName, False)
         
         results = Geospatial_data(file_name = fileName)
@@ -837,5 +835,5 @@
         xll = 0.1
         yll = 20
-        geo_reference = Geo_reference(56, xll, yll)
+        geo_reference=Geo_reference(56, xll, yll)
         geo_reference.write_NetCDF(outfile)
 
@@ -875,6 +873,7 @@
 
         
-    def test_add_points_files(self):
-        '''adds an xya and pts files and checks resulting file is correct
+    def test_add_(self):
+        '''adds an xya and pts files, reads the files and adds them
+           checking results are correct
         '''
 
@@ -882,18 +881,14 @@
         
         # create files
-#        dict1 = {}
         att_dict1 = {}
         pointlist1 = array([[1.0, 0.0],[0.0, 1.0],[1.0, 0.0]])
         att_dict1['elevation'] = array([-10.0, 0.0, 10.4])
         att_dict1['brightness'] = array([10.0, 0.0, 10.4])
-#        dict1['attributelist'] = att_dict1
         geo_reference1 = Geo_reference(56, 2.0, 1.0)
         
-#        dict2 = {}
         att_dict2 = {}
         pointlist2 = array([[2.0, 1.0],[1.0, 2.0],[2.0, 1.0]])
         att_dict2['elevation'] = array([1.0, 15.0, 1.4])
         att_dict2['brightness'] = array([14.0, 1.0, -12.4])
-#        dict2['attributelist'] = att_dict2
         geo_reference2 = Geo_reference(56, 1.0, 2.0) #FIXME (Ole): I changed this, why does it still pass
         #OK - it fails now, after the fix revealed by test_create_from_pts_file_with_geo')
@@ -918,13 +913,16 @@
         
         #read results
-        assert allclose(G.get_data_points(absolute = False),
-                        [[2.0, 0.0],[1.0, 1.0],
-                         [2.0, 0.0],[2.0, 2.0],
-                         [1.0, 3.0],[2.0, 2.0]])
-        assert allclose(G.get_attributes(attribute_name = 'elevation'),
+#        print'res', G.get_data_points()
+#        print'res1', G.get_data_points(False)
+        assert allclose(G.get_data_points(),
+                        [[ 3.0, 1.0], [ 2.0, 2.0],
+                         [ 3.0, 1.0], [ 3.0, 3.0],
+                         [ 2.0, 4.0], [ 3.0, 3.0]])
+                         
+        assert allclose(G.get_attributes(attribute_name='elevation'),
                         [-10.0, 0.0, 10.4, 1.0, 15.0, 1.4])
         
         answer = [10.0, 0.0, 10.4, 14.0, 1.0, -12.4]
-        assert allclose(G.get_attributes(attribute_name = 'brightness'), answer)
+        assert allclose(G.get_attributes(attribute_name='brightness'), answer)
         
         self.failUnless(G.get_geo_reference() == geo_reference1,
@@ -962,5 +960,5 @@
         #print "data_points",data_points     
         new_points = ensure_absolute(data_points,
-                                             geo_reference = mesh_origin)
+                                             geo_reference=mesh_origin)
         #print "new_points",new_points
         #print "ab_points",ab_points
@@ -972,5 +970,5 @@
         data_points = geo.change_points_geo_ref(ab_points)   
         new_points = ensure_absolute(data_points,
-                                             geo_reference = geo)
+                                             geo_reference=geo)
         #print "new_points",new_points
         #print "ab_points",ab_points
@@ -985,5 +983,5 @@
         #print "geo in points", points
         G = Geospatial_data(points, attributes,
-                            geo_reference = geo_reference)
+                            geo_reference=geo_reference)
           
         new_points = ensure_absolute(G)
@@ -1011,7 +1009,7 @@
         results = Geospatial_data(fileName)
         
-        assert allclose(results.get_data_points(absolute = False), [[1.0, 0.0],[0.0, 1.0],[1.0, 0.0]])
-        assert allclose(results.get_attributes(attribute_name = 'elevation'), [10.0, 0.0, 10.4])
-        assert allclose(results.get_attributes(attribute_name = 'speed'), [0.0, 10.0, 40.0])
+        assert allclose(results.get_data_points(absolute=False), [[1.0, 0.0],[0.0, 1.0],[1.0, 0.0]])
+        assert allclose(results.get_attributes(attribute_name='elevation'), [10.0, 0.0, 10.4])
+        assert allclose(results.get_attributes(attribute_name='speed'), [0.0, 10.0, 40.0])
 
         os.remove(fileName)
@@ -1020,5 +1018,5 @@
         
         try:
-            G = Geospatial_data(delimiter = ',')
+            G = Geospatial_data(delimiter=',')
 #            results = Geospatial_data(file_name = fileName)
 #            dict = import_points_file(fileName)
@@ -1042,4 +1040,57 @@
             raise msg        
 
+    def xxx_test_check_geo_reference(self):
+        """
+        checks geo reference details are OK. eg can be called '#geo reference'
+        if not throws a clear error message
+        """
+        import os
+        fileName = tempfile.mktemp(".xya")
+        file = open(fileName,"w")
+        file.write("  elevation  \n\
+1.0 0.0 10.0\n\
+0.0 1.0 0.0\n\
+1.0 0.0 10.4\n\
+#geo reference\n\
+56\n\
+1.1\n\
+1.0\n")
+
+        file.close()
+        results = Geospatial_data(fileName)
+        assert allclose(results.get_geo_reference().get_xllcorner(), 1.1)
+        assert allclose(results.get_geo_reference().get_yllcorner(), 1.0)
+
+    def xxx_test_check_geo_reference1(self):
+        """
+        checks geo reference details are OK. eg can be called '#geo reference'
+        if not throws a clear error message
+        """
+        import os
+        fileName = tempfile.mktemp(".xya")
+        file = open(fileName,"w")
+        file.write("  elevation  \n\
+1.0 0.0 10.0\n\
+0.0 1.0 0.0\n\
+1.0 0.0 10.4\n\
+#geo reference\n\
+56\n\
+1.1\n"
+)
+        file.close()
+
+#        try:
+        results = Geospatial_data(fileName)
+#        except ValueError or SyntaxError:
+#            pass
+#        else:
+#            msg = 'Geo reference data format is incorrect'
+#            raise msg        
+
+
+
+        assert allclose(results.get_geo_reference().get_xllcorner(), 1.1)
+        assert allclose(results.get_geo_reference().get_yllcorner(), 1.0)
+        
 
 
