Ignore:
Timestamp:
Mar 19, 2009, 1:43:34 PM (16 years ago)
Author:
rwilson
Message:

Merged trunk into numpy, all tests and validations work.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/numpy/anuga/coordinate_transforms/test_redfearn.py

    r6533 r6553  
    1111from anuga.utilities.anuga_exceptions import ANUGAError
    1212
     13from anuga.utilities.system_tools import get_pathname_from_package
     14from os.path import join
    1315import numpy as num
    1416
     
    122124
    123125    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)
    127136        zone, easting, northing = redfearn(-29.233299999,114.05)
    128137
     
    267276    #    #assert allclose(northing, 6181725.1724276)
    268277
     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           
    269365    def test_convert_lats_longs(self):
    270366
Note: See TracChangeset for help on using the changeset viewer.