Ignore:
Timestamp:
Mar 24, 2006, 2:43:10 PM (18 years ago)
Author:
ole
Message:

Clean up

File:
1 edited

Legend:

Unmodified
Added
Removed
  • inundation/geospatial_data/test_geospatial_data.py

    r2589 r2590  
    202202                                              [1.0, 2.1], [3.0, 5.3]])
    203203       
    204     def test_add1 (self):
     204    def test_add_with_geo (self):
    205205        """
    206206        Difference in Geo_reference resolved
     
    208208        points1 = [[1.0, 2.1], [3.0, 5.3]]
    209209        points2 = [[5.0, 6.1], [6.0, 3.3]]
    210         attributes1= [2, 4]
     210        attributes1 = [2, 4]
    211211        attributes2 = [5, 76]
    212212        geo_ref1= Geo_reference(55, 1.0, 2.0)
    213         geo_ref2 = Geo_reference(zone = 55, xllcorner = 0.1,
    214                                  yllcorner = 3.0, datum = 'wgs84',
    215                                  projection = 'UTM', units = 'm')
     213        geo_ref2 = Geo_reference(zone=55,
     214                                 xllcorner=0.1,
     215                                 yllcorner=3.0,
     216                                 datum='wgs84',
     217                                 projection='UTM',
     218                                 units='m')
    216219                               
    217220        G1 = Geospatial_data(points1, attributes1, geo_ref1)
    218221        G2 = Geospatial_data(points2, attributes2, geo_ref2)
    219222
     223        #Check that absolute values are as expected
     224        P1 = G1.get_data_points(absolute=True)
     225        assert allclose(P1, [[2.0, 4.1], [4.0, 7.3]])
     226
     227        P2 = G2.get_data_points(absolute=True)
     228        assert allclose(P2, [[5.1, 9.1], [6.1, 6.3]])       
     229       
    220230        G = G1 + G2
    221231       
    222232        assert allclose(G.get_geo_reference().get_xllcorner(), 0.1)
    223233        assert allclose(G.get_geo_reference().get_yllcorner(), 2.0)
    224 #        print 'G data points=', G.get_data_points()
    225         assert allclose(G.get_data_points(), [[2.0, 4.1], [4.0, 7.3], [5.1, 9.1], [6.1, 6.3]])                             
    226 
     234
     235        P = G.get_data_points(absolute=True)
     236        assert allclose(P, concatenate( (P1,P2) ))
     237
     238        P_relative = G.get_data_points(absolute=False)
     239        assert allclose(P_relative, P - [0.1, 2.0])                     
     240        assert allclose(P, [[2.0, 4.1], [4.0, 7.3],
     241                            [5.1, 9.1], [6.1, 6.3]])
    227242
    228243
Note: See TracChangeset for help on using the changeset viewer.