Changeset 3768


Ignore:
Timestamp:
Oct 13, 2006, 12:13:34 PM (18 years ago)
Author:
ole
Message:

A bit of formatting

File:
1 edited

Legend:

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

    r3689 r3768  
    3535from anuga.utilities.numerical_tools import ensure_numeric, mean, NAN
    3636from anuga.utilities.polygon import in_and_outside_polygon
    37 from anuga.geospatial_data.geospatial_data import Geospatial_data, ensure_absolute
     37from anuga.geospatial_data.geospatial_data import Geospatial_data
     38from anuga.geospatial_data.geospatial_data import ensure_absolute
    3839from anuga.fit_interpolate.search_functions import search_tree_of_vertices
    3940from anuga.fit_interpolate.general_fit_interpolate import FitInterpolate
     
    120121        # FIXME (Ole): Need an input check that dimensions are compatible
    121122
    122         # FIXME (Ole): Why is the interpolation matrix rebuilt everytime the method is called
    123         # even if interpolation points are unchanged.
     123        # FIXME (Ole): Why is the interpolation matrix rebuilt everytime the
     124        # method is called even if interpolation points are unchanged.
    124125       
    125126        #print "point_coordinates interpolate.interpolate", point_coordinates
     
    168169                                 len(point_coordinates),
    169170                                 start_blocking_len):
     171                   
    170172                    t = self.interpolate_block(f, point_coordinates[start:end],
    171173                                               verbose=verbose)
     
    174176                    z = concatenate((z,t))
    175177                    start = end
     178                   
    176179                end = len(point_coordinates)
    177180                t = self.interpolate_block(f, point_coordinates[start:end],
     
    179182                z = concatenate((z,t))
    180183        return z
    181 
    182184
    183185    def interpolate_block(self, f, point_coordinates = None, verbose=False):
     
    213215            z[i] = NAN
    214216        return z
    215 
    216217
    217218    def _build_interpolation_matrix_A(self,
     
    364365        velocity_y_writer.writerow(velocity_ys)
    365366
     367
    366368class Interpolation_function:
    367369    """Interpolation_interface - creates callable object f(t, id) or f(t,x,y)
     
    398400    If None, return average value
    399401    """
    400 
    401    
     402 
    402403   
    403404    def __init__(self,
     
    467468        self.index = 0    # Initial time index
    468469        self.precomputed_values = {}
    469        
    470 
    471 
    472 
    473470       
    474471           
     
    504501            if verbose: print 'Interpolate'
    505502            for i, t in enumerate(self.time):
    506                 #Interpolate quantities at this timestep
     503                # Interpolate quantities at this timestep
    507504                if verbose and i%((p+10)/10)==0:
    508505                    print ' time step %d of %d' %(i, p)
     
    510507                for name in quantity_names:
    511508                    if len(quantities[name].shape) == 2:
    512                         result = interpol.interpolate(quantities[name][i,:],
    513                                                       point_coordinates = \
    514                                                       self.interpolation_points)
     509                        Q = quantities[name][i,:] # Quantities at timestep i
    515510                    else:
    516                        #Assume no time dependency
    517                        result = interpol.interpolate(quantities[name][:],
    518                                      point_coordinates = \
    519                                      self.interpolation_points)
     511                        Q = quantities[name][:]   # No time dependency
    520512                       
     513                    # Interpolate   
     514                    result = interpol.interpolate(Q,
     515                                                  point_coordinates=\
     516                                                  self.interpolation_points)
    521517                    self.precomputed_values[name][i, :] = result
     518
    522519                   
    523             #Report
     520            # Report
    524521            if verbose:
    525522                print self.statistics()
     
    527524           
    528525        else:
    529             #Store quantitites as is
    530             for name in quantity_names:
     526            # Store quantitites as is
     527            for name in quantity_names:
    531528                self.precomputed_values[name] = quantities[name]
    532529
    533 
    534530    def __repr__(self):
    535         #return 'Interpolation function (spatio-temporal)'
     531        # return 'Interpolation function (spatio-temporal)'
    536532        return self.statistics()
    537    
    538 
    539     def __call__(self, t, point_id = None, x = None, y = None):
     533 
     534    def __call__(self, t, point_id=None, x=None, y=None):
    540535        """Evaluate f(t), f(t, point_id) or f(t, x, y)
    541536
     
    665660        return self.time
    666661
     662
    667663    def statistics(self):
    668664        """Output statistics about interpolation_function
     
    711707        return str
    712708
     709
    713710def interpolate_sww(sww_file, time, interpolation_points,
    714711                    quantity_names = None, verbose = False):
     
    729726
    730727    #Will return the quantity values at the specified times and locations
    731     interp =  Interpolation_interface(
    732                  time,
    733                  quantities,
    734                  quantity_names = quantity_names, 
    735                  vertex_coordinates = vertex_coordinates,
    736                  triangles = volumes,
    737                  interpolation_points = interpolation_points,
    738                  verbose = verbose)
     728    interp = Interpolation_interface(time,
     729                                     quantities,
     730                                     quantity_names=quantity_names, 
     731                                     vertex_coordinates=vertex_coordinates,
     732                                     triangles=volumes,
     733                                     interpolation_points=interpolation_points,
     734                                     verbose=verbose)
    739735
    740736
     
    801797    return x, y, volumes, time, quantities
    802798
     799
    803800#-------------------------------------------------------------
    804801if __name__ == "__main__":
Note: See TracChangeset for help on using the changeset viewer.