Ignore:
Timestamp:
Feb 27, 2009, 11:54:09 AM (15 years ago)
Author:
rwilson
Message:

numpy changes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/numpy/anuga/coordinate_transforms/geo_reference.py

    r6360 r6428  
    101101            self.read_ASCII(ASCIIFile, read_title=read_title)
    102102
    103 #    # Might be better to have this method instead of the following 3.
    104 #    def get_origin(self):
    105 #        return (self.zone, self.xllcorner, self.yllcorner)
    106 
    107103    ##
    108104    # @brief Get the X coordinate of the origin of this georef.
     
    238234################################################################################
    239235
     236    ##
     237    # @brief Change points to be absolute wrt new georef 'points_geo_ref'.
     238    # @param points The points to change.
     239    # @param points_geo_ref The new georef to make points absolute wrt.
     240    # @return The changed points.
     241    # @note If 'points' is a list then a changed list is returned.
     242    # @note The input points data is changed.
    240243    def change_points_geo_ref(self, points, points_geo_ref=None):
     244        """Change the geo reference of a list or numeric array of points to
     245        be this reference.(The reference used for this object)
     246        If the points do not have a geo ref, assume 'absolute' input values
    241247        """
    242         Change the geo reference of a list or numeric array of points to
    243         be this reference.(The reference used for this object)
    244         If the points do not have a geo ref, assume 'absolute' values
    245         """
    246 
    247         is_list = False
    248         if type(points) == types.ListType:
    249             is_list = True
     248
     249        # remember if we got a list
     250        is_list = isinstance(points, list)
    250251
    251252        points = ensure_numeric(points, num.float)
    252253
     254        # sanity checks
    253255        if len(points.shape) == 1:
    254256            # One point has been passed
     
    288290    # @return True if ???
    289291    def is_absolute(self):
    290         """Return True if xllcorner==yllcorner==0
    291         indicating that points in question are absolute.
    292         """
     292        """Return True if xllcorner==yllcorner==0"""
    293293
    294294        return num.allclose([self.xllcorner, self.yllcorner], 0)
     
    298298    # @param points
    299299    # @return
    300     # @note
     300    # @note This method changes the input points!
    301301    def get_absolute(self, points):
    302         """Given a set of points geo referenced to this instance,
     302        """Given a set of points geo referenced to this instance
     303
    303304        return the points as absolute values.
    304305        """
    305306
    306         #if self.is_absolute:
    307         #    return points
    308 
    309307        # remember if we got a list
    310         is_list = False
    311         if type(points) == types.ListType:
    312             is_list = True
    313 
     308        is_list = isinstance(points, list)
     309
     310        # convert to numeric array
    314311        points = ensure_numeric(points, num.float)
     312
     313        # sanity checks
    315314        if len(points.shape) == 1:
    316315            #One point has been passed
     
    326325
    327326        # Add geo ref to points
    328         #if not self.is_absolute:
    329327        if not self.is_absolute():
    330328            points[:,0] += self.xllcorner
Note: See TracChangeset for help on using the changeset viewer.