@@ -0,0 +1,1433 @@
+%22%22%22%0A  extract depths from gebco bathymetric data obtained from%0A  British Oceanographic Data Centre http://www.bodc.ac.uk%0A  from where the data from a selected lat/long bounding box can be downloaded with either 1 minute or 30 second %0A%0Aresolution%0A  needs netCDF4  http://code.google.com/p/netcdf4-python/%0A  %0A  this script extracts a bounding box from a larger downloaded source file.  For example the file may contain the   %0A%0Awhole of the Mediterranean %0A  and the script extracts smaller areas from the whole%0A  .nc files in gebco  subdirectory%0A  parameters%0A     top left lat, long%0A     bottom right lat,long%0A          %0A  Chris Wallace%0A  kitwallace.co.uk%0A%22%22%22%0A%0Adef latlong_to_array(lat,long) :%0A   return %5B int((long - xrangemin  ) /scale) , int((yrangemax - lat) / scale)%5D%0A   %0Aimport netCDF4%0Afrom numpy import * %0Afrom generate_STL import *%0Aimport sys%0A%0Alat_max = float(sys.argv%5B1%5D)%0Along_min = float(sys.argv%5B2%5D)%0Alat_min = float(sys.argv%5B3%5D)%0Along_max = float(sys.argv%5B4%5D)%0A %0A%0Ad= netCDF4.Dataset(sys.stdin, 'r')%0A%0Ascale = d.variables%5B'spacing'%5D%5B0%5D%0Axrangemin = d.variables%5B'x_range'%5D%5B0%5D%0Ayrangemax = d.variables%5B'y_range'%5D%5B1%5D%0A%0Atl = latlong_to_array(lat_max,long_min)%0Abr = latlong_to_array(lat_min,long_max)%0A%0Adepths = d.variables%5B'z'%5D%5B:%5D%0Adepths = depths.reshape(d.variables%5B'dimension'%5D%5B1%5D, d.variables%5B'dimension'%5D%5B0%5D)%0Ad.close()%0Adepths = depths%5B tl%5B1%5D: br%5B1%5D,tl%5B0%5D: br%5B0%5D%5D%0A%0A%0A//print depths in row matrix format%0Asavetxt(sys.stdout,depths,%22%25d%22)%0A

Create extract_gebco.py