topo30 demo by Kurt Schwehr, Jun 2013. Licensed under the Apache 2.0 license.
wget ftp://topex.ucsd.edu/pub/srtm30_plus/topo30/topo30.grd
wget ftp://topex.ucsd.edu/pub/srtm30_plus/topo30/COPYRIGHT.txt
cat COPYRIGHT.txt
David T. Sandwell, Walter H. F. Smith, and Joseph J. Becker Copyright 2008 The Regents of the University of California All Rights Reserved Permission to copy, modify and distribute any part of this gridded bathymetry at 30 second resolution for educational, research and non-profit purposes, without fee, and without a written agreement is hereby granted, provided that the above copyright notice, this paragraph and the following three paragraphs appear in all copies. Those desiring to incorporate this global bathymetry into commercial products or use for commercial purposes should contact the Technology Transfer & Intellectual Property Services, University of California, San Diego, 9500 Gilman Drive, Mail Code 0910, La Jolla, CA 92093-0910, Ph: (858) 534-5815, FAX: (858) 534-7345, E-MAIL:invent@ucsd.edu. IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS global bathymetry, EVEN IF THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. THE global bathymetry PROVIDED HEREIN IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. THE UNIVERSITY OF CALIFORNIA MAKES NO REPRESENTATIONS AND EXTENDS NO WARRANTIES OF ANY KIND, EITHER IMPLIED OR EXPRESS, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE, OR THAT THE USE OF THE global bathymetry WILL NOT INFRINGE ANY PATENT, TRADEMARK OR OTHER RIGHTS.
ls -l
total 3646024 -rw-r--r-- 1 schwehr staff 302 Jun 15 10:18 topo30-20130615.ipynb -rw-r--r-- 1 schwehr staff 1866759096 Jun 15 08:27 topo30.grd
!grdinfo topo30.grd
topo30.grd: Title: topo30.grd topo30.grd: Command: xyz2grd -V -Rg -I30c topo30 -Gtopo30.grd=ns -ZTLhw -F topo30.grd: Remark: topo30.grd: Pixel node registration used topo30.grd: Grid file format: ns (# 16) GMT netCDF format (short) (COARDS-compliant) topo30.grd: x_min: 0 x_max: 360 x_inc: 0.00833333333333 name: longitude [degrees_east] nx: 43200 topo30.grd: y_min: -90 y_max: 90 y_inc: 0.00833333333333 name: latitude [degrees_north] ny: 21600 topo30.grd: z_min: -11609 z_max: 8685 name: z topo30.grd: scale_factor: 1 add_offset: 0
Units are in meters. This grid says the ocean is 11609 meters deep and the land is 8685 meters at the highest point
import gdal
src = gdal.Open('topo30.grd')
topo30 = src.GetRasterBand(1).ReadAsArray()
less0 = (topo30 < 0).sum(); print less0, 'cells'
615742641 cells
topo30.size
933120000
print '%0.2f%% of the grid is below 0' % (100. * float(less0) / topo30.size)
65.99% of the grid is below 0
1 fathom = 0.0909090909 chains. 1 chain = 20.1168 meters. 1 fathom = 1.8288 meters. 20 fathom = 36.57600 meters. 100 fathom = 182.88 meters
http://en.wikipedia.org/wiki/Fathom http://en.wikipedia.org/wiki/Chain_(unit)
'%.1f %% of the grid below 0 is below 20 fathoms' % (100. * float((topo30 < -36.576).sum()) / less0)
'97.1 % of the grid below 0 is below 20 fathoms'
'%.1f %% of the grid below 0 is below 100 fathoms' % (100. * float((topo30 < -182.88).sum()) / less0)
'91.4 % of the grid below 0 is below 100 fathoms'
data = numpy.hstack(topo30)
data.shape
(933120000,)
pylab.hist(data, bins=100, histtype='stepfilled')
(array([ 1, 0, 0, 45, 288, 416, 741, 1325, 2672, 4853, 7199, 13479, 16571, 19082, 21686, 30199, 39391, 42721, 50998, 64010, 86709, 140039, 143448, 172670, 219785, 369534, 1203206, 4409083, 9492429, 15841632, 23976442, 30796385, 34275474, 33181641, 34448456, 39732885, 43006672, 35886789, 35440161, 30397671, 25316175, 22141362, 17251089, 15346092, 12233477, 10224394, 9167176, 8056897, 7190608, 6466525, 6303823, 5758306, 4993129, 5894586, 9935708, 16135620, 39655696, 87942955, 54067948, 35599529, 20624282, 15188263, 13846524, 11255256, 8839983, 7467336, 6845747, 6798881, 7122778, 8667842, 12043493, 10488957, 10909343, 5569109, 4985513, 4050558, 1526984, 568081, 463494, 545151, 571120, 601338, 446017, 246730, 125043, 62362, 26454, 9699, 3364, 1175, 571, 291, 173, 86, 49, 28, 14, 13, 9, 6]), array([-11609. , -11406.06, -11203.12, -11000.18, -10797.24, -10594.3 , -10391.36, -10188.42, -9985.48, -9782.54, -9579.6 , -9376.66, -9173.72, -8970.78, -8767.84, -8564.9 , -8361.96, -8159.02, -7956.08, -7753.14, -7550.2 , -7347.26, -7144.32, -6941.38, -6738.44, -6535.5 , -6332.56, -6129.62, -5926.68, -5723.74, -5520.8 , -5317.86, -5114.92, -4911.98, -4709.04, -4506.1 , -4303.16, -4100.22, -3897.28, -3694.34, -3491.4 , -3288.46, -3085.52, -2882.58, -2679.64, -2476.7 , -2273.76, -2070.82, -1867.88, -1664.94, -1462. , -1259.06, -1056.12, -853.18, -650.24, -447.3 , -244.36, -41.42, 161.52, 364.46, 567.4 , 770.34, 973.28, 1176.22, 1379.16, 1582.1 , 1785.04, 1987.98, 2190.92, 2393.86, 2596.8 , 2799.74, 3002.68, 3205.62, 3408.56, 3611.5 , 3814.44, 4017.38, 4220.32, 4423.26, 4626.2 , 4829.14, 5032.08, 5235.02, 5437.96, 5640.9 , 5843.84, 6046.78, 6249.72, 6452.66, 6655.6 , 6858.54, 7061.48, 7264.42, 7467.36, 7670.3 , 7873.24, 8076.18, 8279.12, 8482.06, 8685. ]), <a list of 1 Patch objects>)
# Now give the cumulative distribution function (CDF)
n, bins, patches = pylab.hist(data, 200, histtype='step', cumulative=True)