Changeset 3797


Ignore:
Timestamp:
Oct 16, 2006, 5:07:28 PM (18 years ago)
Author:
ole
Message:

Cosmetics according to style guide

Location:
anuga_core/source/anuga
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/abstract_2d_finite_volumes/quantity.py

    r3689 r3797  
    169169                   function = None,   # Callable object: f(x,y)
    170170                   geospatial_data = None, #Arbitrary dataset
    171                    points = None, values = None, data_georef = None, #Input for fit (obsoleted by use of geo_spatial object)
     171                   points = None, values = None, data_georef = None, #Input
     172                   # for fit (obsoleted by use of geo_spatial object)
    172173                   filename = None, attribute_name = None, #Input from file
    173174                   alpha = None,
     
    273274        L = [numeric, quantity, function, geospatial_data, points, filename]
    274275        msg = 'Exactly one of the arguments '+\
    275               'numeric, quantity, function, geospatial_data, points, or filename '+\
    276               'must be present.'
     276              'numeric, quantity, function, geospatial_data, points, '+\
     277              'or filename must be present.'
    277278        assert L.count(None) == len(L)-1, msg
    278279
     
    492493                   'Values array must be 1d'
    493494
    494             self.set_vertex_values(values.flat, indices = indices)
     495            self.set_vertex_values(values.flat, indices=indices)
    495496        else:
    496497            if len(values.shape) == 1:
    497                 self.set_vertex_values(values, indices = indices)
    498                 #if indices == None:
    499                     #Values are being specified once for each unique vertex
    500                 #    msg = 'Number of values must match number of vertices'
    501                 #    assert values.shape[0] == self.domain.coordinates.shape[0], msg
    502                  #   self.set_vertex_values(values)
    503                 #else:
    504                 #    for element_index, value in map(None, indices, values):
    505                 #        self.vertex_values[element_index, :] = value
     498                self.set_vertex_values(values, indices=indices)
    506499
    507500            elif len(values.shape) == 2:
     
    691684
    692685        from load_mesh.loadASCII import import_points_file
    693         from anuga.geospatial_data.geospatial_data import points_dictionary2geospatial_data
     686        from anuga.geospatial_data.geospatial_data import\
     687             points_dictionary2geospatial_data
    694688
    695689        from types import StringType
     
    698692
    699693
    700         #Read from (NetCDF) file
    701         #FIXME (Ole): This function should really return a Geospatial_data object.
     694        # Read from (NetCDF) file
     695        # FIXME (Ole): This function should really return a
     696        # Geospatial_data object.
    702697        points_dict = import_points_file(filename)
    703698        points = points_dict['pointlist']
     
    743738                                             use_cache = use_cache)
    744739
    745         #Call underlying method for points
    746         #self.set_values_from_points(points, z, alpha,
    747         #                            location, indices,
    748         #                            data_georef = data_georef,
    749         #                            verbose = verbose,
    750         #                            use_cache = use_cache)
    751 
    752 
    753 
    754740   
    755    
    756741    def get_maximum_index(self, indices=None):
    757742        """Return index for maximum value of quantity (on centroids)
     
    767752            have multiple values - one for each triangle sharing it.
    768753
    769             If there are multiple cells with same maximum value, the first cell
    770             encountered in the triangle array is returned.
     754            If there are multiple cells with same maximum value, the
     755            first cell encountered in the triangle array is returned.
    771756        """
    772757
     
    816801            have multiple values - one for each triangle sharing it.
    817802
    818             If there are multiple cells with same maximum value, the first cell
    819             encountered in the triangle array is returned.            
     803            If there are multiple cells with same maximum value, the
     804            first cell encountered in the triangle array is returned.       
    820805        """
    821806
     
    831816
    832817        # Interpolation object based on internal (discontinuous triangles)
    833         x, y, vertex_values, triangles = self.get_vertex_values(xy=True, smooth=False)
     818        x, y, vertex_values, triangles = self.get_vertex_values(xy=True,
     819                                                                smooth=False)
    834820        # FIXME: This concat should roll into get_vertex_values
    835         vertex_coordinates = concatenate( (x[:, NewAxis], y[:, NewAxis]), axis=1 )
     821        vertex_coordinates = concatenate((x[:, NewAxis], y[:, NewAxis]),
     822                                         axis=1)
    836823
    837824        can_reuse = False
     
    844831               
    845832
    846         if can_reuse is True:       
    847             result = I.interpolate(vertex_values) # Use absence to indicate reuse
     833        if can_reuse is True:
     834            # Use absence of points to indicate reuse in I.interpolate
     835            result = I.interpolate(vertex_values)
    848836        else:   
    849837            from anuga.fit_interpolate.interpolate import Interpolate
     
    854842
    855843            # Call interpolate with points the first time
    856             interpolation_points = ensure_numeric(interpolation_points, Float)                       
    857             result = I.interpolate(vertex_values, interpolation_points)            
     844            interpolation_points = ensure_numeric(interpolation_points, Float)
     845            result = I.interpolate(vertex_values, interpolation_points)     
    858846
    859847        return result
    860848
    861849
    862     def get_values(self, interpolation_points=None, location='vertices', indices = None):
     850    def get_values(self, interpolation_points=None,
     851                   location='vertices',
     852                   indices = None):
    863853        """get values for quantity
    864854
    865855        return X, Compatible list, Numeric array (see below)
    866         interpolation_points: List of x, y coordinates where value is sought (using interpolation)
    867                 If points are given, values of location and indices are ignored
     856        interpolation_points: List of x, y coordinates where value is
     857        sought (using interpolation). If points are given, values of
     858        location and indices are ignored
     859       
    868860        location: Where values are to be stored.
    869861                  Permissible options are: vertices, edges, centroid
     
    874866        (N if indices = None).
    875867
    876         In case of location == 'centroids' the dimension of returned values will
    877         be a list or a Numerical array of length N, N being the number
    878         of elements.
     868        In case of location == 'centroids' the dimension of returned
     869        values will be a list or a Numerical array of length N, N being
     870        the number of elements.
    879871       
    880         In case of location == 'vertices' or 'edges' the dimension of returned values will
    881         be of dimension Nx3
    882 
    883         In case of location == 'unique vertices' the average value at each vertex will be
    884         returned and the dimension of returned values will be a 1d array of length "number of vertices"
     872        In case of location == 'vertices' or 'edges' the dimension of
     873        returned values will be of dimension Nx3
     874
     875        In case of location == 'unique vertices' the average value at
     876        each vertex will be returned and the dimension of returned values
     877        will be a 1d array of length "number of vertices"
    885878       
    886 
    887879        Indices is the set of element ids that the operation applies to.
    888880
     
    898890       
    899891
    900         if location not in ['vertices', 'centroids', 'edges', 'unique vertices']:
     892        if location not in ['vertices', 'centroids', 'edges',
     893                            'unique vertices']:
    901894            msg = 'Invalid location: %s' %location
    902895            raise msg
     
    13341327
    13351328    for k in range(N):
    1336         if number_of_boundaries[k] < 2:
     1329        if number_of_boundaries[k] < 2:
    13371330            #Two or three true neighbours
    13381331
  • anuga_core/source/anuga/geospatial_data/test_geospatial_data.py

    r3738 r3797  
    389389        # Then a more complex polygon
    390390        polygon = [[0,0], [1,0], [0.5,-1], [2, -1], [2,1], [0,1]]
    391         points = [ [0.5, 1.4], [0.5, 0.5], [1, -0.5], [1.5, 0], [0.5, 1.5], [0.5, -0.5]]
     391        points = [ [0.5, 1.4], [0.5, 0.5], [1, -0.5], [1.5, 0], [0.5, 1.5], [0.5, -0.5]]
    392392        G = Geospatial_data(points)
    393393
     
    420420        # Then a more complex polygon
    421421        polygon = [[0,0], [1,0], [0.5,-1], [2, -1], [2,1], [0,1]]
    422         points = [ [0.5, 1.4], [0.5, 0.5], [1, -0.5], [1.5, 0], [0.5, 1.5], [0.5, -0.5]]
     422        points = [ [0.5, 1.4], [0.5, 0.5], [1, -0.5], [1.5, 0], [0.5, 1.5], [0.5, -0.5]]
    423423
    424424        # This time just one attribute
     
    456456       
    457457        # Then a more complex polygon
    458         points = [ [0.5, 1.4], [0.5, 0.5], [1, -0.5], [1.5, 0], [0.5, 1.5], [0.5, -0.5]]
     458        points = [ [0.5, 1.4], [0.5, 0.5], [1, -0.5], [1.5, 0], [0.5, 1.5], [0.5, -0.5]]
    459459        attributes = [2, -4, 5, 76, -2, 0.1]       
    460460        G = Geospatial_data(points, attributes)
     
    490490        # Then a more complex polygon
    491491        polygon = [[0,0], [1,0], [0.5,-1], [2, -1], [2,1], [0,1]]
    492         points = [ [0.5, 1.4], [0.5, 0.5], [1, -0.5], [1.5, 0], [0.5, 1.5], [0.5, -0.5]]
     492        points = [ [0.5, 1.4], [0.5, 0.5], [1, -0.5], [1.5, 0], [0.5, 1.5], [0.5, -0.5]]
    493493        attributes = [2, -4, 5, 76, -2, 0.1]       
    494494        G = Geospatial_data(points, attributes)
  • anuga_core/source/anuga/pmesh/mesh_interface.py

    r3737 r3797  
    6060    as the x and y values for the geo_ref.
    6161   
    62     Returns the mesh instance if no finename is given
     62    Returns the mesh instance if no filename is given
    6363
    6464    Note, interior regions should be fully nested, as overlaps may cause
     
    230230        for polygon, res in interior_regions:
    231231            m.add_region_from_polygon(polygon,
    232                                       max_triangle_area = res,
     232                                      max_triangle_area=res,
    233233                                      geo_reference=poly_geo_reference)
    234234   
     
    238238        for polygon in interior_holes:
    239239            m.add_hole_from_polygon(polygon,
    240                                       geo_reference=poly_geo_reference)
     240                                    geo_reference=poly_geo_reference)
    241241       
    242242           
  • anuga_core/source/anuga/shallow_water/shallow_water_domain.py

    r3793 r3797  
    210210          - None
    211211
    212         In the two first cases, the named quantities will be stored at each yieldstep
    213         (This is in addition to the quantities elevation and friction)
     212        In the two first cases, the named quantities will be stored at
     213        each yieldstep (This is in addition to the quantities elevation
     214        and friction)
     215       
    214216        If q is None, storage will be switched off altogether.
    215217        """
     
    226228        #Check correcness
    227229        for quantity_name in q:
    228             msg = 'Quantity %s is not a valid conserved quantity' %quantity_name
     230            msg = 'Quantity %s is not a valid conserved quantity'\
     231                  %quantity_name
     232           
    229233            assert quantity_name in self.conserved_quantities, msg
    230234
     
    248252        # FIXME (Ole): Allow this to be specified as a keyword argument as well
    249253        from anuga.config import minimum_allowed_height
     254
    250255       
    251 
    252         elevation = self.get_quantity('elevation').get_values(location='centroids', indices=indices)
    253         stage = self.get_quantity('stage').get_values(location='centroids', indices=indices)               
     256        elevation = self.get_quantity('elevation').\
     257                    get_values(location='centroids', indices=indices)
     258        stage = self.get_quantity('stage').\
     259                get_values(location='centroids', indices=indices)       
    254260        depth = stage - elevation
    255261
    256262        # Select indices for which depth > 0
    257         wet_indices = compress(depth > minimum_allowed_height, arange(len(depth)))
     263        wet_indices = compress(depth > minimum_allowed_height,
     264                               arange(len(depth)))
    258265        return wet_indices
    259266
     
    272279
    273280        wet_elements = self.get_wet_elements(indices)
    274         return self.get_quantity('elevation').get_maximum_value(indices=wet_elements)
     281        return self.get_quantity('elevation').\
     282               get_maximum_value(indices=wet_elements)
    275283
    276284
     
    288296
    289297        wet_elements = self.get_wet_elements(indices)
    290         return self.get_quantity('elevation').get_maximum_location(indices=wet_elements)   
     298        return self.get_quantity('elevation').\
     299               get_maximum_location(indices=wet_elements)   
    291300
    292301
     
    829838
    830839    timestep = float(sys.maxint)
    831     from shallow_water_ext import compute_fluxes_ext_central as compute_fluxes_ext
     840    from shallow_water_ext import\
     841         compute_fluxes_ext_central as compute_fluxes_ext
     842   
    832843    domain.timestep = compute_fluxes_ext(timestep, domain.epsilon, domain.g,
    833844                                     domain.neighbours,
     
    20892100    h_limiter = h_limiter_c
    20902101    balance_deep_and_shallow = balance_deep_and_shallow_c
    2091     protect_against_infinitesimal_and_negative_heights = protect_against_infinitesimal_and_negative_heights_c
    2092 
    2093 
    2094     #distribute_to_vertices_and_edges = distribute_to_vertices_and_edges_c #(like MH's)
     2102    protect_against_infinitesimal_and_negative_heights =\
     2103                    protect_against_infinitesimal_and_negative_heights_c
     2104
     2105
     2106    #distribute_to_vertices_and_edges =\
     2107    #              distribute_to_vertices_and_edges_c #(like MH's)
    20952108
    20962109
Note: See TracChangeset for help on using the changeset viewer.