"""Thin out MOST NetCDF bathymetry and store as nc file """ input_file = 'e5_bathy_corr5.cdf' output_file = 'SU-AU_e.nc' lat_thin = lon_thin = 4 from Scientific.IO.NetCDF import NetCDFFile fid = NetCDFFile(input_file, 'r') latitudes = fid.variables['LAT'][::lat_thin] longitudes = fid.variables['LON'][::lon_thin] elevations = fid.variables['ELEVATION'][::lat_thin,::lon_thin] outfile = NetCDFFile(output_file, 'w') outfile.createDimension('LON', fid.dimensions['LON']/lon_thin + 1) outfile.createDimension('LAT', fid.dimensions['LAT']/lat_thin + 1) import Numeric outfile.createVariable('LON', Numeric.Float64, ('LON',)) outfile.createVariable('LAT', Numeric.Float64, ('LAT',)) outfile.createVariable('ELEVATION', Numeric.Float32, ('LAT', 'LON')) #Assign to NC file #Precision used by MOST for lat/lon is 4 or 5 decimals outfile.variables['LAT'][:] = Numeric.around(latitudes, 5) outfile.variables['LON'][:] = Numeric.around(longitudes, 5) outfile.variables['ELEVATION'][:] = elevations fid.close() outfile.close()