Changeset 1797


Ignore:
Timestamp:
Sep 7, 2005, 1:21:00 PM (20 years ago)
Author:
ole
Message:

work on MOST boundary

Location:
inundation/pyvolution
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • inundation/pyvolution/data_manager.py

    r1787 r1797  
    14211421
    14221422
     1423
     1424
    14231425def convert_dem_from_ascii2netcdf(basename_in, basename_out = None,
    14241426                                  verbose=False):
     
    15781580
    15791581    fid.close()
     1582
     1583
    15801584
    15811585
     
    16461650    longitudes = file_h.variables['LON']
    16471651
     1652
     1653    e_lat = file_e.variables['LAT'][:]
     1654
     1655
     1656    #Check that files are compatible
     1657    from Numeric import allclose
     1658    assert allclose(latitudes, file_u.variables['LAT'])
     1659    assert allclose(latitudes, file_v.variables['LAT'])   
     1660    assert allclose(latitudes, file_e.variables['LAT'])
     1661
     1662    assert allclose(longitudes, file_u.variables['LON'])
     1663    assert allclose(longitudes, file_v.variables['LON'])
     1664    assert allclose(longitudes, file_e.variables['LON'])   
     1665
     1666
     1667
    16481668    if mint == None:
    16491669        jmin = 0
     
    16841704
    16851705    if verbose: print 'cropping'
     1706    zname = 'ELEVATION'
     1707
     1708   
    16861709    amplitudes = file_h.variables['HA'][jmin:jmax, kmin:kmax, lmin:lmax]
    16871710    uspeed = file_u.variables['UA'][jmin:jmax, kmin:kmax, lmin:lmax] #Lon
    16881711    vspeed = file_v.variables['VA'][jmin:jmax, kmin:kmax, lmin:lmax] #Lat
    1689     elevations = file_e.variables['ELEVATION'][kmin:kmax, lmin:lmax]
     1712    elevations = file_e.variables[zname][kmin:kmax, lmin:lmax]
    16901713
    16911714#    if latitudes2[0]==latitudes[0] and latitudes2[-1]==latitudes[-1]:
     
    17091732    nan_ua = file_u.variables['UA'].missing_value[0]
    17101733    nan_va = file_v.variables['VA'].missing_value[0]
    1711     if hasattr(file_e.variables['ELEVATION'],'missing_value'):
    1712         nan_e  = file_e.variables['ELEVATION'].missing_value[0]
     1734    if hasattr(file_e.variables[zname],'missing_value'):
     1735        nan_e  = file_e.variables[zname].missing_value[0]
    17131736    else:
    17141737        nan_e = None
     
    19792002              %(min(times), max(times), len(times))
    19802003        print '  Quantities [SI units]:'
    1981         for name in ['stage', 'xmomentum', 'ymomentum']:
    1982             q = outfile.variables[name][:].flferret2swwat
     2004        for name in ['stage', 'xmomentum', 'ymomentum', 'elevation']:
     2005            q = outfile.variables[name][:].flat
    19832006            print '    %s in [%f, %f]' %(name, min(q), max(q))
    19842007
  • inundation/pyvolution/test_data_manager.py

    r1753 r1797  
    12561256
    12571257    def test_ferret2sww3(self):
    1258         """
     1258        """Elevation included
    12591259        """
    12601260        from Scientific.IO.NetCDF import NetCDFFile
     
    14141414
    14151415
     1416    def test_ferret2sww_nz_origin(self):
     1417        from Scientific.IO.NetCDF import NetCDFFile
     1418        from coordinate_transforms.redfearn import redfearn
     1419
     1420        #Call conversion (with nonzero origin)
     1421        ferret2sww('small', verbose=False,
     1422                   origin = (56, 100000, 200000))
     1423
     1424
     1425        #Work out the UTM coordinates for first point
     1426        zone, e, n = redfearn(-34.5, 150.66667)
     1427
     1428        #Read output file 'small.sww'
     1429        fid = NetCDFFile('small.sww', 'r')
     1430
     1431        x = fid.variables['x'][:]
     1432        y = fid.variables['y'][:]
     1433
     1434        #Check that first coordinate is correctly represented
     1435        assert allclose(x[0], e-100000)
     1436        assert allclose(y[0], n-200000)
     1437
     1438        fid.close()
     1439
     1440        #Cleanup
     1441        import os
     1442        os.remove('small.sww')
     1443
     1444
     1445
    14161446    def test_sww_extent(self):
    14171447        """Not a test, rather a look at the sww format
     
    14571487
    14581488
    1459     def test_ferret2sww_nz_origin(self):
    1460         from Scientific.IO.NetCDF import NetCDFFile
    1461         from coordinate_transforms.redfearn import redfearn
    1462 
    1463         #Call conversion (with nonzero origin)
    1464         ferret2sww('small', verbose=False,
    1465                    origin = (56, 100000, 200000))
    1466 
    1467 
    1468         #Work out the UTM coordinates for first point
    1469         zone, e, n = redfearn(-34.5, 150.66667)
    1470 
    1471         #Read output file 'small.sww'
    1472         fid = NetCDFFile('small.sww', 'r')
    1473 
    1474         x = fid.variables['x'][:]
    1475         y = fid.variables['y'][:]
    1476 
    1477         #Check that first coordinate is correctly represented
    1478         assert allclose(x[0], e-100000)
    1479         assert allclose(y[0], n-200000)
    1480 
    1481         fid.close()
    1482 
    1483         #Cleanup
    1484         import os
    1485         os.remove('small.sww')
    14861489
    14871490    def test_sww2domain(self):
Note: See TracChangeset for help on using the changeset viewer.