Changeset 2060 for inundation/pyvolution/data_manager.py
- Timestamp:
- Nov 24, 2005, 10:46:22 AM (18 years ago)
- File:
-
- 1 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')
Note: See TracChangeset
for help on using the changeset viewer.