Changeset 3262


Ignore:
Timestamp:
Jun 30, 2006, 3:19:05 PM (18 years ago)
Author:
duncan
Message:

using/expanding ensure_absolute

Location:
inundation
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • inundation/geospatial_data/geospatial_data.py

    r3177 r3262  
    697697                 relative to their respective origins.
    698698    """
     699    if isinstance(points,type('')):
     700        #It's a string
     701        #assume it is a point file
     702        points = Geospatial_data(file_name = points)
     703       
    699704    if isinstance(points,Geospatial_data):
    700705        points = points.get_data_points( \
     
    733738    """
    734739    if isinstance(points,Geospatial_data):
    735         #points = points.get_data_points( \
    736         #        absolute = True)
    737740        msg = "Use a Geospatial_data object or a mesh origin. Not both."
    738741        assert geo_reference == None, msg
     
    741744        points = ensure_numeric(points, Float)
    742745    if geo_reference is None:
    743         geo = None #Geo_reference()
     746        geo = None
    744747    else:
    745748        if isinstance(geo_reference, Geo_reference):
     
    749752                                geo_reference[1],
    750753                                geo_reference[2])
    751         points = Geospatial_data(data_points=points, geo_reference=geo)
    752         #points = geo.get_absolute(points)
     754        points = Geospatial_data(data_points=points, geo_reference=geo)       
    753755    return points
    754756             
  • inundation/geospatial_data/test_geospatial_data.py

    r3177 r3262  
    10311031        assert allclose(new_points, ab_points)
    10321032
     1033       
     1034        fileName = tempfile.mktemp(".xya")
     1035        file = open(fileName,"w")
     1036        file.write("  elevation   speed \n\
     10371.0 0.0 10.0 0.0\n\
     10380.0 1.0 0.0 10.0\n\
     10391.0 0.0 10.4 40.0\n\
     1040#geocrap\n\
     104156\n\
     104210\n\
     104320\n")
     1044        file.close()
     1045       
     1046        ab_points = ensure_absolute(fileName)
     1047        actual =  [[11, 20.0],[10.0, 21.0],[11.0, 20.0]]
     1048        assert allclose(ab_points, actual)
     1049        os.remove(fileName)
     1050
    10331051       
    10341052    def test_ensure_geospatial(self):
  • inundation/pyvolution/util.py

    r3221 r3262  
    55"""
    66
    7 
    87import utilities.polygon
    98from warnings import warn
     9
     10from geospatial_data.geospatial_data import ensure_absolute
    1011
    1112
     
    4647                 a tuple of values - one for each quantity 
    4748
    48     interpolation_points - list of absolute UTM coordinates for points (N x 2) at
    49     which values are sought
     49    interpolation_points - list of absolute UTM coordinates for points (N x 2)
     50    or geospatial object or points file name at which values are sought
    5051   
    5152    use_cache: True means that caching of intermediate result of
     
    103104    #In fact, this is where origin should be converted to that of domain
    104105    #Also, check that file covers domain fully.
    105     #If we use the suggested Point_set class for interpolation points
    106     #here it would be easier
    107106
    108107    #Take into account:
     
    173172    from Scientific.IO.NetCDF import NetCDFFile
    174173    from Numeric import array, zeros, Float, alltrue, concatenate, reshape
    175     from utilities.numerical_tools import ensure_numeric   
    176174
    177175    #Open NetCDF file
     
    197195
    198196    if interpolation_points is not None:
    199         interpolation_points = ensure_numeric(interpolation_points, Float)
     197        interpolation_points = ensure_absolute(interpolation_points)
    200198        msg = 'Points must by N x 2. I got %d' %interpolation_points.shape[1]
    201199        assert interpolation_points.shape[1] == 2, msg
     
    569567   
    570568    gauge_filename  - name of file containing gauge data
    571                         - name, easting, northing
     569                        - easting, northing, name , elevation?
    572570                    - OR (this is not yet done)
    573571                        - structure which can be converted to a Numeric array,
     
    669667        report = False
    670668       
    671     assert type(plot_quantity) == list,\
    672                'plot_quantity must be a list'
    673669   
    674670    if plot_quantity is None:
    675671        plot_quantity = ['depth', 'speed', 'bearing']
    676672    else:
     673        assert type(plot_quantity) == list,\
     674               'plot_quantity must be a list'
    677675        check_list(plot_quantity)
    678676
     
    741739                            time_min, time_max, title_on, label_id, verbose)
    742740                         
    743 
     741#Fixme - Use geospatial to read this file - it's an xya file
    744742def get_gauges_from_file(filename):
    745743    from os import sep, getcwd, access, F_OK, mkdir
Note: See TracChangeset for help on using the changeset viewer.