Changeset 4484


Ignore:
Timestamp:
May 24, 2007, 4:15:34 PM (17 years ago)
Author:
ole
Message:

Made Geospatial addition absolute together with Nick to save alot of memory.
We hope this won't cause any hassles but all tests pass.

Location:
anuga_core/source/anuga/geospatial_data
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/geospatial_data/geospatial_data.py

    r4481 r4484  
    412412        attributes 
    413413       
    414         Always return relative points!
     414        Always return absolute points!
    415415        """
    416416
     
    428428        # FIXME (Duncan and Ole): use lower left corner derived from
    429429        # absolute coordinates
    430         if self.geo_reference.xllcorner <= other.geo_reference.xllcorner:
    431             xll = self.geo_reference.xllcorner
    432         else:
    433             xll = other.geo_reference.xllcorner
    434 
    435         if self.geo_reference.yllcorner <= other.geo_reference.yllcorner:
    436             yll = self.geo_reference.yllcorner
    437         else:
    438             yll = other.geo_reference.yllcorner
    439         new_geo_ref = Geo_reference(geo_ref1.get_zone(), xll, yll)
    440 
    441         xll = yll = 0.
    442        
    443         relative_points1 = self.get_data_points(absolute = False)
    444         relative_points2 = other.get_data_points(absolute = False)
    445 
    446        
    447         new_relative_points1 = new_geo_ref.\
    448                                change_points_geo_ref(relative_points1,
    449                                                      geo_ref1)
    450         new_relative_points2 = new_geo_ref.\
    451                                change_points_geo_ref(relative_points2,
    452                                                      geo_ref2)
    453        
    454         # Now both point sets are relative to new_geo_ref and
    455         # zones have been reconciled
    456 
    457         # Concatenate points
    458         new_points = concatenate((new_relative_points1,
    459                                   new_relative_points2),
    460                                   axis = 0)
     430        #if self.geo_reference.xllcorner <= other.geo_reference.xllcorner:
     431        #    xll = self.geo_reference.xllcorner
     432        #else:
     433        #    xll = other.geo_reference.xllcorner
     434
     435        #if self.geo_reference.yllcorner <= other.geo_reference.yllcorner:
     436        #    yll = self.geo_reference.yllcorner
     437        #else:
     438        #    yll = other.geo_reference.yllcorner
     439           
     440        #new_geo_ref = Geo_reference(geo_ref1.get_zone(), xll, yll)
     441
     442        #xll = yll = 0.
     443       
     444#         relative_points1 = self.get_data_points(absolute = False)
     445#         relative_points2 = other.get_data_points(absolute = False)
     446
     447       
     448#         relative_points1 = new_geo_ref.\
     449#                            change_points_geo_ref(relative_points1,
     450#                                                  geo_ref1)
     451#         relative_points2 = new_geo_ref.\
     452#                            change_points_geo_ref(relative_points2,
     453#                                                  geo_ref2)
     454       
     455#         # Now both point sets are relative to new_geo_ref and
     456#         # zones have been reconciled
     457
     458#         # Concatenate points
     459#         new_points = concatenate((relative_points1,
     460#                                   relative_points2),
     461#                                   axis = 0)
     462       
     463        new_points = concatenate((self.get_data_points(absolute = True),
     464                                  other.get_data_points(absolute = True)),
     465                                  axis = 0)       
     466
     467       
    461468     
    462469        # Concatenate attributes if any
     
    482489                    raise Exception, msg
    483490
    484         # Instantiate new data object and return   
     491        # Instantiate new data object and return absolute coordinates
     492        new_geo_ref = Geo_reference(geo_ref1.get_zone(), 0.0, 0.0)
    485493        return Geospatial_data(new_points,
    486494                               new_attributes,
  • anuga_core/source/anuga/geospatial_data/test_geospatial_data.py

    r4470 r4484  
    371371       
    372372        G = G1 + G2
    373        
    374         assert allclose(G.get_geo_reference().get_xllcorner(), 0.1)
    375         assert allclose(G.get_geo_reference().get_yllcorner(), 2.0)
     373
     374        # Check absoluteness
     375        assert allclose(G.get_geo_reference().get_xllcorner(), 0.0)
     376        assert allclose(G.get_geo_reference().get_yllcorner(), 0.0)
    376377
    377378        P = G.get_data_points(absolute=True)
    378379
    379         P_relative = G.get_data_points(absolute=False)
    380        
    381         assert allclose(P_relative, P - [0.1, 2.0])
     380        #P_relative = G.get_data_points(absolute=False)
     381        #
     382        #assert allclose(P_relative, P - [0.1, 2.0])
    382383
    383384        assert allclose(P, concatenate( (P1,P2) ))
     
    423424        G = G1 + G2
    424425       
    425         assert allclose(G.get_geo_reference().get_xllcorner(), 1.0)
    426         assert allclose(G.get_geo_reference().get_yllcorner(), 2.0)
     426        #assert allclose(G.get_geo_reference().get_xllcorner(), 1.0)
     427        #assert allclose(G.get_geo_reference().get_yllcorner(), 2.0)
    427428
    428429        P = G.get_data_points(absolute=True)
    429430
    430         P_relative = G.get_data_points(absolute=False)
    431        
    432         assert allclose(P_relative, [[1.0, 2.1], [3.0, 5.3], [4.1, 7.1], [5.1, 4.3]])
     431        #P_relative = G.get_data_points(absolute=False)
     432        #
     433        #assert allclose(P_relative, [[1.0, 2.1], [3.0, 5.3], [4.1, 7.1], [5.1, 4.3]])
    433434
    434435        assert allclose(P, concatenate( (points1,points2) ))
Note: See TracChangeset for help on using the changeset viewer.