Changeset 4179


Ignore:
Timestamp:
Jan 16, 2007, 2:08:22 PM (17 years ago)
Author:
duncan
Message:

added comments and warnings

Location:
anuga_core/source/anuga/geospatial_data
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/geospatial_data/geospatial_data.py

    r4178 r4179  
    4141
    4242        data_points: x,y coordinates in meters. Type must be either a
    43         sequence of 2-tuples or an Mx2 Numeric array of floats.
     43        sequence of 2-tuples or an Mx2 Numeric array of floats.  A file name
     44        can also be passed in here.
    4445
    4546        attributes: Associated values for each data point. The type
     
    5253        points. It contains UTM zone, easting and northing and data
    5354        points are assumed to be relative to this origin.
    54         If geo_reference is None, the default geo ref object is used
     55        If geo_reference is None, the default geo ref object is used.
    5556
    5657        default_attribute_name: Name of default attribute to be used with
     
    5859        equipped with information about which attribute to return.
    5960        If None, the default is the "first"
    60        
    61         file_name: Name of input netCDF file or xya file. netCDF file must
     61
     62        latitudes, longitudes: Vectors of latitudes and longitudes,
     63        used to specify location instead of points.
     64       
     65        points_are_lats_longs: Set this as true if the points are actually
     66        lats and longs, not UTM
     67
     68        max_read_lines: The number of rows read into memory when using
     69        blocking to read a file.
     70
     71        load_file_now:  If true the file is automatically loaded
     72        into the geospatial instance. Used when blocking.
     73       
     74        file_name: Name of input netCDF file or .txt file. netCDF file must
    6275        have dimensions "points" etc.
    63         xya file is a comma seperated file with x, y and attribute data.
    64         the first line must be the attribute names eg elevation
    65        
    66         The format for a .xya file is:
    67             1st line:     [attribute names]
     76        .txt file is a comma seperated file with x, y and attribute
     77        data.
     78        the first line has the titles of the columns.  The first two columns
     79        are assumed to be the x and y, and the title names acually used are
     80        ignored.
     81
     82        The
     83       
     84        The format for a .txt file is:
     85            1st line:     [column names]
    6886            other lines:  x y [attributes]
    6987
    7088            for example:
    71             elevation, friction
     89            x, y, elevation, friction
    7290            0.6, 0.7, 4.9, 0.3
    7391            1.9, 2.8, 5, 0.3
    7492            2.7, 2.4, 5.2, 0.3
    7593
    76         The first two columns are always implicitly assumed to be x, y
     94        The first two columns are always assumed to be x, y
    7795        coordinates.
    78         Use the same delimiter for the attribute names and the data
    79 
    80         An xya file can optionally end with
    81             #geo reference
    82             56
    83             466600.0
    84             8644444.0
    85 
    86         When the 1st # is the zone,
    87         2nd # the xllcorner and
    88         3rd # the yllcorner
    89 
     96     
    9097        An issue with the xya format is that the attribute column order
    9198        is not be controlled.  The info is stored in a dictionary and it's
    92         written however
     99        written in an order dependent on the hash order
    93100       
    94101        The format for a Points dictionary is:
     
    106113               
    107114        delimiter: is the file delimiter that will be used when
    108             importing the file
     115            importing a .xya file, which is being phased out.
    109116           
    110117        verbose:
    111118
    112         load_file_now: if load file now is true, the file is
    113         loaded during instanciation.
    114119         
    115120        """
     
    123128        self.file_name = file_name
    124129        self.max_read_lines = max_read_lines
     130
     131        if delimiter is not None:
     132            msg = 'Specifying delimiters will be removed.'
     133            msg = 'Text file format is moving to comma seperated .txt files.'
     134            warn(msg, DeprecationWarning)
    125135        if file_name is None:
    126136            if delimiter is not None:
     
    514524        attributes = {}
    515525        if file_name[-4:]== ".xya":
     526            msg = 'Text file format is moving to comma seperated .txt files.'
     527            warn(msg, DeprecationWarning)
    516528            try:
    517529                if delimiter == None:
     
    746758            if self.start_row == self.last_row:
    747759                # read the end of the file last iteration
    748                 # FIXME clean up, remove blocking atts eg
    749                 #self.max_read_lines
    750                 #self.blocking_georef,self.last_row
    751                 #self.start_row
    752                 ### self.blocking_keys
     760                # remove blocking attributes
    753761                self.fid.close()
     762                del self.max_read_lines
     763                del self.blocking_georef
     764                del self.last_row
     765                del self.start_row
     766                del self.blocking_keys
     767                del self.fid
    754768                raise StopIteration
    755769            fin_row = self.start_row + self.max_read_lines
     
    777791            except StopIteration:
    778792                self.file_pointer.close()
     793                del self.header
     794                del self.file_pointer
    779795                raise StopIteration
    780796        return geo
  • anuga_core/source/anuga/geospatial_data/test_geospatial_data.py

    r4178 r4179  
    2222                        category=DeprecationWarning)
    2323
     24warnings.filterwarnings(action = 'ignore',
     25                        message='Text file format is moving to comma se',
     26                        category=DeprecationWarning)
     27
     28warnings.filterwarnings(action = 'ignore',
     29                        message='Specifying delimiters will be removed.',
     30                        category=DeprecationWarning)
    2431
    2532class Test_Geospatial_data(unittest.TestCase):
Note: See TracChangeset for help on using the changeset viewer.