Changeset 1875
- Timestamp:
- Oct 6, 2005, 2:38:17 PM (19 years ago)
- Location:
- inundation/pyvolution
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/pyvolution/data_manager.py
r1874 r1875 1211 1211 reduction = None, 1212 1212 cellsize = 10, 1213 easting_min = None, 1214 easting_max = None, 1215 northing_min = None, 1216 northing_max = None, 1213 1217 verbose = False, 1214 1218 origin = None, … … 1277 1281 # Note the use of a .ers extension is optional (write_ermapper_grid will 1278 1282 # deal with either option 1279 # ersfile = basename_out 1280 1283 1284 #Read sww file 1281 1285 if verbose: print 'Reading from %s' %swwfile 1282 #Read sww file1283 1286 from Scientific.IO.NetCDF import NetCDFFile 1284 1287 fid = NetCDFFile(swwfile) … … 1288 1291 y = fid.variables['y'][:] 1289 1292 volumes = fid.variables['volumes'][:] 1290 1291 ymin = min(y); ymax = max(y)1292 xmin = min(x); xmax = max(x)1293 1293 1294 1294 number_of_timesteps = fid.dimensions['number_of_timesteps'] … … 1312 1312 1313 1313 1314 1314 1315 #Get quantity and reduce if applicable 1315 1316 if verbose: print 'Reading quantity %s' %quantity … … 1322 1323 1323 1324 if len(q.shape) == 2: 1325 #q has a time component and needs to be reduced along 1326 #the temporal dimension 1324 1327 if verbose: print 'Reducing quantity %s' %quantity 1325 1328 q_reduced = zeros( number_of_points, Float ) … … 1330 1333 q = q_reduced 1331 1334 1332 #Now q has dimension: number_of_points 1335 #Post condition: Now q has dimension: number_of_points 1336 assert len(q.shape) == 1 1337 assert q.shape[0] == number_of_points 1338 1333 1339 1334 1340 #Create grid and update xll/yll corner and x,y 1341 1342 #Relative extent 1343 if easting_min is None: 1344 xmin = min(x) 1345 else: 1346 xmin = easting_min - xllcorner 1347 1348 if easting_max is None: 1349 xmax = max(x) 1350 else: 1351 xmax = easting_max - xllcorner 1352 1353 if northing_min is None: 1354 ymin = min(y) 1355 else: 1356 ymin = northing_min - yllcorner 1357 1358 if northing_max is None: 1359 ymax = max(y) 1360 else: 1361 ymax = northing_max - yllcorner 1362 1363 1364 1335 1365 if verbose: print 'Creating grid' 1336 1366 ncols = int((xmax-xmin)/cellsize)+1 1337 1367 nrows = int((ymax-ymin)/cellsize)+1 1338 1368 1369 1370 #New absolute reference and coordinates 1339 1371 newxllcorner = xmin+xllcorner 1340 1372 newyllcorner = ymin+yllcorner … … 1371 1403 #FIXME: This should be done with precrop = True (?), otherwise it'll 1372 1404 #take forever. With expand_search set to False, some grid points might 1373 #miss out.... 1405 #miss out.... This will be addressed though Duncan's refactoring of least_squares 1374 1406 1375 1407 interp = Interpolation(vertex_points, volumes, grid_points, alpha=0.0, … … 1474 1506 origin = None): 1475 1507 print 'sww2asc will soon be obsoleted - please use sww2dem' 1476 sww2dem(basename_in, 1477 basename_out ,1478 quantity ,1479 timestep ,1480 reduction ,1481 cellsize ,1482 verbose ,1483 origin ,1508 sww2dem(basename_in, 1509 basename_out = basename_out, 1510 quantity = quantity, 1511 timestep = timestep, 1512 reduction = reduction, 1513 cellsize = cellsize, 1514 verbose = verbose, 1515 origin = origin, 1484 1516 datum = 'WGS84', 1485 1517 format = 'asc') … … 1495 1527 print 'sww2ers will soon be obsoleted - please use sww2dem' 1496 1528 sww2dem(basename_in, 1497 basename_out ,1498 quantity ,1499 timestep ,1500 reduction ,1501 cellsize ,1502 verbose ,1503 origin ,1504 datum ,1529 basename_out = basename_out, 1530 quantity = quantity, 1531 timestep = timestep, 1532 reduction = reduction, 1533 cellsize = cellsize, 1534 verbose = verbose, 1535 origin = origin, 1536 datum = datum, 1505 1537 format = 'ers') 1506 1538 ################################# END COMPATIBILITY ############## -
inundation/pyvolution/test_data_manager.py
r1867 r1875 965 965 verbose = False, 966 966 format = 'asc') 967 #dem2pts(root, easting_min=2010.0, easting_max=2110.0,968 # northing_min=3035.0, northing_max=3125.5)969 970 967 971 968 … … 1056 1053 1057 1054 1058 #FIXME: TODO 1059 def xtest_sww2dem_boundingbox(self): 1055 def test_sww2dem_boundingbox(self): 1060 1056 """Test that sww information can be converted correctly to asc/prj 1061 1057 format readable by e.g. ArcView. … … 1158 1154 format = 'asc') 1159 1155 1160 1156 fid.close() 1157 1158 1161 1159 #Check prj (meta data) 1162 1160 prjid = open(prjfile) … … 1236 1234 1237 1235 1238 fid.close()1239 1236 1240 1237 #Cleanup … … 1593 1590 os.remove(sww.filename) 1594 1591 1595 1596 def xxxtestz_sww2ers_real(self):1597 """Test that sww information can be converted correctly to asc/prj1598 format readable by e.g. ArcView1599 """1600 1601 import time, os1602 from Numeric import array, zeros, allclose, Float, concatenate1603 from Scientific.IO.NetCDF import NetCDFFile1604 1605 1606 1607 1608 #Export to ascii/prj files1609 sww2ers('karratha_100m.sww',1610 quantity = 'depth',1611 cellsize = 5,1612 verbose = False)1613 1592 1614 1593 … … 2541 2520 if __name__ == "__main__": 2542 2521 suite = unittest.makeSuite(Test_Data_Manager,'test') 2522 #suite = unittest.makeSuite(Test_Data_Manager,'test_sww2dem_boundingbox') 2543 2523 #suite = unittest.makeSuite(Test_Data_Manager,'test_dem2pts_bounding_box') 2544 2524 #suite = unittest.makeSuite(Test_Data_Manager,'test_decimate_dem')
Note: See TracChangeset
for help on using the changeset viewer.