Index: anuga_core/source/anuga/abstract_2d_finite_volumes/quantity.py
===================================================================
--- anuga_core/source/anuga/abstract_2d_finite_volumes/quantity.py	(revision 4127)
+++ anuga_core/source/anuga/abstract_2d_finite_volumes/quantity.py	(revision 4129)
@@ -692,4 +692,5 @@
         #print kwargs
 
+        #FIXME(dsg):Why is this catched? fit_to_mesh handles caching.
         if use_cache is True:
             try:
@@ -734,53 +735,6 @@
         assert type(filename) == StringType, msg
 
-
-        # Read from (NetCDF) file
-        # FIXME (Ole): This function should really return a
-        # Geospatial_data object.
         geospatial_data = Geospatial_data(filename)
         
-        #points_dict = import_points_file(filename)
-        #points_dict['pointlist'] = None
-        #points_dict['attributelist'] = None
-        #points = points_dict['pointlist']
-        #attributes = points_dict['attributelist']
-
-
-        #Take care of georeferencing
-        # this doesn't do anything....
-        #if points_dict.has_key('geo_reference') and \
-        #       points_dict['geo_reference'] is not None:
-        #    data_georef = points_dict['geo_reference']
-        #else:
-        #    data_georef = None
-            
-        # if there is no attribute name, use the 1st key?
-        # This isn't so good..., if there is more than 1 key
-        # since it will not always be the 1 column
-        # or anything predictable...        
-
-        #if attribute_name is None:
-        #    names = attributes.keys()
-        #    attribute_name = names[0]
-
-        #msg = 'Attribute_name must be a text string'
-        #assert type(attribute_name) == StringType, msg
-
-
-        #if verbose:
-        #    print 'Using attribute %s from file %s' %(attribute_name, filename)
-        #    print 'Available attributes: %s' %(names)
-
-        #try:
-        #    z = attributes[attribute_name]
-        #except:
-        #    msg = 'Could not extract attribute %s from file %s'\
-        #          %(attribute_name, filename)
-        #    raise msg
-        
-        #Call underlying method for geospatial data
-        #geospatial_data = points_dictionary2geospatial_data(points_dict)
-        # geospatial_data.set_default_attribute_name(attribute_name)
-
         self.set_values_from_geospatial_data(geospatial_data,
                                              alpha,
Index: anuga_core/source/anuga/fit_interpolate/benchmark_least_squares.py
===================================================================
--- anuga_core/source/anuga/fit_interpolate/benchmark_least_squares.py	(revision 4127)
+++ anuga_core/source/anuga/fit_interpolate/benchmark_least_squares.py	(revision 4129)
@@ -49,5 +49,13 @@
 
 class BenchmarkLeastSquares:
-
+"""
+"""
+
+"""
+
+Note(DSG-DSG): If you are interested in benchmarking fitting, before
+and after blocking O:\1\dgray\before_blocking_subsandpit is before blocking
+
+"""
 
     def __init__(self):
Index: anuga_core/source/anuga/fit_interpolate/fit.py
===================================================================
--- anuga_core/source/anuga/fit_interpolate/fit.py	(revision 4127)
+++ anuga_core/source/anuga/fit_interpolate/fit.py	(revision 4129)
@@ -23,6 +23,7 @@
    * (DSG-) Change the interface of fit, so a domain object can
       be passed in. (I don't know if this is feasible). If could
-      save time.
+      save time/memory.
 """
+import types
 
 from Numeric import zeros, Float, ArrayType,take 
@@ -300,7 +301,8 @@
     
         
-    def fit(self, point_coordinates=None, z=None,
-                              verbose = False,
-                              point_origin = None):
+    def fit(self, point_coordinates_or_filename=None, z=None,
+            verbose=False,
+            point_origin=None,
+            max_read_lines=500):
         """Fit a smooth surface to given 1d array of data points z.
 
@@ -315,4 +317,19 @@
           
         """
+
+        # use blocking to load in the point info
+        if type(point_coordinates_or_filename) == types.StringType:
+            filename = point_coordinates_or_filename
+            for geo_block in  Geospatial_data(filename,
+                                              max_read_lines=max_read_lines,
+                                              load_file_now=False):
+                # build the array
+                points = geo_block.get_data_points(absolute=True)
+                z = geo_block.get_attributes()
+                self.build_fit_subset(points, z)
+            point_coordinates = None
+        else:
+            point_coordinates =  point_coordinates_or_filename
+            
         if point_coordinates is None:
             assert self.AtA <> None
@@ -320,6 +337,4 @@
             #FIXME (DSG) - do  a message
         else:
-            # This is where build fit subset can be looped over,
-            # if a file name is passed in.
             point_coordinates = ensure_absolute(point_coordinates,
                                                 geo_reference=point_origin)
@@ -400,6 +415,6 @@
 def fit_to_mesh(vertex_coordinates,
                 triangles,
-                point_coordinates,
-                point_attributes,
+                point_coordinates=None,
+                point_attributes=None,
                 alpha = DEFAULT_ALPHA,
                 verbose = False,
Index: anuga_core/source/anuga/fit_interpolate/test_fit.py
===================================================================
--- anuga_core/source/anuga/fit_interpolate/test_fit.py	(revision 4127)
+++ anuga_core/source/anuga/fit_interpolate/test_fit.py	(revision 4129)
@@ -5,4 +5,5 @@
 import unittest
 from math import sqrt
+import tempfile
 
 from Numeric import zeros, take, compress, Float, Int, dot, concatenate, \
@@ -199,4 +200,44 @@
         assert allclose(f, answer)
 
+        # test fit 2 mesh as well.
+    def test_fit_file_blocking(self):
+
+        a = [-1.0, 0.0]
+        b = [3.0, 4.0]
+        c = [4.0,1.0]
+        d = [-3.0, 2.0] #3
+        e = [-1.0,-2.0]
+        f = [1.0, -2.0] #5
+
+        vertices = [a, b, c, d,e,f]
+        triangles = [[0,1,3], [1,0,2], [0,4,5], [0,5,2]] #abd bac aef afc
+
+        interp = Fit(vertices, triangles,
+                                alpha=0.0)
+
+
+        fileName = tempfile.mktemp(".ddd")
+        file = open(fileName,"w")
+        file.write(" x,y, elevation \n\
+-2.0, 2.0, 0.\n\
+-1.0, 1.0, 0.\n\
+0.0, 2.0 , 2.\n\
+1.0, 1.0 , 2.\n\
+ 2.0,  1.0 ,3. \n\
+ 0.0,  0.0 , 0.\n\
+ 1.0,  0.0 , 1.\n\
+ 0.0,  -1.0, -1.\n\
+ -0.2, -0.5, -0.7\n\
+ -0.9, -1.5, -2.4\n\
+ 0.5,  -1.9, -1.4\n\
+ 3.0,  1.0 , 4.\n")
+        file.close()
+        
+        f = interp.fit(fileName, max_read_lines=2)
+        answer = linear_function(vertices)
+        #print "f\n",f
+        #print "answer\n",answer
+        assert allclose(f, answer)
+        
     def test_fit_and_interpolation(self):
 
Index: anuga_core/source/anuga/geospatial_data/geospatial_data.py
===================================================================
--- anuga_core/source/anuga/geospatial_data/geospatial_data.py	(revision 4127)
+++ anuga_core/source/anuga/geospatial_data/geospatial_data.py	(revision 4129)
@@ -29,5 +29,6 @@
                  longitudes=None,
                  points_are_lats_longs=False,
-                 max_read_lines=None,                 
+                 max_read_lines=None,
+                 load_file_now=True,
                  verbose=False):
 
@@ -105,4 +106,7 @@
             
         verbose:
+
+        load_file_now: if load file now is true, the file is
+        loaded during instanciation.
           
         """
@@ -134,5 +138,5 @@
             self.set_default_attribute_name(default_attribute_name)
 
-        else:
+        elif load_file_now is True:
             # watch for case where file name and points,
             # attributes etc are provided!!
@@ -145,6 +149,7 @@
             self.set_default_attribute_name(default_attribute_name)
 
-
-        assert self.attributes is None or isinstance(self.attributes, DictType)
+        #Why?    
+        #assert self.attributes is None or isinstance(self.attributes, DictType)
+        #This is a hassle when blocking, so I've removed it.
         
 
@@ -539,5 +544,5 @@
                 raise IOError, msg  
         
-        elif file_name[-4:]== ".xxx":
+        elif file_name[-4:]== ".txt" or file_name[-4:]== ".csv":
             #let's do ticket#116 stuff
             #
@@ -677,4 +682,6 @@
 
         #FIXME - what to do if the file isn't there
+
+        #FIXME - give warning if the file format is .xya
         file_pointer = open(self.file_name)
         self.header, self.file_pointer = _read_csv_file_header(file_pointer)
@@ -771,5 +778,5 @@
                 file_pointer,
                 header,
-                max_read_lines=5000) #FIXME: how hacky is that!
+                max_read_lines=MAX_READ_LINES) #FIXME: how hacky is that!
         except StopIteration:
             break
@@ -792,5 +799,5 @@
 def _read_csv_file_blocking(file_pointer, header,
                             delimiter=CSV_DELIMITER,
-                            max_read_lines=500,
+                            max_read_lines=MAX_READ_LINES,
                             verbose=False):
     
@@ -805,4 +812,5 @@
 
     #This is to remove the x and y headers.
+    header = header[:]
     header.pop(0)
     header.pop(0)
@@ -1136,5 +1144,5 @@
          
 if __name__ == "__main__":
-    g = Geospatial_data("t.xxx")
+    g = Geospatial_data("t.txt")
     print "g.get_data_points()", g.get_data_points()
     for i,a in enumerate(g):
Index: anuga_core/source/anuga/geospatial_data/test_geospatial_data.py
===================================================================
--- anuga_core/source/anuga/geospatial_data/test_geospatial_data.py	(revision 4127)
+++ anuga_core/source/anuga/geospatial_data/test_geospatial_data.py	(revision 4129)
@@ -912,5 +912,5 @@
         import os
        
-        fileName = tempfile.mktemp(".xxx")
+        fileName = tempfile.mktemp(".txt")
         file = open(fileName,"w")
         file.write(" x,y, elevation ,  speed \n\
