Skip to content

Commit

Permalink
Update the Caribbean bathymetry data to v2
Browse files Browse the repository at this point in the history
The new version has fewer points (smaller area), removed the very dense
surveys, removed the surveys with systematic errors. All of this to help
reduce the file size and number of points to something more manageable.
Version 1 took too long to just plot.
  • Loading branch information
leouieda committed Feb 7, 2024
1 parent 891ff9d commit 805259d
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 23 deletions.
38 changes: 22 additions & 16 deletions doc/gallery_src/caribbean-bathymetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
This dataset is a compilation of several public domain single-beam bathymetry
surveys of the ocean in the Caribbean. The data display a wide range of
tectonic activity, uneven distribution, and even clear systematic errors in
some of the survey lines.
tectonic activity and uneven distribution.
**Original source:** `NOAA NCEI
<https://ngdc.noaa.gov/mgg/geodas/trackline.html>`__
Expand All @@ -20,6 +19,14 @@
redistribution in Ensaio
<https://github.com/fatiando-data/caribbean-bathymetry>`__
.. admonition:: Changes in version 2
:class: note
In version 1, there were 1,938,095 data taking up a larger area. The
data were ``depth_m`` and positive downward. Version 2, cropped the
data to make it more manageable and converted the depths to bathymetric
heights (negative downward).
"""
import pandas as pd
import pygmt
Expand All @@ -28,7 +35,7 @@

###############################################################################
# Download and cache the data and return the path to it on disk
fname = ensaio.fetch_caribbean_bathymetry(version=1)
fname = ensaio.fetch_caribbean_bathymetry(version=2)
print(fname)

###############################################################################
Expand All @@ -37,22 +44,21 @@
data

###############################################################################
# Make a PyGMT map with the data points colored by the depth.
# Make a PyGMT map with the data points colored by the bathymetry.
fig = pygmt.Figure()
fig.basemap(
region=[
data.longitude.min(),
data.longitude.max(),
data.latitude.min(),
data.latitude.max(),
],
projection="M15c",
frame=True,
pygmt.makecpt(
cmap="cmocean/topo+h",
series=[data.bathymetry_m.min(), data.bathymetry_m.max()],
)
pygmt.makecpt(cmap="viridis", series=[data.depth_m.min(), data.depth_m.max()])
fig.plot(
x=data.longitude, y=data.latitude, fill=data.depth_m, cmap=True, style="c0.02c"
x=data.longitude,
y=data.latitude,
fill=data.bathymetry_m,
cmap=True,
style="c0.02c",
projection="M15c",
frame=True,
)
fig.colorbar(frame='af+l"bathymetric depth [m]"')
fig.colorbar(frame='af+l"bathymetry [m]"')
fig.coast(land="#666666")
fig.show()
30 changes: 23 additions & 7 deletions ensaio/_fetchers.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@
"doi": "doi:10.5281/zenodo.5882211",
"url": "https://github.com/fatiando-data/caribbean-bathymetry/releases/download/v1",
},
"v2": {
"hash": "md5:79698c447daba7c15011a5528c8fe212",
"doi": "doi:10.5281/zenodo.10631903",
"url": "https://github.com/fatiando-data/caribbean-bathymetry/releases/download/v2",
},
},
"earth-geoid-10arcmin.nc": {
"v1": {
Expand Down Expand Up @@ -420,14 +425,21 @@ def fetch_caribbean_bathymetry(version):
This dataset is a compilation of several public domain single-beam
bathymetry surveys of the ocean in the Caribbean. The data display a wide
range of tectonic activity, uneven distribution, and even clear systematic
errors in some of the survey lines.
range of tectonic activity and an uneven distribution.
The horizontal datum is WGS84 and the bathymetry is negative downwards and
is referenced to "mean sea level".
There are 294,321 measurements in total with 4 columns available:
survey ID, longitude, latitude (geodetic), and bathymetry (in meters).
The horizontal datum is WGS84 and the bathymetric depth is positive
downwards and referenced to "mean sea level".
.. admonition:: Changes in version 2
:class: note
There are 1,938,095 measurements in total with 4 columns available:
survey ID, longitude, latitude (geodetic), and depth.
In version 1, there were 1,938,095 data taking up a larger area. The
data were ``depth_m`` and positive downward. Version 2, cropped the
data to make it more manageable and converted the depths to bathymetric
heights (negative downward).
**Format:** CSV with xz (lzma) compression.
Expand All @@ -447,6 +459,10 @@ def fetch_caribbean_bathymetry(version):
* `1
<https://github.com/fatiando-data/caribbean-bathymetry/releases/tag/v1>`_
(doi:`10.5281/zenodo.5882211 <https://doi.org/10.5281/zenodo.5882211>`__)
* `2
<https://github.com/fatiando-data/caribbean-bathymetry/releases/tag/v2>`_
(doi:`10.5281/zenodo.10631903
<https://doi.org/10.5281/zenodo.10631903>`__)
Parameters
----------
Expand All @@ -459,7 +475,7 @@ def fetch_caribbean_bathymetry(version):
Path to the downloaded file on disk.
"""
_check_versions(version, allowed={1}, name="Caribbean bathymetry")
_check_versions(version, allowed={1, 2}, name="Caribbean bathymetry")
fname = "caribbean-bathymetry.csv.xz"
return Path(_repository(fname, version).fetch(fname))

Expand Down
12 changes: 12 additions & 0 deletions ensaio/tests/test_fetchers.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,25 @@
for name, function in inspect.getmembers(_fetchers, inspect.isfunction)
if name.startswith("fetch_")
]
FETCH_FUNCTIONS_V2 = [
_fetchers.fetch_caribbean_bathymetry,
]


@pytest.mark.parametrize("fetch", FETCH_FUNCTIONS)
def test_fetch_datasets(fetch):
"Check that fetching works and the file exists once downloaded"
path = fetch(version=1)
assert path.exists()
assert "v1" in str(path)


@pytest.mark.parametrize("fetch", FETCH_FUNCTIONS_V2)
def test_fetch_datasets_v2(fetch):
"Check that fetching v2 works and the file exists once downloaded"
path = fetch(version=2)
assert path.exists()
assert "v2" in str(path)


def test_locate():
Expand Down

0 comments on commit 805259d

Please sign in to comment.