Changeset 5253


Ignore:
Timestamp:
Apr 30, 2008, 11:44:10 AM (17 years ago)
Author:
duncan
Message:

Addition to URS_points_needed_to_file so it can do the Northern hemisphere.

Location:
anuga_core/source/anuga
Files:
3 edited

Legend:

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

    r5251 r5253  
    902902    if data_points is not None and not points_are_lats_longs:
    903903        msg = """Data points are specified yet latitude and
    904         longitude are also specified!"""
     904        longitude are also specified."""
    905905        raise ValueError, msg
    906906   
    907907    if points_are_lats_longs:
    908908        if data_points is None:
    909             msg = """Data points are not specified !"""
     909            msg = """Data points are not specified."""
    910910            raise ValueError, msg
    911911        lats_longs = ensure_numeric(data_points)
    912 
    913912        latitudes = ravel(lats_longs[:,0:1])
    914913        longitudes = ravel(lats_longs[:,1:])
    915914       
    916915    if latitudes is None and longitudes is None:
    917         msg = """Latitudes and Longitudes are not."""
     916        msg = """Latitudes and Longitudes are not specified."""
    918917        raise ValueError, msg
    919918   
    920919    if latitudes is None:
    921         msg = """Longitudes are specified yet latitudes aren't!"""
     920        msg = """Longitudes are specified yet latitudes aren't."""
    922921        raise ValueError, msg
    923922   
    924923    if longitudes is None:
    925         msg = """Latitudes are specified yet longitudes aren't!"""
     924        msg = """Latitudes are specified yet longitudes aren't."""
    926925        raise ValueError, msg
    927926   
  • anuga_core/source/anuga/shallow_water/data_manager.py

    r5250 r5253  
    44204420                              grid_spacing,
    44214421                              lat_amount, long_amount,
     4422                              isSouthernHemisphere=True,
    44224423                              export_csv=False, use_cache=False,
    44234424                              verbose=False):
    44244425    """
     4426    Given the info to replicate the URS grid and a polygon output
     4427    a file that specifies the cloud of boundary points for URS.
     4428   
     4429    Note: The polygon cannot cross zones or hemispheres.
     4430   
    44254431    file_name - name of the urs file produced for David.
    44264432    boundary_polygon - a list of points that describes a polygon.
     
    44294435
    44304436     This is info about the URS model that needs to be inputted.
    4431      If you do not, default values will be used, which may be incorrect.
     4437     
    44324438    ll_lat - lower left latitude, in decimal degrees
    44334439    ll-long - lower left longitude, in decimal degrees
     
    44414447    geo = URS_points_needed(boundary_polygon, zone, ll_lat, ll_long,
    44424448                            grid_spacing,
    4443                             lat_amount, long_amount,use_cache, verbose)
     4449                            lat_amount, long_amount, isSouthernHemisphere,
     4450                            use_cache, verbose)
    44444451    if not file_name[-4:] == ".urs":
    44454452        file_name += ".urs"
    4446     geo.export_points_file(file_name)
     4453    geo.export_points_file(file_name, isSouthHemisphere=isSouthernHemisphere)
    44474454    if export_csv:
    44484455        if file_name[-4:] == ".urs":
     
    44524459def URS_points_needed(boundary_polygon, zone, ll_lat,
    44534460                      ll_long, grid_spacing,
    4454                       lat_amount, long_amount,
     4461                      lat_amount, long_amount, isSouthHemisphere=True,
    44554462                      use_cache=False, verbose=False):
    44564463    args = (boundary_polygon,
    4457                       zone)
    4458     kwargs = {'ll_lat': ll_lat,
    4459               'll_long': ll_long,
    4460               'grid_spacing': grid_spacing,
    4461               'lat_amount': lat_amount,
    4462               'long_amount': long_amount} 
     4464            zone, ll_lat,
     4465            ll_long, grid_spacing,
     4466            lat_amount, long_amount, isSouthHemisphere)
     4467    kwargs = {} 
    44634468    if use_cache is True:
    44644469        try:
     
    44754480                  compression=False)
    44764481    else:
    4477         #I was getting 'got multiple values for keyword argument' errors
    4478         #geo = apply(_URS_points_needed, args, kwargs)
    4479         geo = _URS_points_needed(boundary_polygon,
    4480                                  zone, ll_lat,
    4481                                  ll_long, grid_spacing,
    4482                                  lat_amount, long_amount)
     4482        geo = apply(_URS_points_needed, args, kwargs)
    44834483
    44844484    return geo
     
    44874487                      zone, ll_lat,
    44884488                      ll_long, grid_spacing,
    4489                       lat_amount, long_amount):
    4490     """
    4491 
     4489                      lat_amount, long_amount,
     4490                       isSouthHemisphere):
     4491    """
    44924492    boundary_polygon - a list of points that describes a polygon.
    44934493                      The last point is assumed ot join the first point.
     
    45074507    # List of segments.  Each segment is two points.
    45084508    segs = [i and [a[i-1], a[i]] or [a[len(a)-1], a[0]] for i in range(len(a))]
    4509 
    45104509    # convert the segs to Lat's and longs.
    45114510   
     
    45164515    for seg in segs:
    45174516        points_lat_long = points_needed(seg, ll_lat, ll_long, grid_spacing,
    4518                       lat_amount, long_amount, zone)
     4517                      lat_amount, long_amount, zone, isSouthHemisphere)
    45194518        lat_long_set |= ImmutableSet(points_lat_long)
    4520     #print "lat_long_set",lat_long_set
     4519    if lat_long_set == ImmutableSet([]):
     4520        msg = """URS region specified and polygon does not overlap."""
     4521        raise ValueError, msg
     4522
     4523    # Warning there is no info in geospatial saying the hemisphere of
     4524    # these points.  There should be.
    45214525    geo = Geospatial_data(data_points=list(lat_long_set),
    45224526                              points_are_lats_longs=True)
     
    45244528   
    45254529def points_needed(seg, ll_lat, ll_long, grid_spacing,
    4526                   lat_amount, long_amount, zone):
    4527     """
     4530                  lat_amount, long_amount, zone,
     4531                  isSouthHemisphere):
     4532    """
     4533    seg is one point, in UTM
    45284534    return a list of the points, in lats and longs that are needed to
    45294535    interpolate any point on the segment.
     
    45324538    #print "zone",zone
    45334539    geo_reference = Geo_reference(zone=zone)
    4534     #print "seg",seg
    45354540    geo = Geospatial_data(seg,geo_reference=geo_reference)
    4536     seg_lat_long = geo.get_data_points(as_lat_long=True)
    4537     #print "seg_lat_long", seg_lat_long
     4541    seg_lat_long = geo.get_data_points(as_lat_long=True,
     4542                                       isSouthHemisphere=isSouthHemisphere)
    45384543    # 1.415 = 2^0.5, rounded up....
    45394544    sqrt_2_rounded_up = 1.415
  • anuga_core/source/anuga/shallow_water/test_data_manager.py

    r5250 r5253  
    61446144
    61456145
    6146     def Xtest_URS_points_needed_poly2(self):
     6146    def test_URS_points_needed_poly2(self):
    61476147        # Values used for 2004 validation work
    61486148        # domain in northern hemisphere zone 47       
     
    61696169                                  GRID_SPACING,
    61706170                                  LAT_AMOUNT, LONG_AMOUNT,
     6171                                  isSouthernHemisphere=False,
    61716172                                  verbose=self.verbose)
    61726173       
     
    75617562    suite = unittest.makeSuite(Test_Data_Manager,'test')
    75627563    #suite = unittest.makeSuite(Test_Data_Manager,'test_get_flow_through_cross_section')
    7563     #suite = unittest.makeSuite(Test_Data_Manager,'test_urs_ungridded_holeII')
     7564    #suite = unittest.makeSuite(Test_Data_Manager,'Xtest')
    75647565
    75657566   
Note: See TracChangeset for help on using the changeset viewer.