- Timestamp:
- Mar 19, 2009, 1:43:34 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/numpy/anuga/coordinate_transforms/test_redfearn.py
r6533 r6553 11 11 from anuga.utilities.anuga_exceptions import ANUGAError 12 12 13 from anuga.utilities.system_tools import get_pathname_from_package 14 from os.path import join 13 15 import numpy as num 14 16 … … 122 124 123 125 def test_UTM_6_nonstandard_projection(self): 124 #Test 6 (Geraldton, WA) 125 126 #First test native projection (zone 50) 126 """test_UTM_6_nonstandard_projection 127 128 Test that projections can be forced to 129 use other than native zone. 130 131 Data is from Geraldton, WA 132 """ 133 134 135 # First test native projection (zone 50) 127 136 zone, easting, northing = redfearn(-29.233299999,114.05) 128 137 … … 267 276 # #assert allclose(northing, 6181725.1724276) 268 277 278 279 def test_nonstandard_meridian_coinciding_with_native(self): 280 """test_nonstandard_meridian_coinciding_with_native 281 282 This test will verify that redfearn can be used to project 283 points using an arbitrary central meridian that happens to 284 coincide with the standard meridian at the center of a UTM zone. 285 This is a preliminary test before testing this functionality 286 with a truly arbitrary non-standard meridian. 287 """ 288 289 # The file projection_test_points_z53.csv contains 10 points 290 # which straddle the boundary between UTM zones 53 and 54. 291 # They have been projected to zone 53 irrespective of where they 292 # belong. 293 294 path = get_pathname_from_package('anuga.coordinate_transforms') 295 296 for forced_zone in [53, 54]: 297 298 datafile = join(path, 'projection_test_points_z%d.csv' % forced_zone) 299 fid = open(datafile) 300 301 for line in fid.readlines()[1:]: 302 fields = line.strip().split(',') 303 304 lon = float(fields[1]) 305 lat = float(fields[2]) 306 x = float(fields[3]) 307 y = float(fields[4]) 308 309 zone, easting, northing = redfearn(lat, lon, 310 zone=forced_zone) 311 312 # Check calculation 313 assert zone == forced_zone 314 assert num.allclose(x, easting) 315 assert num.allclose(y, northing) 316 317 318 319 320 def test_nonstandard_meridian(self): 321 """test_nonstandard_meridian 322 323 This test will verify that redfearn can be used to project 324 points using an arbitrary central meridian. 325 """ 326 327 # The file projection_test_points.csv contains 10 points 328 # which straddle the boundary between UTM zones 53 and 54. 329 # They have been projected using a central meridian of 137.5 330 # degrees (the boundary is 138 so it is pretty much right 331 # in the middle of zones 53 and 54). 332 333 path = get_pathname_from_package('anuga.coordinate_transforms') 334 datafile = join(path, 'projection_test_points.csv') 335 fid = open(datafile) 336 337 for line in fid.readlines()[1:]: 338 fields = line.strip().split(',') 339 340 lon = float(fields[1]) 341 lat = float(fields[2]) 342 x = float(fields[3]) 343 y = float(fields[4]) 344 345 zone, easting, northing = redfearn(lat, lon, 346 central_meridian=137.5, 347 scale_factor=0.9996) 348 349 assert zone == -1 # Indicates non UTM projection 350 assert num.allclose(x, easting) 351 assert num.allclose(y, northing) 352 353 # Test that zone and meridian can't both be specified 354 try: 355 zone, easting, northing = redfearn(lat, lon, 356 zone=50, 357 central_meridian=137.5) 358 except: 359 pass 360 else: 361 msg = 'Should have raised exception' 362 raise Exception, msg 363 364 269 365 def test_convert_lats_longs(self): 270 366
Note: See TracChangeset
for help on using the changeset viewer.