Changeset 2060
- Timestamp:
- Nov 24, 2005, 10:46:22 AM (19 years ago)
- Location:
- inundation/pyvolution
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/pyvolution/data_manager.py
r2057 r2060 1424 1424 reduction = None, 1425 1425 cellsize = 10, 1426 NODATA_value = -9999, 1426 1427 easting_min = None, 1427 1428 easting_max = None, … … 1481 1482 msg = 'Format must be either asc or ers' 1482 1483 assert format.lower() in ['asc', 'ers'], msg 1483 1484 1485 1484 1486 false_easting = 500000 1485 1487 false_northing = 10000000 … … 1670 1672 grid_values = interp.interpolate(q).flat 1671 1673 1674 1675 #Assign NODATA_value to all points outside bounding polygon (from interpolation mesh) 1676 P = interp.mesh.get_boundary_polygon() 1677 inside_indices = inside_polygon(grid_points, P) 1678 1679 #FIXME: Remove when new interpolation takes care of this 1680 for i in range(nrows): 1681 if verbose and i%((nrows+10)/10)==0: 1682 print 'Doing row %d of %d' %(i, nrows) 1683 1684 base_index = (nrows-i-1)*ncols 1685 for j in range(ncols): 1686 index = base_index+j 1687 1688 if not sometrue(inside_indices == index): 1689 grid_values[index] = NODATA_value 1690 1691 ############# 1692 1693 1694 1672 1695 if verbose: 1673 1696 print 'Interpolated values are in [%f, %f]' %(min(grid_values), … … 1677 1700 # setup ERS header information 1678 1701 grid_values = reshape(grid_values,(nrows, ncols)) 1679 NODATA_value = 01680 1702 header = {} 1681 1703 header['datum'] = '"' + datum + '"' … … 1725 1747 1726 1748 if verbose: print 'Writing %s' %demfile 1727 NODATA_value = -99991728 1749 1729 1750 ascid = open(demfile, 'w') … … 1738 1759 1739 1760 #Get bounding polygon from mesh 1740 P = interp.mesh.get_boundary_polygon()1741 inside_indices = inside_polygon(grid_points, P)1761 #P = interp.mesh.get_boundary_polygon() 1762 #inside_indices = inside_polygon(grid_points, P) 1742 1763 1743 1764 for i in range(nrows): … … 1745 1766 print 'Doing row %d of %d' %(i, nrows) 1746 1767 1768 base_index = (nrows-i-1)*ncols 1747 1769 for j in range(ncols): 1748 index = (nrows-i-1)*ncols+j 1749 1750 if sometrue(inside_indices == index): 1751 ascid.write('%f ' %grid_values[index]) 1752 else: 1753 ascid.write('%d ' %NODATA_value) 1770 index = base_index+j 1771 1772 ascid.write('%f ' %grid_values[index]) 1754 1773 1755 1774 ascid.write('\n') -
inundation/pyvolution/test_data_manager.py
r2054 r2060 1694 1694 from Scientific.IO.NetCDF import NetCDFFile 1695 1695 1696 1697 NODATA_value = 1758323 1698 1696 1699 #Setup 1697 1700 self.domain.filename = 'datatest' … … 1737 1740 quantity = 'elevation', 1738 1741 cellsize = cellsize, 1742 NODATA_value = NODATA_value, 1739 1743 verbose = False, 1740 1744 format = 'ers') … … 1755 1759 assert int(header['nroflines']) == 5 1756 1760 assert int(header['nrofcellsperline']) == 5 1757 assert int(header['nullcellvalue']) == 0 #?1761 assert int(header['nullcellvalue']) == NODATA_value 1758 1762 #FIXME - there is more in the header 1759 1763 … … 1763 1767 1764 1768 #FIXME (Ole): Why is this the desired reference grid for -x-y? 1765 ref_grid = [ 0, 0, 0, 0, 0,1769 ref_grid = [NODATA_value, NODATA_value, NODATA_value, NODATA_value, NODATA_value, 1766 1770 -1, -1.25, -1.5, -1.75, -2.0, 1767 1771 -0.75, -1.0, -1.25, -1.5, -1.75, … … 1770 1774 1771 1775 1776 #print grid 1772 1777 assert allclose(grid, ref_grid) 1773 1778 … … 3581 3586 if __name__ == "__main__": 3582 3587 #suite = unittest.makeSuite(Test_Data_Manager,'test_asc_csiro2sww4') 3583 suite = unittest.makeSuite(Test_Data_Manager,'test')3584 #suite = unittest.makeSuite(Test_Data_Manager,'xxxtest')3588 #suite = unittest.makeSuite(Test_Data_Manager,'test') 3589 suite = unittest.makeSuite(Test_Data_Manager,'test_sww2dem_asc_missing_points') 3585 3590 #suite = unittest.makeSuite(Test_Data_Manager,'test_sww2dem_boundingbox') 3586 3591 #suite = unittest.makeSuite(Test_Data_Manager,'test_dem2pts_bounding_box')
Note: See TracChangeset
for help on using the changeset viewer.