Changeset 4284


Ignore:
Timestamp:
Feb 27, 2007, 4:48:19 PM (18 years ago)
Author:
duncan
Message:

added caching to ungridded urs2sww

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

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/shallow_water/data_manager.py

    r4283 r4284  
    43834383
    43844384    ### PRODUCING THE POINTS NEEDED FILE ###
    4385 def URS_points_needed_to_file(file_name, boundary_polygon, ll_lat, ll_long,
    4386                               grid_spacing,
    4387                       lat_amount, long_amount, zone=None):
     4385LL_LAT = -50.0
     4386LL_LONG = 80.0
     4387GRID_SPACING = 1.0/60.0
     4388LAT_AMOUNT = 4800
     4389LONG_AMOUNT = 3600
     4390def URS_points_needed_to_file(file_name, boundary_polygon,
     4391                              ll_lat=LL_LAT, ll_long=LL_LONG,
     4392                              grid_spacing=GRID_SPACING,
     4393                              lat_amount=LAT_AMOUNT, long_amount=LONG_AMOUNT,
     4394                              zone=None, export_csv=False, use_cache=False,
     4395                              verbose=False):
    43884396    """
    43894397    file_name - name of the urs file produced for David.
     
    44004408    """
    44014409    geo = URS_points_needed(boundary_polygon, ll_lat, ll_long, grid_spacing,
    4402                       lat_amount, long_amount, zone=zone)
     4410                      lat_amount, long_amount, zone, use_cache, verbose)
    44034411    if not file_name[-4:] == ".urs":
    44044412        file_name += ".urs"
    44054413    geo.export_points_file(file_name)
    4406    
    4407 def URS_points_needed(boundary_polygon, ll_lat=-50.0,
    4408                       ll_long=80.0, grid_spacing=1.0/60.0,
    4409                       lat_amount=4800, long_amount=3600, zone=None):
     4414    if export_csv:
     4415        if file_name[-4:] == ".urs":
     4416            file_name = file_name[:-4] + ".csv"
     4417        geo.export_points_file(file_name)
     4418
     4419def URS_points_needed(boundary_polygon, ll_lat=LL_LAT,
     4420                      ll_long=LL_LONG, grid_spacing=GRID_SPACING,
     4421                      lat_amount=LAT_AMOUNT, long_amount=LONG_AMOUNT,
     4422                      zone=None, use_cache=False, verbose=False):
     4423    args = (boundary_polygon)
     4424    kwargs = {'ll_lat': ll_lat,
     4425              'll_long': ll_long,
     4426              'grid_spacing': grid_spacing,
     4427              'lat_amount': lat_amount,
     4428              'long_amount': long_amount,
     4429              'zone': zone} 
     4430    if use_cache is True:
     4431        try:
     4432            from anuga.caching import cache
     4433        except:
     4434            msg = 'Caching was requested, but caching module'+\
     4435                  'could not be imported'
     4436            raise msg
     4437
     4438
     4439        geo = cache(_URS_points_needed,
     4440                  args, kwargs,
     4441                  verbose=verbose,
     4442                  compression=False)
     4443    else:
     4444        #I was getting 'got multiple values for keyword argument' errors
     4445        #geo = apply(_URS_points_needed, args, kwargs)
     4446        geo = _URS_points_needed(boundary_polygon, ll_lat,
     4447                      ll_long, grid_spacing,
     4448                      lat_amount, long_amount,
     4449                      zone)
     4450
     4451    return geo   
     4452def _URS_points_needed(boundary_polygon, ll_lat=LL_LAT,
     4453                      ll_long=LL_LONG, grid_spacing=GRID_SPACING,
     4454                      lat_amount=LAT_AMOUNT, long_amount=LONG_AMOUNT,
     4455                      zone=None):
    44104456    """
    44114457
  • anuga_core/source/anuga/shallow_water/test_data_manager.py

    r4281 r4284  
    54595459        self.delete_mux(files)
    54605460        os.remove( base_name + '.sww')
     5461   
     5462    def cache_test_URS_points_needed_and_urs_ungridded2sww(self):
     5463       
     5464        ll_lat = -21.5
     5465        ll_long = 114.5
     5466        grid_spacing = 1./60.
     5467        lat_amount = 30
     5468        long_amount = 30
     5469        time_step_count = 2
     5470        time_step = 400
     5471        tide = -200000
     5472
     5473        boundary_polygon = [[250000,7660000],[270000,7650000],
     5474                             [280000,7630000],[250000,7630000]]
     5475        geo=URS_points_needed(boundary_polygon,
     5476                              ll_lat, ll_long, grid_spacing,
     5477                              lat_amount, long_amount, use_cache=True,
     5478                              verbose=True)
    54615479       
    54625480    def visual_test_URS_points_needed_and_urs_ungridded2sww(self):
     
    54955513if __name__ == "__main__":
    54965514    #suite = unittest.makeSuite(Test_Data_Manager,'davids_test_points_urs_ungridded2sww')
    5497     #suite = unittest.makeSuite(Test_Data_Manager,'test_urs_ungridded2swwII')
     5515    #suite = unittest.makeSuite(Test_Data_Manager,'cache_test_URS_points_needed_and_urs_ungridded2sww')
    54985516    #suite = unittest.makeSuite(Test_Data_Manager,'visual_test_URS_points_needed_and_urs_ungridded2sww')
    54995517    suite = unittest.makeSuite(Test_Data_Manager,'test')
Note: See TracChangeset for help on using the changeset viewer.