Ignore:
Timestamp:
Feb 7, 2005, 5:04:54 PM (20 years ago)
Author:
ole
Message:

Slight change to pts format having attribute names as variables

File:
1 edited

Legend:

Unmodified
Added
Removed
  • inundation/ga/storm_surge/pyvolution/data_manager.py

    r837 r839  
    823823    138.3698 137.4194 136.5062 135.5558 ..........
    824824
    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
    826829    """
    827830
     
    843846    cellsize = infile.cellsize[0]
    844847    NODATA_value = infile.NODATA_value[0]
    845     elevation = infile.variables['elevation']
     848    dem_elevation = infile.variables['elevation']
    846849
    847850    #Get output file                               
     
    860863
    861864   
    862     outfile.attribute_names = 'elevation' #This is the attribute always present in DEMs
    863     #FIXME (Ole): We would really like this to be Python list,
    864     #but I am not sure if
    865     #that is possible in NetCDF???
    866    
    867 
    868865    # dimension definitions
    869866    outfile.createDimension('number_of_points', nrows*ncols)   
    870     outfile.createDimension('number_of_attributes', 1) #Always 1 with the dem fmt
    871867    outfile.createDimension('number_of_dimensions', 2) #This is 2d data
    872868   
    873 
    874869    # variable definitions
    875870    outfile.createVariable('points', Float, ('number_of_points',
    876871                                             'number_of_dimensions'))
    877     outfile.createVariable('attributes', Float, ('number_of_points',
    878                                                  'number_of_attributes'))
     872    outfile.createVariable('elevation', Float, ('number_of_points',))
    879873
    880874    # Get handles to the variables
    881875    points = outfile.variables['points']
    882     attributes = outfile.variables['attributes']
     876    elevation = outfile.variables['elevation']
    883877
    884878    #Store data
     
    893887            x = j*cellsize
    894888            points[index, :] = [x,y]
    895             attributes[index, 0] = elevation[i, j]           
     889            elevation[index] = dem_elevation[i, j]           
    896890
    897891    infile.close()           
Note: See TracChangeset for help on using the changeset viewer.