Ignore:
Timestamp:
Sep 5, 2007, 4:42:58 PM (17 years ago)
Author:
ole
Message:

Implemented ticket:192

File:
1 edited

Legend:

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

    r4679 r4704  
    1616
    1717from Numeric import array, zeros, Float, less, concatenate, NewAxis,\
    18      argmax, allclose, take, reshape
     18     argmax, argmin, allclose, take, reshape
    1919
    2020from anuga.utilities.numerical_tools import ensure_numeric, is_scalar
     
    799799
    800800   
    801     def get_maximum_index(self, indices=None):
    802         """Return index for maximum value of quantity (on centroids)
    803 
    804         Optional argument:
     801    def get_extremum_index(self, mode=None, indices=None):
     802        """Return index for maximum or minimum value of quantity (on centroids)
     803
     804        Optional arguments:
     805            mode is either 'max'(default) or 'min'.
    805806            indices is the set of element ids that the operation applies to.
    806807
    807808        Usage:
    808             i = get_maximum_index()
     809            i = get_extreme_index()
    809810
    810811        Notes:
    811             We do not seek the maximum at vertices as each vertex can
     812            We do not seek the extremum at vertices as each vertex can
    812813            have multiple values - one for each triangle sharing it.
    813814
     
    819820
    820821        # Always return absolute indices
    821         i = argmax(V)
    822 
     822        if mode is None or mode == 'max':
     823            i = argmax(V)
     824        elif mode == 'min':   
     825            i = argmin(V)
     826
     827           
    823828        if indices is None:
    824829            return i
     
    826831            return indices[i]
    827832
     833
     834    def get_maximum_index(self, indices=None):
     835        """See get extreme index for details
     836        """
     837
     838        return self.get_extremum_index(mode='max',
     839                                       indices=indices)
     840
     841
    828842       
    829843    def get_maximum_value(self, indices=None):
     
    866880
    867881        i = self.get_maximum_index(indices)
     882        x, y = self.domain.get_centroid_coordinates()[i]
     883
     884        return x, y
     885
     886
     887    def get_minimum_index(self, indices=None):
     888        """See get extreme index for details
     889        """       
     890
     891        return self.get_extremum_index(mode='min',
     892                                       indices=indices)
     893
     894
     895    def get_minimum_value(self, indices=None):
     896        """Return minimum value of quantity (on centroids)
     897
     898        Optional argument:
     899            indices is the set of element ids that the operation applies to.
     900
     901        Usage:
     902            v = get_minimum_value()
     903
     904        See get_maximum_value for more details.   
     905        """
     906
     907
     908        i = self.get_minimum_index(indices)
     909        V = self.get_values(location='centroids')
     910       
     911        return V[i]
     912       
     913
     914    def get_minimum_location(self, indices=None):
     915        """Return location of minimum value of quantity (on centroids)
     916
     917        Optional argument:
     918            indices is the set of element ids that the operation applies to.
     919
     920        Usage:
     921            x, y = get_minimum_location()
     922
     923
     924        Notes:
     925            We do not seek the maximum at vertices as each vertex can
     926            have multiple values - one for each triangle sharing it.
     927
     928            If there are multiple cells with same maximum value, the
     929            first cell encountered in the triangle array is returned.       
     930        """
     931
     932        i = self.get_minimum_index(indices)
    868933        x, y = self.domain.get_centroid_coordinates()[i]
    869934
Note: See TracChangeset for help on using the changeset viewer.