Changeset 4024


Ignore:
Timestamp:
Nov 21, 2006, 4:50:59 PM (17 years ago)
Author:
duncan
Message:

fix bug reported in ticket#109, with ferret2sww

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

Legend:

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

    r4014 r4024  
    743743
    744744
    745 #### NEED national exposure database
     745#### NED is national exposure database
    746746   
    747747LAT_TITLE = 'LATITUDE'
     
    26802680    else:
    26812681        jmin = searchsorted(times, mint)
    2682 
     2682       
    26832683    if maxt == None:
    26842684        jmax=len(times)
     
    26862686        jmax = searchsorted(times, maxt)
    26872687
    2688     if minlat == None:
    2689         kmin=0
    2690     else:
    2691         kmin = searchsorted(latitudes, minlat)
    2692 
    2693     if maxlat == None:
    2694         kmax = len(latitudes)
    2695     else:
    2696         kmax = searchsorted(latitudes, maxlat)
    2697 
    2698     if minlon == None:
    2699         lmin=0
    2700     else:
    2701         lmin = searchsorted(longitudes, minlon)
    2702 
    2703     if maxlon == None:
    2704         lmax = len(longitudes)
    2705     else:
    2706         lmax = searchsorted(longitudes, maxlon)
     2688    kmin, kmax, lmin, lmax = _get_min_max_indexes(latitudes[:],
     2689                                                  longitudes[:],
     2690                                                 minlat, maxlat,
     2691                                                 minlon, maxlon)
     2692
    27072693
    27082694#    print' j', jmin, jmax
     
    39213907
    39223908    # reverse order of lat, so it's in ascending order
     3909    try:
     3910        latitudes = latitudes.tolist()
     3911    except:
     3912        pass
     3913   
    39233914    latitudes.reverse()
     3915   
    39243916    largest_lat_index = len(latitudes)-1
    39253917    #Cut out a smaller extent.
  • anuga_core/source/anuga/shallow_water/test_data_manager.py

    r4013 r4024  
    23142314
    23152315
     2316    def test_ferret2sww_lat_long(self):
     2317        # Test that min lat long works
     2318
     2319        #The test file has
     2320        # LON = 150.66667, 150.83334, 151, 151.16667
     2321        # LAT = -34.5, -34.33333, -34.16667, -34 ;
     2322        # TIME = 0, 0.1, 0.6, 1.1, 1.6, 2.1 ;
     2323        #
     2324        # First value (index=0) in small_ha.nc is 0.3400644 cm,
     2325        # Fourth value (index==3) is -6.50198 cm
     2326
     2327
     2328
     2329        #Read
     2330        from anuga.coordinate_transforms.redfearn import redfearn
     2331        fid = NetCDFFile(self.test_MOST_file + '_ha.nc')
     2332        first_value = fid.variables['HA'][:][0,0,0]
     2333        fourth_value = fid.variables['HA'][:][0,0,3]
     2334        fid.close()
     2335
     2336
     2337        #Call conversion (with zero origin)
     2338        #ferret2sww('small', verbose=False,
     2339        #           origin = (56, 0, 0))
     2340        ferret2sww(self.test_MOST_file, verbose=False,
     2341                   origin = (56, 0, 0), minlat=-34.5, maxlat=-34)
     2342
     2343        #Work out the UTM coordinates for first point
     2344        zone, e, n = redfearn(-34.5, 150.66667)
     2345        #print zone, e, n
     2346
     2347        #Read output file 'small.sww'
     2348        #fid = NetCDFFile('small.sww')
     2349        fid = NetCDFFile(self.test_MOST_file + '.sww')
     2350
     2351        x = fid.variables['x'][:]
     2352        y = fid.variables['y'][:]
     2353        #Check that first coordinate is correctly represented
     2354        assert 16 == len(x)
     2355
     2356        fid.close()
     2357
     2358        #Cleanup
     2359        import os
     2360        os.remove(self.test_MOST_file + '.sww')
     2361
    23162362
    23172363    def test_ferret2sww3(self):
     
    48474893if __name__ == "__main__":
    48484894    #suite = unittest.makeSuite(Test_Data_Manager,'test_lon')
    4849     #suite = unittest.makeSuite(Test_Data_Manager,'test_urs2sww')
     4895    #suite = unittest.makeSuite(Test_Data_Manager,'test_ferret2sww_lat_long')
    48504896    suite = unittest.makeSuite(Test_Data_Manager,'test')
    48514897    runner = unittest.TextTestRunner()
Note: See TracChangeset for help on using the changeset viewer.