Index: inundation/geospatial_data/test_geospatial_data.py
===================================================================
--- inundation/geospatial_data/test_geospatial_data.py	(revision 2890)
+++ inundation/geospatial_data/test_geospatial_data.py	(revision 2928)
@@ -365,11 +365,10 @@
 1.0, 0.0, 10.4, 40.0\n")
         file.close()
-        #print fileName
-        dict = import_points_file(fileName,delimiter = ',')
-        dict = import_points_file(fileName,delimiter = ',')
-        os.remove(fileName)
-        assert allclose(dict['pointlist'], [[1.0, 0.0],[0.0, 1.0],[1.0, 0.0]])
-        assert allclose(dict['attributelist']['elevation'], [10.0, 0.0, 10.4])
-        assert allclose(dict['attributelist']['speed'], [0.0, 10.0, 40.0])
+        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])
 
     def test_loadxya2(self):
@@ -386,11 +385,12 @@
 1.0 0.0 10.4 40.0\n")
         file.close()
-        #print fileName
-#        dict = import_points_file(fileName,delimiter = ' ')
-        dict = import_points_file(fileName,delimiter = ' ')
-        os.remove(fileName)
-        assert allclose(dict['pointlist'], [[1.0, 0.0],[0.0, 1.0],[1.0, 0.0]])
-        assert allclose(dict['attributelist']['elevation'], [10.0, 0.0, 10.4])
-        assert allclose(dict['attributelist']['speed'], [0.0, 10.0, 40.0])
+
+        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])
      
     def test_loadxya3(self):
@@ -411,31 +411,17 @@
 3\n")
         file.close()
-        #print fileName
-        dict = import_points_file(fileName,delimiter = ' ')
-        os.remove(fileName)
-        assert allclose(dict['pointlist'], [[1.0, 0.0],[0.0, 1.0],[1.0, 0.0]])
-        assert allclose(dict['attributelist']['elevation'], [10.0, 0.0, 10.4])
-        assert allclose(dict['attributelist']['speed'], [0.0, 10.0, 40.0])
-
-    def test_loadxy_bad_no_file_xya(self):
-        import os
-       
-        fileName = tempfile.mktemp(".xya")
-        #print fileName
-        try:
-            dict = import_points_file(fileName,delimiter = ' ')
-        except IOError:
-            pass
-        else:
-            self.failUnless(0 ==1,
-                        'imaginary file did not raise error!')
-  
+
+        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):
-#        dict = {}
         att_dict = {}
         pointlist = array([[1.0, 0.0],[0.0, 1.0],[1.0, 0.0]])
         att_dict['elevation'] = array([10.0, 0.0, 10.4])
         att_dict['brightness'] = array([10.0, 0.0, 10.4])
-#        dict['attributelist'] = att_dict
         geo_reference = Geo_reference(56,1.9,1.9)
         
@@ -448,6 +434,8 @@
             pass
         else:
-            self.failUnless(0 == 1,
-                        'bad points file extension did not raise error!')
+            msg = 'bad points file extension did not raise error!'
+            raise msg
+#            self.failUnless(0 == 1,
+#                        'bad points file extension did not raise error!')
                    
     def test_loadxy_bad(self):
@@ -463,10 +451,12 @@
         #print fileName
         try:
-            dict = import_points_file(fileName,delimiter = ' ')
+            results = Geospatial_data(fileName, delimiter = ' ')
         except IOError:
             pass
         else:
-            self.failUnless(0 ==1,
-                        'bad xya file did not raise error!')
+            msg = 'bad xya file did not raise error!'
+            raise msg
+#            self.failUnless(0 == 1,
+#                        'bad xya file did not raise error!')
         os.remove(fileName)
        
@@ -483,10 +473,10 @@
         #print fileName
         try:
-            dict = import_points_file(fileName,delimiter = ' ')
+            results = Geospatial_data(fileName, delimiter = ' ')
         except IOError:
             pass
         else:
-            self.failUnless(0 ==1,
-                        'bad xya file did not raise error!')    
+            msg = 'bad xya file did not raise error!'
+            raise msg
         os.remove(fileName)
    
@@ -505,35 +495,12 @@
         file.close()
         try:
-            dict = import_points_file(fileName,delimiter = ' ')
+            results = Geospatial_data(fileName, delimiter = ' ')
         except IOError:
             pass
         else:
-            self.failUnless(0 ==1,
-                        'bad xya file did not raise error!')    
+            msg = 'bad xya file did not raise error!'
+            raise msg
         os.remove(fileName)
      
-    def test_loadxy_bad4(self):
-        """
-        specifying wrong delimiter
-        """
-        import os
-       
-        fileName = tempfile.mktemp(".xya")
-        file = open(fileName,"w")
-        file.write("  elevation   speed \n\
-1.0 0.0 10.0 0.0\n\
-0.0 1.0 0.0 10.0\n\
-1.0 0.0 10.4 40.0\n\
-yeah")
-        file.close()
-        try:
-            dict = import_points_file(fileName,delimiter = ' ')
-        except IOError:
-            pass
-        else:
-            self.failUnless(0 ==1,
-                        'bad xya file did not raise error!')    
-        os.remove(fileName)
-  
     def test_loadxy_bad4(self):
         """
@@ -551,10 +518,16 @@
         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 = ' ')
         except IOError:
             pass
         else:
-            self.failUnless(0 ==1,
-                        'bad xya file did not raise error!')    
+            msg = 'bad xya file did not raise error!'
+            raise msg
+
+#            self.failUnless(0 ==1,
+#                        'bad xya file did not raise error!')    
         os.remove(fileName)
 
@@ -575,10 +548,16 @@
         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 = ' ')
         except IOError:
             pass
         else:
-            self.failUnless(0 ==1,
-                        'bad xya file did not raise error!')    
+            msg = 'bad xya file did not raise error!'
+            raise msg
+
+#            self.failUnless(0 ==1,
+#                        'bad xya file did not raise error!')    
         os.remove(fileName)              
 
@@ -587,12 +566,18 @@
        
         fileName = tempfile.mktemp(".xya")
-        #print fileName
         try:
-            dict = import_points_file(fileName,delimiter = ' ')
+            results = Geospatial_data(fileName, delimiter = ' ')
         except IOError:
             pass
         else:
-            self.failUnless(0 ==1,
-                        'imaginary file did not raise error!')
+            msg = 'imaginary file did not raise error!'
+            raise msg
+
+#        except IOError:
+#            pass
+#        else:
+#            self.failUnless(0 == 1,
+#                        'imaginary file did not raise error!')
+
                         
   ###################### .XYA ##############################
@@ -611,18 +596,21 @@
         G = Geospatial_data(pointlist, att_dict, geo_reference)
         G.export_points_file(fileName)
-        dict2 = import_points_file(fileName)
+
+#        dict2 = import_points_file(fileName)
+        results = Geospatial_data(file_name = fileName)
         #print "fileName",fileName 
         os.remove(fileName)
-        #print "dict2",dict2 
-        
-        assert allclose(dict2['pointlist'],[[1.0, 0.0],[0.0, 1.0],[1.0, 0.0]])
-        assert allclose(dict2['attributelist']['elevation'], [10.0, 0.0, 10.4])
+        
+        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])
         answer = [10.0, 0.0, 10.4]
-        assert allclose(dict2['attributelist']['brightness'], answer)
+        assert allclose(results.get_attributes(attribute_name = 'brightness'), answer)
         #print "dict2['geo_reference']",dict2['geo_reference'] 
-        self.failUnless(geo_reference == dict2['geo_reference'],
+        self.failUnless(results.get_geo_reference() == geo_reference,
                          'test_writepts failed. Test geo_reference')
 
     def test_export_xya_file2(self):
+        """test absolute xya file
+        """
         att_dict = {}
         pointlist = array([[1.0, 0.0],[0.0, 1.0],[1.0, 0.0]])
@@ -633,13 +621,16 @@
         G = Geospatial_data(pointlist, att_dict)
         G.export_points_file(fileName)
-        dict2 = import_points_file(fileName)
-        os.remove(fileName)
-        
-        assert allclose(dict2['pointlist'],[[1.0, 0.0],[0.0, 1.0],[1.0, 0.0]])
-        assert allclose(dict2['attributelist']['elevation'], [10.0, 0.0, 10.4])
+        results = Geospatial_data(file_name = fileName)
+#        dict2 = import_points_file(fileName)
+        os.remove(fileName)
+        
+        assert allclose(results.get_data_points(False),[[1.0, 0.0],[0.0, 1.0],[1.0, 0.0]])
+        assert allclose(results.get_attributes('elevation'), [10.0, 0.0, 10.4])
         answer = [10.0, 0.0, 10.4]
-        assert allclose(dict2['attributelist']['brightness'], answer)
-
-    def test_export_xya_file2(self):
+        assert allclose(results.get_attributes('brightness'), answer)
+
+    def test_export_xya_file3(self):
+        """test absolute xya file with geo_ref
+        """
         att_dict = {}
         pointlist = array([[1.0, 0.0],[0.0, 1.0],[1.0, 0.0]])
@@ -651,19 +642,21 @@
         fileName = tempfile.mktemp(".xya")
         G = Geospatial_data(pointlist, att_dict, geo_reference)
+        
         G.export_points_file(fileName, absolute=True)
-        dict2 = import_points_file(fileName)
-        #print "fileName",fileName 
-        os.remove(fileName)
-        #print "dict2",dict2 
-        
-#        assert allclose(dict2['pointlist'],[[1.0, 0.0],[0.0, 1.0],[1.0, 0.0]])
-        assert allclose(dict2['pointlist'],[[2.9, 1.9],[1.9, 2.9],[2.9, 1.9]])
-        assert allclose(dict2['attributelist']['elevation'], [10.0, 0.0, 10.4])
+        
+        results = Geospatial_data(file_name = fileName)
+        os.remove(fileName)
+
+        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'),
+                         [10.0, 0.0, 10.4])
         answer = [10.0, 0.0, 10.4]
-        assert allclose(dict2['attributelist']['brightness'], answer)
-#        print "dict2['geo_reference']",dict2['geo_reference'] 
-        self.failUnless(None == dict2['geo_reference'],
-                         'test_writepts failed. Test geo_reference')
-
+        assert allclose(results.get_attributes(attribute_name = 'brightness'), answer)
+        self.failUnless(results.get_geo_reference() == geo_reference,
+                         'test_writepts failed. Test geo_reference')                         
+                        
+                        
+                        
     def test_new_export_pts_file(self):
         att_dict = {}
@@ -678,12 +671,12 @@
         G.export_points_file(fileName)
 
-        dict2 = import_points_file(fileName)
-
-        os.remove(fileName)
-        
-        assert allclose(dict2['pointlist'],[[1.0, 0.0],[0.0, 1.0],[1.0, 0.0]])
-        assert allclose(dict2['attributelist']['elevation'], [10.1, 0.0, 10.4])
+        results = Geospatial_data(file_name = fileName)
+
+        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.1, 0.0, 10.4])
         answer = [10.0, 1.0, 10.4]
-        assert allclose(dict2['attributelist']['brightness'], answer)
+        assert allclose(results.get_attributes(attribute_name = 'brightness'), answer)
 
     def test_new_export_absolute_pts_file(self):
@@ -700,13 +693,12 @@
         G.export_points_file(fileName, absolute=True)
 
-        dict2 = import_points_file(fileName)
-
-        os.remove(fileName)
-        
-#        assert allclose(dict2['pointlist'],[[1.0, 0.0],[0.0, 1.0],[1.0, 0.0]])
-        assert allclose(dict2['pointlist'],G.get_data_points(True))
-        assert allclose(dict2['attributelist']['elevation'], [10.1, 0.0, 10.4])
+        results = Geospatial_data(file_name = fileName)
+
+        os.remove(fileName)
+        
+        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])
         answer = [10.0, 1.0, 10.4]
-        assert allclose(dict2['attributelist']['brightness'], answer)
+        assert allclose(results.get_attributes(attribute_name = 'brightness'), answer)
 
     def test_loadpts(self):
@@ -740,19 +732,15 @@
         outfile.close()
         
-        dict = import_points_file(fileName)
+        results = Geospatial_data(file_name = fileName)
         os.remove(fileName)
         answer =  [[1.0, 0.0],[0.0, 1.0],[1.0, 0.0]]
-        #print "dict['pointlist']",dict['pointlist']
-        #print "answer",answer
-        assert allclose(dict['pointlist'], [[1.0, 0.0],[0.0, 1.0],[1.0, 0.0]])
-        assert allclose(dict['attributelist']['elevation'], [10.0, 0.0, 10.4])
+        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])
         
     def test_writepts(self):
-#        dict = {}
         att_dict = {}
         pointlist = array([[1.0, 0.0],[0.0, 1.0],[1.0, 0.0]])
         att_dict['elevation'] = array([10.0, 0.0, 10.4])
         att_dict['brightness'] = array([10.0, 0.0, 10.4])
-#        dict['attributelist'] = att_dict
         geo_reference = Geo_reference(56,1.9,1.9)
         
@@ -763,17 +751,15 @@
         G.export_points_file(fileName)
         
-        dict2 = import_points_file(fileName)
-
-        os.remove(fileName)
-
-        assert allclose(dict2['pointlist'],[[1.0, 0.0],[0.0, 1.0],[1.0, 0.0]])
-        assert allclose(dict2['attributelist']['elevation'], [10.0, 0.0, 10.4])
+        results = Geospatial_data(file_name = fileName)
+
+        os.remove(fileName)
+
+        assert allclose(results.get_data_points(False),[[1.0, 0.0],[0.0, 1.0],[1.0, 0.0]])
+        assert allclose(results.get_attributes('elevation'), [10.0, 0.0, 10.4])
         answer = [10.0, 0.0, 10.4]
-        assert allclose(dict2['attributelist']['brightness'], answer)
-
-        #print "dict['geo_reference'] ",dict['geo_reference'] 
-        #print "dict2['geo_reference']",dict2['geo_reference']
-        
-        self.failUnless(geo_reference == dict2['geo_reference'],
+        assert allclose(results.get_attributes('brightness'), answer)
+
+        
+        self.failUnless(geo_reference == geo_reference,
                          'test_writepts failed. Test geo_reference')
         
@@ -787,10 +773,13 @@
         #print fileName
         try:
-            dict = import_points_file(fileName)
+            results = Geospatial_data(file_name = fileName)
+#            dict = import_points_file(fileName)
         except IOError:
             pass
         else:
-            self.failUnless(0 ==1,
-                        'imaginary file did not raise error!')
+            msg = 'imaginary file did not raise error!'
+            raise msg
+#            self.failUnless(0 == 1,
+#                        'imaginary file did not raise error!')
 
 
@@ -916,39 +905,33 @@
         fileName2 = tempfile.mktemp(".pts")
 
-#        G1.export_points_file(fileName1)
-#        G2.export_points_file(fileName2)
-        
-        results_file = 'resulting_points.pts'
+        #makes files
+        G1.export_points_file(fileName1)
+        G2.export_points_file(fileName2)
         
         # add files
         
-        G = G1 + G2
-        
-        G.export_points_file(results_file)
-#        add_points_files(fileName1, fileName2, results_file )
+        G3 = Geospatial_data(file_name = fileName1)
+        G4 = Geospatial_data(file_name = fileName2)
+        
+        G = G3 + G4
+
         
         #read results
-        results_dict = import_points_file(results_file)
-#        print 'results points:', results_dict['pointlist']
-#        print 'results geo_ref:', results_dict['geo_reference']
-        
-        assert allclose(results_dict['pointlist'],
+        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(results_dict['attributelist']['elevation'],
+        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(results_dict['attributelist']['brightness'], answer)
-        
-        self.failUnless(results_dict['geo_reference'] == geo_reference1,
+        assert allclose(G.get_attributes(attribute_name = 'brightness'), answer)
+        
+        self.failUnless(G.get_geo_reference() == geo_reference1,
                          'test_writepts failed. Test geo_reference')
                          
-#        os.remove(fileName1)
-#        os.remove(fileName2)
-        os.remove(results_file)
-
-    
+        os.remove(fileName1)
+        os.remove(fileName2)
+        
     def test_ensure_absolute(self):
         points = [[2.0, 0.0],[1.0, 1.0],
@@ -1010,4 +993,55 @@
         assert allclose(new_points, ab_points)
         
+    def test_isinstance(self):
+
+        import os
+       
+        fileName = tempfile.mktemp(".xya")
+        file = open(fileName,"w")
+        file.write("  elevation   speed \n\
+1.0 0.0 10.0 0.0\n\
+0.0 1.0 0.0 10.0\n\
+1.0 0.0 10.4 40.0\n\
+#geocrap\n\
+56\n\
+56.6\n\
+3\n")
+        file.close()
+
+        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])
+
+        os.remove(fileName)
+        
+    def test_delimiter(self):
+        
+        try:
+            G = Geospatial_data(delimiter = ',')
+#            results = Geospatial_data(file_name = fileName)
+#            dict = import_points_file(fileName)
+        except ValueError:
+            pass
+        else:
+            msg = 'Instance with No fileName but has a delimiter\
+                  did not raise error!'
+            raise msg
+
+    def test_no_constructors(self):
+        
+        try:
+            G = Geospatial_data()
+#            results = Geospatial_data(file_name = fileName)
+#            dict = import_points_file(fileName)
+        except ValueError:
+            pass
+        else:
+            msg = 'Instance must have a filename or data points'
+            raise msg        
+
+
+
 if __name__ == "__main__":
     #suite = unittest.makeSuite(Test_Geospatial_data, 'test_ensure_absolute')
