Changeset 4108


Ignore:
Timestamp:
Dec 20, 2006, 3:58:01 PM (17 years ago)
Author:
duncan
Message:

mainly comments - Getting ready for blocking..

Location:
anuga_core/source/anuga/fit_interpolate
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/fit_interpolate/benchmark_least_squares.py

    r3514 r4108  
    9393                print "Interpolate!"
    9494                calc = interp.interpolate(mesh_dict['vertex_attributes'])
    95         else:
    96             # need to change to fit_interpolate code
    97             interp = Fit(mesh_dict['vertices'],
     95        else: 
     96            if is_fit is True:
     97                interp = Fit(mesh_dict['vertices'],
    9898                                 mesh_dict['triangles'],
    99                                  max_vertices_per_cell = max_points_per_cell)
    100             if is_fit is True:
     99                                 max_vertices_per_cell = max_points_per_cell)
    101100                print "Fit in Fit"
    102101                calc = interp.fit(points_dict['points'],
    103102                                  points_dict['point_attributes'])
    104                 pass
    105103            else:
    106104                # run an interploate problem.
  • anuga_core/source/anuga/fit_interpolate/fit.py

    r3945 r4108  
    7878          Note: Don't supply a vertex coords as a geospatial object and
    7979              a mesh origin, since geospatial has its own mesh origin.
     80
     81
     82        Usage,
     83        To use this in a blocking way, call  build_fit_subset, with z info,
     84        and then fit, with no point coord, z info.
     85       
    8086        """
    8187        # Initialise variabels
     
    232238
    233239        if self.AtA == None:
    234             # AtA and Atz need ot be initialised.
     240            # AtA and Atz need to be initialised.
    235241            m = self.mesh.number_of_nodes
    236242            if len(z.shape) > 1:
     
    243249
    244250            self.AtA = Sparse(m,m)
     251            # The memory damage has been done by now.
     252           
    245253        self.point_count += point_coordinates.shape[0]
    246254        #print "_build_matrix_AtA_Atz - self.point_count", self.point_count
     
    250258        #      self.mesh.get_boundary_polygon()
    251259
     260        # Why are these global?
    252261        self.inside_poly_indices, self.outside_poly_indices  = \
    253262                     in_and_outside_polygon(point_coordinates,
     
    311320            #FIXME (DSG) - do  a message
    312321        else:
     322            # This is where build fit subset can be looped over,
     323            # if a file name is passed in.
    313324            point_coordinates = ensure_absolute(point_coordinates,
    314325                                                geo_reference=point_origin)
     326            #if isinstance(point_coordinates,Geospatial_data) and z is None:
     327            # z will come from the geo-ref
    315328            self.build_fit_subset(point_coordinates, z, verbose)
    316329
     
    345358
    346359       
    347     def build_fit_subset(self, point_coordinates, z,
    348                               verbose = False):
     360    def build_fit_subset(self, point_coordinates, z=None, attribute_name=None,
     361                              verbose=False):
    349362        """Fit a smooth surface to given 1d array of data points z.
    350363
     
    356369              List of coordinate pairs [x, y] of
    357370              data points or an nx2 Numeric array or a Geospatial_data object
    358           z: Single 1d vector or array of data at the point_coordinates.
    359 
    360         """
    361         #Note: Don't get the z info from anuga.geospatial_data.attributes yet.
    362         # If we did fit would have to handle attribute title info.
     371        z: Single 1d vector or array of data at the point_coordinates.
     372        attribute_name: Used to get the z values from the
     373              geospatial object if no attribute_name is specified,
     374              it's a bit of a lucky dip as to what attributes you get.
     375              If there is only one attribute it will be that one.
     376
     377        """
    363378
    364379        #FIXME(DSG-DSG): Check that the vert and point coords
     
    369384       
    370385        #Convert input to Numeric arrays
    371         z = ensure_numeric(z, Float)
     386        if z is not None:
     387            z = ensure_numeric(z, Float)
     388        else:
     389            msg = 'z not specified'
     390            assert isinstance(point_coordinates,Geospatial_data), msg
     391            z = point_coordinates.get_attributes(attribute_name)
     392           
    372393        point_coordinates = ensure_numeric(point_coordinates, Float)
    373394
Note: See TracChangeset for help on using the changeset viewer.