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

Addition to URS_points_needed_to_file so it can do the Northern hemisphere.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.