Changeset 2489
- Timestamp:
- Mar 7, 2006, 11:33:08 AM (19 years ago)
- Location:
- inundation/geospatial_data
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/geospatial_data/geospatial_data.py
r2472 r2489 8 8 9 9 from Numeric import concatenate 10 11 from coordinate_transforms.geo_reference import Geo_reference 10 12 11 13 class Geospatial_data: … … 85 87 self.geo_reference = geo_reference 86 88 else: 87 msg = 'Argument geo_reference must be a valid Geo_reference \ 88 89 msg = 'Argument geo_reference must be a valid Geo_reference \n' 90 msg += 'object or None.' 89 91 raise msg 90 92 … … 134 136 """ 135 137 136 a_points = self.get_data_points() 137 b_points = other.get_data_points() 138 139 a_attribute_keys = self.attributes.keys() 140 b_attribute_keys = other.attributes.keys() 141 138 # sets xll and yll as the smallest from self and other 139 if self.geo_reference.xllcorner <= other.geo_reference.xllcorner: 140 xll = self.geo_reference.xllcorner 141 else: 142 xll = other.geo_reference.xllcorner 143 144 if self.geo_reference.yllcorner <= other.geo_reference.yllcorner: 145 yll = self.geo_reference.yllcorner 146 else: 147 yll = other.geo_reference.yllcorner 148 149 # find objects zone and checks if the same 142 150 geo_ref1 = self.get_geo_reference() 143 151 zone1 = geo_ref1.get_zone() … … 146 154 zone2 = geo_ref2.get_zone() 147 155 148 if zone1 == zone2: # and some more checks to add 149 150 c_points = concatenate((a_points, b_points), axis = 0) 156 geo_ref = Geo_reference(zone1, xll, yll) 157 158 if zone1 == zone2: 159 a_rel_points = self.get_data_points() 160 b_rel_points = other.get_data_points() 161 162 # subtracts xll and yll from self's and other's 163 # reletive data point and concatenates 164 c_points = concatenate((a_rel_points-[xll, yll], 165 b_rel_points-[xll, yll]), axis = 0) 166 151 167 new_dictionary = {} 152 168 for x in self.attributes.keys(): 153 169 if other.attributes.has_key(x): 154 170 155 a ttrib_a= self.attributes[x]156 attrib_b = other.attributes[x]157 new_dictionary[x] = concatenate((a ttrib_a, attrib_b))171 a_attrib = self.attributes[x] 172 b_attrib = other.attributes[x] 173 new_dictionary[x] = concatenate((a_attrib, b_attrib)) 158 174 159 175 else: 160 176 msg = 'Both geospatial_data objects must have the same \n' 161 #msg += 'attributes to allow addition.'177 msg += 'attributes to allow addition.' 162 178 raise msg 163 179 164 return Geospatial_data(c_points, new_dictionary )180 return Geospatial_data(c_points, new_dictionary, geo_ref) 165 181 166 182 else: … … 168 184 ZONE to allow addition.' 169 185 raise msg 170 171 172 # else: 173 # print 'zones are not the same' 174 175 176 177 178 179 186 180 187 181 188 -
inundation/geospatial_data/test_geospatial_data.py
r2473 r2489 208 208 [1.0, 2.1], [3.0, 5.3]]) 209 209 210 def xtest_add1 (self):210 def test_add1 (self): 211 211 """ 212 212 difference in Geo_reference resolved … … 228 228 assert allclose(G.get_geo_reference().get_xllcorner(), 0.1) 229 229 assert allclose(G.get_geo_reference().get_yllcorner(), 2.0) 230 assert allclose(G.get_data_points(), [[2.0, 4.1], [4.0, 7.3], [5.1, 9.3], [6.1, 6.3]]) 230 # print 'G data points=', G.get_data_points() 231 assert allclose(G.get_data_points(), [[2.0, 4.1], [4.0, 7.3], [5.1, 9.1], [6.1, 6.3]]) 231 232 232 233 def xtest_create_from_file(self):
Note: See TracChangeset
for help on using the changeset viewer.