Changeset 5730
- Timestamp:
- Sep 4, 2008, 5:22:08 PM (17 years ago)
- Location:
- anuga_core
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/documentation/user_manual/anuga_user_manual.tex
r5719 r5730 18 18 % makeindex modanuga_user_manual.idx 19 19 % To produce the modanuga_user_manual.ind file. 20 21 22 %%%%%%%%%%%%%% TODO %%%%%%%%%%%%%%%% 23 % 24 % ensure_geospatial 25 % ensure_absolute 26 % set_geo_reference 27 28 20 29 21 30 -
anuga_core/source/anuga/coordinate_transforms/geo_reference.py
r5665 r5730 385 385 geo_ref = None 386 386 else: 387 geo_ref = apply(Geo_reference, origin)387 geo_ref = apply(Geo_reference, origin) 388 388 return geo_ref 389 389 -
anuga_core/source/anuga/geospatial_data/geospatial_data.py
r5729 r5730 228 228 self.attributes = attributes 229 229 230 #def set_geo_reference(self, geo_reference): 231 # # FIXME (Ole): Backwards compatibility - deprecate 232 # self.setgeo_reference(geo_reference) 230 233 231 234 def set_geo_reference(self, geo_reference): 232 """ 233 Set's the georeference of geospatial. 234 It can also be used to change the georeference 235 """Set the georeference of geospatial data. 236 237 It can also be used to change the georeference and will ensure that 238 the absolute coordinate values are unchanged. 235 239 """ 236 240 from anuga.coordinate_transforms.geo_reference import Geo_reference 237 241 238 242 if geo_reference is None: 239 geo_reference = Geo_reference() # Use default 243 # Use default - points are in absolute coordinates 244 geo_reference = Geo_reference() 245 246 # Allow for tuple (zone, xllcorner, yllcorner) 240 247 geo_reference = ensure_geo_reference(geo_reference) 248 241 249 if not isinstance(geo_reference, Geo_reference): 250 # FIXME (Ole): This exception will be raised if geo_reference is None 242 251 msg = 'Argument geo_reference must be a valid Geo_reference \n' 243 252 msg += 'object or None.' 244 253 raise msg 245 254 246 # if a geo ref already exists, change the point datato247 # represent the new geo-ref255 # If a geo_reference already exists, change the point data according to 256 # the new geo reference 248 257 if self.geo_reference is not None: 249 #FIXME: Maybe put out a warning here... 250 self.data_points = self.get_data_points \ 251 (geo_reference=geo_reference) 258 self.data_points = self.get_data_points(geo_reference=geo_reference) 252 259 253 260 self.geo_reference = geo_reference … … 376 383 lats_longs = [] 377 384 for point in self.get_data_points(True): 378 ### UTMtoLL(northing, easting, zone, 385 386 # UTMtoLL(northing, easting, zone, 379 387 lat_calced, long_calced = UTMtoLL(point[1],point[0], 380 388 zone, isSouthHemisphere) 381 389 lats_longs.append((lat_calced, long_calced)) # to hash 382 390 return lats_longs 391 383 392 if absolute is True and geo_reference is None: 384 393 return self.geo_reference.get_absolute(self.data_points) … … 388 397 self.geo_reference) 389 398 else: 399 # If absolute is False 390 400 return self.data_points 391 401 … … 1315 1325 1316 1326 def ensure_absolute(points, geo_reference=None): 1317 """ 1327 """Ensure that points are in absolute coordinates. 1328 1318 1329 This function inputs several formats and 1319 1330 outputs one format. - a numeric array of absolute points. 1320 1331 1321 Input edformats are;1322 points: List or numeric array of coordinate pairs [xi, eta] of1332 Input formats are; 1333 points: List or numeric array of coordinate pairs [xi, eta] of 1323 1334 points or geospatial object or points file name 1324 1335 … … 1328 1339 relative to their respective origins. 1329 1340 """ 1330 if isinstance(points,type('')): 1331 #It's a string1332 #assume it is a point file1333 points = Geospatial_data(file_name = points)1334 1335 if isinstance(points,Geospatial_data):1336 points = points.get_data_points( \1337 absolute =True)1338 msg = "Use a Geospatial_data object or a mesh origin. Not both."1341 1342 # Input check 1343 if isinstance(points, basestring): 1344 #It's a string - assume it is a point file 1345 points = Geospatial_data(file_name=points) 1346 1347 if isinstance(points, Geospatial_data): 1348 points = points.get_data_points(absolute=True) 1349 msg = 'Use a Geospatial_data object or a mesh origin. Not both.' 1339 1350 assert geo_reference == None, msg 1340 1341 1351 else: 1342 1352 points = ensure_numeric(points, Float) 1353 1354 # Sort of geo_reference and convert points 1343 1355 if geo_reference is None: 1344 1356 geo = None #Geo_reference() … … 1351 1363 geo_reference[2]) 1352 1364 points = geo.get_absolute(points) 1365 1366 # Return 1353 1367 return points 1354 1368 … … 1368 1382 relative to their respective origins. 1369 1383 """ 1370 if isinstance(points,Geospatial_data): 1384 1385 # Input check 1386 if isinstance(points, Geospatial_data): 1371 1387 msg = "Use a Geospatial_data object or a mesh origin. Not both." 1372 assert geo_reference ==None, msg1388 assert geo_reference is None, msg 1373 1389 return points 1374 1390 else: 1391 # List or numeric array of absolute points 1375 1392 points = ensure_numeric(points, Float) 1393 1394 # Sort out geo reference 1376 1395 if geo_reference is None: 1377 1396 geo = None … … 1383 1402 geo_reference[1], 1384 1403 geo_reference[2]) 1404 1405 # Create Geospatial_data object with appropriate geo reference and return 1385 1406 points = Geospatial_data(data_points=points, geo_reference=geo) 1386 1407 return points -
anuga_core/source/anuga/geospatial_data/test_geospatial_data.py
r5729 r5730 205 205 206 206 def test_set_geo_reference(self): 207 """test_set_georeference 208 209 Test that georeference can be changed without changing the 210 absolute values. 211 """ 212 207 213 points_ab = [[12.5,34.7],[-4.5,-60.0]] 208 214 x_p = -10 … … 210 216 geo_ref = Geo_reference(56, x_p, y_p) 211 217 points_rel = geo_ref.change_points_geo_ref(points_ab) 212 spatial = Geospatial_data(points_rel) 213 # since the geo_ref wasn't set 214 assert not allclose( points_ab, spatial.get_data_points(absolute=True)) 215 216 spatial = Geospatial_data(points_rel, geo_reference=geo_ref) 217 assert allclose( points_ab, spatial.get_data_points(absolute=True)) 218 218 219 # Create without geo_ref properly set 220 G = Geospatial_data(points_rel) 221 assert not allclose(points_ab, G.get_data_points(absolute=True)) 222 223 # Create the way it should be 224 G = Geospatial_data(points_rel, geo_reference=geo_ref) 225 assert allclose(points_ab, G.get_data_points(absolute=True)) 226 227 # Change georeference and check that absolute values are unchanged. 219 228 x_p = 10 220 229 y_p = 400 221 230 new_geo_ref = Geo_reference(56, x_p, y_p) 222 spatial.set_geo_reference(new_geo_ref) 223 assert allclose( points_ab, spatial.get_data_points(absolute=True)) 224 225 231 G.set_geo_reference(new_geo_ref) 232 assert allclose(points_ab, G.get_data_points(absolute=True)) 233 234 235 226 236 227 237 def test_conversions_to_points_dict(self): -
anuga_core/source/anuga/shallow_water/shallow_water_domain.py
r5729 r5730 97 97 98 98 from anuga.utilities.numerical_tools import gradient, mean, ensure_numeric 99 from anuga.geospatial_data.geospatial_data import ensure_geospatial 100 99 101 from anuga.config import minimum_storable_height 100 102 from anuga.config import minimum_allowed_height, maximum_allowed_speed … … 409 411 410 412 # FIXME (Ole): HACK - need to make midpoints Geospatial instances 411 midpoints = self.geo_reference.get_absolute(midpoints) 413 #midpoints = self.geo_reference.get_absolute(midpoints) 414 415 # Make midpoints Geospatial instances 416 midpoints = ensure_geospatial(midpoints, self.geo_reference) 412 417 413 418 # Compute flow -
anuga_core/source/anuga/shallow_water/test_shallow_water_domain.py
r5729 r5730 5905 5905 if __name__ == "__main__": 5906 5906 5907 #suite = unittest.makeSuite(Test_Shallow_Water,'test')5908 5909 suite = unittest.makeSuite(Test_Shallow_Water,'test_get_flow_through_cross_section_with_geo')5907 suite = unittest.makeSuite(Test_Shallow_Water,'test') 5908 5909 #suite = unittest.makeSuite(Test_Shallow_Water,'test_get_flow_through_cross_section_with_geo') 5910 5910 #suite = unittest.makeSuite(Test_Shallow_Water,'test_fitting_using_shallow_water_domain') 5911 5911 #suite = unittest.makeSuite(Test_Shallow_Water,'test_tight_slope_limiters')
Note: See TracChangeset
for help on using the changeset viewer.