Changeset 460


Ignore:
Timestamp:
Oct 28, 2004, 4:22:55 PM (20 years ago)
Author:
duncan
Message:

removed temp methods in quantity

File:
1 edited

Legend:

Unmodified
Added
Removed
  • inundation/ga/storm_surge/pyvolution/quantity.py

    r459 r460  
    240240                raise msg
    241241           
    242  #FIXME - roll this back into set_array_values, if possible             
    243     def set_array_values_by_index(self, values, location='vertices', indexes = None):
    244         from Numeric import array, Float, Int
    245 
    246         values = array(values).astype(Float)
    247        
    248         if not (indexes == None):
    249             indexes = array(indexes).astype(Int)
    250 
    251         N = self.centroid_values.shape[0]
    252        
    253         if location == 'centroids':
    254             assert len(values.shape) == 1, 'Values array must be 1d'
    255 
    256             if indexes == None:
    257                 msg = 'Number of values must match number of elements'
    258                 assert values.shape[0] == N, msg
    259            
    260                 self.centroid_values = values
    261             else:
    262                 msg = 'Number of values must match number of indexes'
    263                 assert values.shape[0] == indexes.shape[0], msg
    264                
    265                 #Brute force
    266                 for i in range(len(indexes)):
    267                     self.centroid_values[indexes[i]] = values[i]
    268                
    269242
    270243    # FIXME have a get_vertex_values as well, so the 'level' quantity can be
     
    299272        #Intialise centroid and edge_values
    300273        self.interpolate()
     274
    301275 
    302     def set_some_vertex_values(self, A, indexes):
    303         """Set vertex values for some triangles based on input array A
    304         which is assumed to have one entry per (unique) vertex, i.e.
    305         one value for each row in array self.domain.coordinates.
    306         """
    307 
    308         from Numeric import array, Float
    309        
    310         #Assert that A can be converted to a Numeric array of appropriate dim
    311         A = array(A, Float)
    312         msg = 'Number of values must match number of indexes'
    313         assert A.shape[0] == len(indexes), msg
    314         if (len(A.shape) == 2):
    315             assert A.shape[0] == len(indexes), msg 
    316             msg = 'Each vertex must have a list of three values, or one value'
    317             assert A.shape[1] == 3, msg 
    318         elif (len(A.shape) <> 1): 
    319             msg = 'vertex values must be 1D or 2D.'
    320             raise msg
    321        
    322         #Go through list of triangles
    323         #FIXME This is brute force.  Can it be optimised?
    324         for element_index, value in map(None, indexes, A):           
    325             if len(A.shape) == 2:
    326                 self.vertex_values[element_index] = value
    327             else:
    328                 self.vertex_values[element_index, 0] = value
    329                 self.vertex_values[element_index, 1] = value
    330                 self.vertex_values[element_index, 2] = value
    331                
    332         #Intialise centroid and edge_values
    333         self.interpolate()
    334 
    335    
    336276    def smooth_vertex_values(self, value_array='field_values',
    337277                             precision = None):
Note: See TracChangeset for help on using the changeset viewer.