Changeset 4179 for anuga_core/source/anuga
- Timestamp:
- Jan 16, 2007, 2:08:22 PM (18 years ago)
- 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 41 41 42 42 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. 44 45 45 46 attributes: Associated values for each data point. The type … … 52 53 points. It contains UTM zone, easting and northing and data 53 54 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. 55 56 56 57 default_attribute_name: Name of default attribute to be used with … … 58 59 equipped with information about which attribute to return. 59 60 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 62 75 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] 68 86 other lines: x y [attributes] 69 87 70 88 for example: 71 elevation, friction89 x, y, elevation, friction 72 90 0.6, 0.7, 4.9, 0.3 73 91 1.9, 2.8, 5, 0.3 74 92 2.7, 2.4, 5.2, 0.3 75 93 76 The first two columns are always implicitlyassumed to be x, y94 The first two columns are always assumed to be x, y 77 95 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 90 97 An issue with the xya format is that the attribute column order 91 98 is not be controlled. The info is stored in a dictionary and it's 92 written however99 written in an order dependent on the hash order 93 100 94 101 The format for a Points dictionary is: … … 106 113 107 114 delimiter: is the file delimiter that will be used when 108 importing the file115 importing a .xya file, which is being phased out. 109 116 110 117 verbose: 111 118 112 load_file_now: if load file now is true, the file is113 loaded during instanciation.114 119 115 120 """ … … 123 128 self.file_name = file_name 124 129 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) 125 135 if file_name is None: 126 136 if delimiter is not None: … … 514 524 attributes = {} 515 525 if file_name[-4:]== ".xya": 526 msg = 'Text file format is moving to comma seperated .txt files.' 527 warn(msg, DeprecationWarning) 516 528 try: 517 529 if delimiter == None: … … 746 758 if self.start_row == self.last_row: 747 759 # 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 753 761 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 754 768 raise StopIteration 755 769 fin_row = self.start_row + self.max_read_lines … … 777 791 except StopIteration: 778 792 self.file_pointer.close() 793 del self.header 794 del self.file_pointer 779 795 raise StopIteration 780 796 return geo -
anuga_core/source/anuga/geospatial_data/test_geospatial_data.py
r4178 r4179 22 22 category=DeprecationWarning) 23 23 24 warnings.filterwarnings(action = 'ignore', 25 message='Text file format is moving to comma se', 26 category=DeprecationWarning) 27 28 warnings.filterwarnings(action = 'ignore', 29 message='Specifying delimiters will be removed.', 30 category=DeprecationWarning) 24 31 25 32 class Test_Geospatial_data(unittest.TestCase):
Note: See TracChangeset
for help on using the changeset viewer.