Changeset 839
- Timestamp:
- Feb 7, 2005, 5:04:54 PM (20 years ago)
- Location:
- inundation/ga/storm_surge/pyvolution
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
inundation/ga/storm_surge/pyvolution/data_manager.py
r837 r839 823 823 138.3698 137.4194 136.5062 135.5558 .......... 824 824 825 Convert to NetCDF pts format 825 Convert to NetCDF pts format which is 826 827 points: (Nx2) Float array 828 elevation: N Float array 826 829 """ 827 830 … … 843 846 cellsize = infile.cellsize[0] 844 847 NODATA_value = infile.NODATA_value[0] 845 elevation = infile.variables['elevation']848 dem_elevation = infile.variables['elevation'] 846 849 847 850 #Get output file … … 860 863 861 864 862 outfile.attribute_names = 'elevation' #This is the attribute always present in DEMs863 #FIXME (Ole): We would really like this to be Python list,864 #but I am not sure if865 #that is possible in NetCDF???866 867 868 865 # dimension definitions 869 866 outfile.createDimension('number_of_points', nrows*ncols) 870 outfile.createDimension('number_of_attributes', 1) #Always 1 with the dem fmt871 867 outfile.createDimension('number_of_dimensions', 2) #This is 2d data 872 868 873 874 869 # variable definitions 875 870 outfile.createVariable('points', Float, ('number_of_points', 876 871 'number_of_dimensions')) 877 outfile.createVariable('attributes', Float, ('number_of_points', 878 'number_of_attributes')) 872 outfile.createVariable('elevation', Float, ('number_of_points',)) 879 873 880 874 # Get handles to the variables 881 875 points = outfile.variables['points'] 882 attributes = outfile.variables['attributes']876 elevation = outfile.variables['elevation'] 883 877 884 878 #Store data … … 893 887 x = j*cellsize 894 888 points[index, :] = [x,y] 895 attributes[index, 0] =elevation[i, j]889 elevation[index] = dem_elevation[i, j] 896 890 897 891 infile.close() -
inundation/ga/storm_surge/pyvolution/test_data_manager.py
r837 r839 521 521 522 522 ref_points = [] 523 ref_ attributes= []523 ref_elevation = [] 524 524 for i in range(6): 525 525 y = (6-i)*25.0 … … 529 529 530 530 ref_points.append( [x,y] ) 531 ref_ attributes.append([z])531 ref_elevation.append(z) 532 532 fid.write('%f ' %z) 533 533 fid.write('\n') … … 544 544 545 545 # Get the variables 546 #print fid.variables.keys() 546 547 points = fid.variables['points'] 547 attributes = fid.variables['attributes'] 548 attribute_names = fid.attribute_names 548 elevation = fid.variables['elevation'] 549 549 550 550 #Check values … … 555 555 556 556 #print attributes[:] 557 #print ref_ attributes558 assert allclose( attributes, ref_attributes)557 #print ref_elevation 558 assert allclose(elevation, ref_elevation) 559 559 560 560 #Cleanup
Note: See TracChangeset
for help on using the changeset viewer.