Changeset 8819


Ignore:
Timestamp:
Apr 6, 2013, 7:13:07 PM (12 years ago)
Author:
steve
Message:

Changes to reading pts file using netcdf4

Location:
trunk/anuga_core/source
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/anuga_core/source/anuga/file_conversion/test_csv2sts.py

    r8780 r8819  
    9090    def _check_generated_sts(self):
    9191        """ check that we can read data out of the file """
    92         sts = NetCDFFile(sts_out)
     92        sts = NetCDFFile(sts_out,'r')
    9393       
    9494        data, names = load_csv_as_dict(testfile_csv, delimiter=' ', d_type = num.float64)
  • trunk/anuga_core/source/anuga/geometry

    • Property svn:ignore set to
      .python_cache
  • trunk/anuga_core/source/anuga/geometry/polygon.py

    r8361 r8819  
    723723    """
    724724
    725     from pylab import ion, hold, plot, savefig, xlabel, \
     725    from pylab import ion, ioff, hold, plot, savefig, xlabel, \
    726726                      ylabel, title, close, title, fill
    727727
     
    777777        savefig('test_image')
    778778
     779    ioff()
     780    hold(False)
    779781    close('all')
    780782
  • trunk/anuga_core/source/anuga/geometry/test_polygon.py

    r8341 r8819  
    17811781        plot_polygons([polygon1, polygon2], figname='test1')
    17821782
     1783        import pylab
     1784        pylab.close('all')
     1785
    17831786        # Another case
    17841787        polygon3 = [[1,5], [10,1], [100,10], [50,10], [3,6]]
    17851788        plot_polygons([polygon2, polygon3], figname='test2')
     1789
     1790        pylab.close('all')
    17861791
    17871792        for file in ['test1.png', 'test2.png']:
  • trunk/anuga_core/source/anuga/geospatial_data/geospatial_data.py

    r8780 r8819  
    877877    fid = NetCDFFile(file_name, netcdf_mode_r)
    878878
    879     pointlist = num.array(fid.variables['points'])
     879    pointlist = fid.variables['points'][:]
    880880    keys = fid.variables.keys()
    881881
     
    893893        if verbose: log.critical("Geospatial_data: Reading attribute '%s'" % key)
    894894
    895         attributes[key] = num.array(fid.variables[key])
     895        if not (key == 'points'):
     896            attributes[key] = fid.variables[key][:]
    896897
    897898    try:
  • trunk/anuga_core/source/anuga/shallow_water/sww_interrogate.py

    r8780 r8819  
    407407            msg += 'must does not match model time interval: [%.8f, %.8f]\n' \
    408408                   % (time[0], time[-1])
    409             if time_interval[1] < time[0]: raise ValueError(msg)
    410             if time_interval[0] > time[-1]: raise ValueError(msg)
     409            if time_interval[1] < time[0]:
     410                fid.close()
     411                raise ValueError(msg)
     412            if time_interval[0] > time[-1]:
     413                fid.close()
     414                raise ValueError(msg)
    411415
    412416            # Take time indices corresponding to interval (& is bitwise AND)
  • trunk/anuga_core/source/anuga/shallow_water/test_sww_interrogate.py

    r8780 r8819  
    5454        domain.set_minimum_storable_height(0.01)
    5555
    56         domain.set_name('runuptest')
     56        filename = 'runup_test_3'
     57        domain.set_name(filename)
    5758        swwfile = domain.get_name() + '.sww'
    5859
     
    527528        final_runup_height = -0.3
    528529
     530        filename = 'runup_test_1'
     531
    529532        #--------------------------------------------------------------
    530533        # Setup computational domain
     
    533536        points, vertices, boundary = rectangular_cross(N, N)
    534537        domain = Domain(points, vertices, boundary)
    535         domain.set_name('runup_test')
     538        domain.set_name(filename)
    536539        domain.set_maximum_allowed_speed(1.0)
    537540
     
    582585        #--------------------------------------------------------------
    583586        q_ref = domain.get_maximum_inundation_elevation()
    584         q = get_maximum_inundation_elevation('runup_test.sww')
     587        q = get_maximum_inundation_elevation(filename+'.sww')
    585588        msg = 'We got %f, should have been %f' % (q, q_ref)
    586589        assert num.allclose(q, q_ref, rtol=1.0/N), msg
    587590
    588         q = get_maximum_inundation_elevation('runup_test.sww')
     591        q = get_maximum_inundation_elevation(filename+'.sww')
    589592        msg = 'We got %f, should have been %f' % (q, initial_runup_height)
    590593        assert num.allclose(q, initial_runup_height, rtol = 1.0/N), msg
     
    592595        # Test error condition if time interval is out
    593596        try:
    594             q = get_maximum_inundation_elevation('runup_test.sww',
     597            q = get_maximum_inundation_elevation(filename+'.sww',
    595598                                                 time_interval=[2.0, 3.0])
    596599        except ValueError:
     
    601604
    602605        # Check correct time interval
    603         q, loc = get_maximum_inundation_data('runup_test.sww',
     606        q, loc = get_maximum_inundation_data(filename+'.sww',
    604607                                             time_interval=[0.0, 3.0])
    605608        msg = 'We got %f, should have been %f' % (q, initial_runup_height)
     
    635638        assert num.allclose(q, final_runup_height, rtol=1.0/N)
    636639
    637         q, loc = get_maximum_inundation_data('runup_test.sww',
     640        q, loc = get_maximum_inundation_data(filename+'.sww',
    638641                                             time_interval=[3.0, 3.0])
    639642        msg = 'We got %f, should have been %f' % (q, final_runup_height)
     
    641644        assert num.allclose(-loc[0]/2, q)    # From topography formula
    642645
    643         q = get_maximum_inundation_elevation('runup_test.sww')
    644         loc = get_maximum_inundation_location('runup_test.sww')
     646        q = get_maximum_inundation_elevation(filename+'.sww')
     647        loc = get_maximum_inundation_location(filename+'.sww')
    645648        msg = 'We got %f, should have been %f' % (q, q_max)
    646649        assert num.allclose(q, q_max, rtol=1.0/N), msg
    647650        assert num.allclose(-loc[0]/2, q)    # From topography formula
    648651
    649         q = get_maximum_inundation_elevation('runup_test.sww',
     652        q = get_maximum_inundation_elevation(filename+'.sww',
    650653                                             time_interval=[0, 3])
    651654        msg = 'We got %f, should have been %f' % (q, q_max)
     
    655658        # Runup region
    656659        polygon = [[0.3, 0.0], [0.9, 0.0], [0.9, 1.0], [0.3, 1.0]]
    657         q = get_maximum_inundation_elevation('runup_test.sww',
     660        q = get_maximum_inundation_elevation(filename+'.sww',
    658661                                             polygon = polygon,
    659662                                             time_interval=[0, 3])
     
    663666        # Offshore region
    664667        polygon = [[0.9, 0.0], [1.0, 0.0], [1.0, 1.0], [0.9, 1.0]]
    665         q, loc = get_maximum_inundation_data('runup_test.sww',
     668        q, loc = get_maximum_inundation_data(filename+'.sww',
    666669                                             polygon = polygon,
    667670                                             time_interval=[0, 3])
     
    673676        # Dry region
    674677        polygon = [[0.0, 0.0], [0.4, 0.0], [0.4, 1.0], [0.0, 1.0]]
    675         q, loc = get_maximum_inundation_data('runup_test.sww',
     678        q, loc = get_maximum_inundation_data(filename+'.sww',
    676679                                             polygon = polygon,
    677680                                             time_interval=[0, 3])
     
    683686        # Check what happens if no time point is within interval
    684687        try:
    685             q = get_maximum_inundation_elevation('runup_test.sww',
     688            q = get_maximum_inundation_elevation(filename+'.sww',
    686689                                                 time_interval=[2.75, 2.75])
    687690        except AssertionError:
     
    713716        initial_runup_height = -0.4
    714717        final_runup_height = -0.3
     718        filename = 'runup_test_2'
    715719
    716720        #--------------------------------------------------------------
     
    720724        points, vertices, boundary = rectangular_cross(N, N)
    721725        domain = Domain(points, vertices, boundary)
    722         domain.set_name('runup_test')
     726        domain.set_name(filename)
    723727        domain.set_maximum_allowed_speed(1.0)
    724728
     
    769773        #--------------------------------------------------------------
    770774        q_ref = domain.get_maximum_inundation_elevation()
    771         q = get_maximum_inundation_elevation('runup_test.sww')
     775        q = get_maximum_inundation_elevation(filename+'.sww')
    772776        msg = 'We got %f, should have been %f' % (q, q_ref)
    773777        assert num.allclose(q, q_ref, rtol=1.0/N), msg
    774778
    775         q = get_maximum_inundation_elevation('runup_test.sww')
     779        q = get_maximum_inundation_elevation(filename+'.sww')
    776780        msg = 'We got %f, should have been %f' % (q, initial_runup_height)
    777781        assert num.allclose(q, initial_runup_height, rtol = 1.0/N), msg
     
    779783        # Test error condition if time interval is out
    780784        try:
    781             q = get_maximum_inundation_elevation('runup_test.sww',
     785            q = get_maximum_inundation_elevation(filename+'.sww',
    782786                                                 time_interval=[2.0, 3.0])
    783787        except ValueError:
     
    788792
    789793        # Check correct time interval
    790         q, loc = get_maximum_inundation_data('runup_test.sww',
     794        q, loc = get_maximum_inundation_data(filename+'.sww',
    791795                                             time_interval=[0.0, 3.0])
    792796        msg = 'We got %f, should have been %f' % (q, initial_runup_height)
     
    822826        assert num.allclose(q, final_runup_height, rtol=1.0/N)
    823827
    824         q, loc = get_maximum_inundation_data('runup_test.sww',
     828        q, loc = get_maximum_inundation_data(filename+'.sww',
    825829                                             time_interval=[3.0, 3.0])
    826830        msg = 'We got %f, should have been %f' % (q, final_runup_height)
     
    828832        assert num.allclose(-loc[0]/2, q)    # From topography formula
    829833
    830         q = get_maximum_inundation_elevation('runup_test.sww')
    831         loc = get_maximum_inundation_location('runup_test.sww')
     834        q = get_maximum_inundation_elevation(filename+'.sww')
     835        loc = get_maximum_inundation_location(filename+'.sww')
    832836        msg = 'We got %f, should have been %f' % (q, q_max)
    833837        assert num.allclose(q, q_max, rtol=1.0/N), msg
    834838        assert num.allclose(-loc[0]/2, q)    # From topography formula
    835839
    836         q = get_maximum_inundation_elevation('runup_test.sww',
     840        q = get_maximum_inundation_elevation(filename+'.sww',
    837841                                             time_interval=[0, 3])
    838842        msg = 'We got %f, should have been %f' % (q, q_max)
     
    842846        # Runup region
    843847        polygon = [[0.3, 0.0], [0.9, 0.0], [0.9, 1.0], [0.3, 1.0]]
    844         q = get_maximum_inundation_elevation('runup_test.sww',
     848        q = get_maximum_inundation_elevation(filename+'.sww',
    845849                                             polygon = polygon,
    846850                                             time_interval=[0, 3])
     
    850854        # Offshore region
    851855        polygon = [[0.9, 0.0], [1.0, 0.0], [1.0, 1.0], [0.9, 1.0]]
    852         q, loc = get_maximum_inundation_data('runup_test.sww',
     856        q, loc = get_maximum_inundation_data(filename+'.sww',
    853857                                             polygon = polygon,
    854858                                             time_interval=[0, 3])
     
    860864        # Dry region
    861865        polygon = [[0.0, 0.0], [0.4, 0.0], [0.4, 1.0], [0.0, 1.0]]
    862         q, loc = get_maximum_inundation_data('runup_test.sww',
     866        q, loc = get_maximum_inundation_data(filename+'.sww',
    863867                                             polygon = polygon,
    864868                                             time_interval=[0, 3])
     
    870874        # Check what happens if no time point is within interval
    871875        try:
    872             q = get_maximum_inundation_elevation('runup_test.sww',
     876            q = get_maximum_inundation_elevation(filename+'.sww',
    873877                                                 time_interval=[2.75, 2.75])
    874878        except AssertionError:
  • trunk/anuga_core/source/anuga/test_all.py

    r8818 r8819  
    269269            try:
    270270                os.remove(file)
    271             except:
     271            except Exception as inst:
    272272                pass
    273273           
  • trunk/anuga_core/source/anuga_validation_tests/Case_studies/Okushiri

    • Property svn:ignore
      •  

        old new  
        11.deps
         2.python_cache
Note: See TracChangeset for help on using the changeset viewer.