From 1b3e3f4552030b6535334d8d925958c1ca9a4311 Mon Sep 17 00:00:00 2001 From: Leonardo Uieda Date: Wed, 7 Feb 2024 17:48:54 -0300 Subject: [PATCH] Update the Caribbean bathymetry data to v2 (#54) 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. Add a test function that downloads the v2 datasets as well. For now, make this manual since this is the only dataset with v2. --- doc/gallery_src/caribbean-bathymetry.py | 38 ++++++++++++++----------- ensaio/_fetchers.py | 30 ++++++++++++++----- ensaio/tests/test_fetchers.py | 12 ++++++++ 3 files changed, 57 insertions(+), 23 deletions(-) diff --git a/doc/gallery_src/caribbean-bathymetry.py b/doc/gallery_src/caribbean-bathymetry.py index e5c8c29..1ed0158 100644 --- a/doc/gallery_src/caribbean-bathymetry.py +++ b/doc/gallery_src/caribbean-bathymetry.py @@ -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 `__ @@ -20,6 +19,14 @@ redistribution in Ensaio `__ +.. 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 @@ -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) ############################################################################### @@ -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() diff --git a/ensaio/_fetchers.py b/ensaio/_fetchers.py index 780958f..4f3c9ed 100644 --- a/ensaio/_fetchers.py +++ b/ensaio/_fetchers.py @@ -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": { @@ -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. @@ -447,6 +459,10 @@ def fetch_caribbean_bathymetry(version): * `1 `_ (doi:`10.5281/zenodo.5882211 `__) + * `2 + `_ + (doi:`10.5281/zenodo.10631903 + `__) Parameters ---------- @@ -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)) diff --git a/ensaio/tests/test_fetchers.py b/ensaio/tests/test_fetchers.py index ce8188f..d089b60 100644 --- a/ensaio/tests/test_fetchers.py +++ b/ensaio/tests/test_fetchers.py @@ -19,6 +19,9 @@ 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) @@ -26,6 +29,15 @@ 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():