Changeset 1797
- Timestamp:
- Sep 7, 2005, 1:21:00 PM (20 years ago)
- Location:
- inundation/pyvolution
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/pyvolution/data_manager.py
r1787 r1797 1421 1421 1422 1422 1423 1424 1423 1425 def convert_dem_from_ascii2netcdf(basename_in, basename_out = None, 1424 1426 verbose=False): … … 1578 1580 1579 1581 fid.close() 1582 1583 1580 1584 1581 1585 … … 1646 1650 longitudes = file_h.variables['LON'] 1647 1651 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 1648 1668 if mint == None: 1649 1669 jmin = 0 … … 1684 1704 1685 1705 if verbose: print 'cropping' 1706 zname = 'ELEVATION' 1707 1708 1686 1709 amplitudes = file_h.variables['HA'][jmin:jmax, kmin:kmax, lmin:lmax] 1687 1710 uspeed = file_u.variables['UA'][jmin:jmax, kmin:kmax, lmin:lmax] #Lon 1688 1711 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] 1690 1713 1691 1714 # if latitudes2[0]==latitudes[0] and latitudes2[-1]==latitudes[-1]: … … 1709 1732 nan_ua = file_u.variables['UA'].missing_value[0] 1710 1733 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] 1713 1736 else: 1714 1737 nan_e = None … … 1979 2002 %(min(times), max(times), len(times)) 1980 2003 print ' Quantities [SI units]:' 1981 for name in ['stage', 'xmomentum', 'ymomentum' ]:1982 q = outfile.variables[name][:].fl ferret2swwat2004 for name in ['stage', 'xmomentum', 'ymomentum', 'elevation']: 2005 q = outfile.variables[name][:].flat 1983 2006 print ' %s in [%f, %f]' %(name, min(q), max(q)) 1984 2007 -
inundation/pyvolution/test_data_manager.py
r1753 r1797 1256 1256 1257 1257 def test_ferret2sww3(self): 1258 """ 1258 """Elevation included 1259 1259 """ 1260 1260 from Scientific.IO.NetCDF import NetCDFFile … … 1414 1414 1415 1415 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 1416 1446 def test_sww_extent(self): 1417 1447 """Not a test, rather a look at the sww format … … 1457 1487 1458 1488 1459 def test_ferret2sww_nz_origin(self):1460 from Scientific.IO.NetCDF import NetCDFFile1461 from coordinate_transforms.redfearn import redfearn1462 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 point1469 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 represented1478 assert allclose(x[0], e-100000)1479 assert allclose(y[0], n-200000)1480 1481 fid.close()1482 1483 #Cleanup1484 import os1485 os.remove('small.sww')1486 1489 1487 1490 def test_sww2domain(self):
Note: See TracChangeset
for help on using the changeset viewer.