From 91cb50b83247c7e7cd644f4d77150a4e9443dca1 Mon Sep 17 00:00:00 2001 From: Michael Grund <23025878+michaelgrund@users.noreply.github.com> Date: Fri, 25 Nov 2022 11:10:54 +0100 Subject: [PATCH 01/19] Add ternary sample dataset Related to #2138. --- pygmt/datasets/samples.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/pygmt/datasets/samples.py b/pygmt/datasets/samples.py index cf122579338..37a46f37753 100644 --- a/pygmt/datasets/samples.py +++ b/pygmt/datasets/samples.py @@ -24,6 +24,7 @@ def list_sample_data(): """ names = { "bathymetry": "Table of ship bathymetric observations off Baja California", + "compositions": "Table of rock sample compositions", "earth_relief_holes": "Regional 20 arc-minute Earth relief grid with holes", "fractures": "Table of hypothetical fracture lengths and azimuths", "hotspots": "Table of locations, names, and symbol sizes of hotpots from " @@ -70,6 +71,7 @@ def load_sample_data(name): # Dictionary of public load functions for backwards compatibility load_func_old = { "bathymetry": load_sample_bathymetry, + "compositions": load_sample_compositions, "fractures": load_fractures_compilation, "hotspots": load_hotspots, "japan_quakes": load_japan_quakes, @@ -359,6 +361,21 @@ def load_mars_shape(**kwargs): ) return data +def load_sample_compositions(**kwargs): + """ + Loads the remote file @ternary.txt. + + Returns + ------- + data : pandas.DataFrame + The data table with columns "a", "b", "c", "z". + """ + + fname = which("@ternary.txt", download="c") + data = pd.read_csv( + fname, sep="\t", header=None, names=["a", "b", "c", "z"] + ) + return data def _load_notre_dame_topography(): """ From e0726e1b6e3b1082142fc56918c00c745cdc8cd7 Mon Sep 17 00:00:00 2001 From: actions-bot <58130806+actions-bot@users.noreply.github.com> Date: Fri, 25 Nov 2022 10:14:03 +0000 Subject: [PATCH 02/19] [format-command] fixes --- pygmt/datasets/samples.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pygmt/datasets/samples.py b/pygmt/datasets/samples.py index 37a46f37753..149487f0109 100644 --- a/pygmt/datasets/samples.py +++ b/pygmt/datasets/samples.py @@ -361,6 +361,7 @@ def load_mars_shape(**kwargs): ) return data + def load_sample_compositions(**kwargs): """ Loads the remote file @ternary.txt. @@ -370,13 +371,12 @@ def load_sample_compositions(**kwargs): data : pandas.DataFrame The data table with columns "a", "b", "c", "z". """ - + fname = which("@ternary.txt", download="c") - data = pd.read_csv( - fname, sep="\t", header=None, names=["a", "b", "c", "z"] - ) + data = pd.read_csv(fname, sep="\t", header=None, names=["a", "b", "c", "z"]) return data + def _load_notre_dame_topography(): """ Load Table 5.11 in Davis: Statistics and Data Analysis in Geology. From 8bb35cc703c44f6859c905f1df1ad206a6e76493 Mon Sep 17 00:00:00 2001 From: Michael Grund <23025878+michaelgrund@users.noreply.github.com> Date: Fri, 25 Nov 2022 11:22:47 +0100 Subject: [PATCH 03/19] Update samples.py --- pygmt/datasets/samples.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/datasets/samples.py b/pygmt/datasets/samples.py index 149487f0109..1e92a7f68f5 100644 --- a/pygmt/datasets/samples.py +++ b/pygmt/datasets/samples.py @@ -362,7 +362,7 @@ def load_mars_shape(**kwargs): return data -def load_sample_compositions(**kwargs): +def load_sample_compositions(): """ Loads the remote file @ternary.txt. From 569e1e41d37f17fb42b81d5cd8f980591f5277a3 Mon Sep 17 00:00:00 2001 From: Michael Grund <23025878+michaelgrund@users.noreply.github.com> Date: Mon, 28 Nov 2022 09:24:55 +0100 Subject: [PATCH 04/19] Update test_datasets_samples.py --- pygmt/tests/test_datasets_samples.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/pygmt/tests/test_datasets_samples.py b/pygmt/tests/test_datasets_samples.py index 3bbe93bc5d3..a7df0df5b4f 100644 --- a/pygmt/tests/test_datasets_samples.py +++ b/pygmt/tests/test_datasets_samples.py @@ -186,3 +186,20 @@ def test_maunaloa_co2(): assert summary.loc["max", "date"] == 2019.3699 assert summary.loc["min", "co2_ppm"] == 313.2 assert summary.loc["max", "co2_ppm"] == 414.83 + + +def test_ternary(): + """ + Check that the @ternary.txt dataset loads without errors. + """ + data = load_sample_data(name="compositions") + assert data.shape == (1000, 4) + summary = data.describe() + assert summary.loc["min", "a"] == 0 + assert summary.loc["max", "a"] == 1 + assert summary.loc["min", "b"] == 0 + assert summary.loc["max", "b"] == 0.921 + assert summary.loc["min", "c"] == 0 + assert summary.loc["max", "c"] == 0.981 + assert summary.loc["min", "d"] == 1.041 + assert summary.loc["max", "d"] == 70.844 From db7ffaf38e87ea21b2aaf15a2777b8c5f41a3f25 Mon Sep 17 00:00:00 2001 From: actions-bot <58130806+actions-bot@users.noreply.github.com> Date: Mon, 28 Nov 2022 10:15:32 +0000 Subject: [PATCH 05/19] [format-command] fixes --- pygmt/tests/test_datasets_samples.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pygmt/tests/test_datasets_samples.py b/pygmt/tests/test_datasets_samples.py index a7df0df5b4f..0fb9babc6dc 100644 --- a/pygmt/tests/test_datasets_samples.py +++ b/pygmt/tests/test_datasets_samples.py @@ -187,7 +187,7 @@ def test_maunaloa_co2(): assert summary.loc["min", "co2_ppm"] == 313.2 assert summary.loc["max", "co2_ppm"] == 414.83 - + def test_ternary(): """ Check that the @ternary.txt dataset loads without errors. @@ -202,4 +202,4 @@ def test_ternary(): assert summary.loc["min", "c"] == 0 assert summary.loc["max", "c"] == 0.981 assert summary.loc["min", "d"] == 1.041 - assert summary.loc["max", "d"] == 70.844 + assert summary.loc["max", "d"] == 70.844 From 6cefa4c8857e6de7994143fe159a848226d0b807 Mon Sep 17 00:00:00 2001 From: Michael Grund <23025878+michaelgrund@users.noreply.github.com> Date: Mon, 28 Nov 2022 12:59:33 +0100 Subject: [PATCH 06/19] Update test_datasets_samples.py --- pygmt/tests/test_datasets_samples.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pygmt/tests/test_datasets_samples.py b/pygmt/tests/test_datasets_samples.py index 0fb9babc6dc..58c54a89a3c 100644 --- a/pygmt/tests/test_datasets_samples.py +++ b/pygmt/tests/test_datasets_samples.py @@ -201,5 +201,5 @@ def test_ternary(): assert summary.loc["max", "b"] == 0.921 assert summary.loc["min", "c"] == 0 assert summary.loc["max", "c"] == 0.981 - assert summary.loc["min", "d"] == 1.041 - assert summary.loc["max", "d"] == 70.844 + assert summary.loc["min", "z"] == 1.041 + assert summary.loc["max", "z"] == 70.844 From 9ffa946bbff54f709b1ec64d69b1780f33deedc0 Mon Sep 17 00:00:00 2001 From: Michael Grund <23025878+michaelgrund@users.noreply.github.com> Date: Mon, 28 Nov 2022 13:07:48 +0100 Subject: [PATCH 07/19] Update samples.py --- pygmt/datasets/samples.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pygmt/datasets/samples.py b/pygmt/datasets/samples.py index 1e92a7f68f5..d43ffa54893 100644 --- a/pygmt/datasets/samples.py +++ b/pygmt/datasets/samples.py @@ -71,7 +71,6 @@ def load_sample_data(name): # Dictionary of public load functions for backwards compatibility load_func_old = { "bathymetry": load_sample_bathymetry, - "compositions": load_sample_compositions, "fractures": load_fractures_compilation, "hotspots": load_hotspots, "japan_quakes": load_japan_quakes, @@ -83,6 +82,7 @@ def load_sample_data(name): # Dictionary of private load functions load_func = { "earth_relief_holes": _load_earth_relief_holes, + "compositions": _load_sample_compositions, "maunaloa_co2": _load_maunaloa_co2, "notre_dame_topography": _load_notre_dame_topography, } @@ -362,7 +362,7 @@ def load_mars_shape(**kwargs): return data -def load_sample_compositions(): +def _load_sample_compositions(): """ Loads the remote file @ternary.txt. From 810c7e574412bd26e62b19213ea67628d8aca171 Mon Sep 17 00:00:00 2001 From: Michael Grund <23025878+michaelgrund@users.noreply.github.com> Date: Tue, 29 Nov 2022 09:23:35 +0100 Subject: [PATCH 08/19] Apply suggestions from code review Co-authored-by: Will Schlitzer --- pygmt/datasets/samples.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/datasets/samples.py b/pygmt/datasets/samples.py index d43ffa54893..7b3fcdead92 100644 --- a/pygmt/datasets/samples.py +++ b/pygmt/datasets/samples.py @@ -81,8 +81,8 @@ def load_sample_data(name): # Dictionary of private load functions load_func = { - "earth_relief_holes": _load_earth_relief_holes, "compositions": _load_sample_compositions, + "earth_relief_holes": _load_earth_relief_holes, "maunaloa_co2": _load_maunaloa_co2, "notre_dame_topography": _load_notre_dame_topography, } From a7a7f65c5f7f8f9b8a2b53b5fec231771b9672f6 Mon Sep 17 00:00:00 2001 From: Michael Grund <23025878+michaelgrund@users.noreply.github.com> Date: Thu, 1 Dec 2022 20:46:13 +0100 Subject: [PATCH 09/19] Update samples.py --- pygmt/datasets/samples.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pygmt/datasets/samples.py b/pygmt/datasets/samples.py index 7b3fcdead92..db89704d1f3 100644 --- a/pygmt/datasets/samples.py +++ b/pygmt/datasets/samples.py @@ -24,7 +24,7 @@ def list_sample_data(): """ names = { "bathymetry": "Table of ship bathymetric observations off Baja California", - "compositions": "Table of rock sample compositions", + "rock_compositions": "Table of rock sample compositions", "earth_relief_holes": "Regional 20 arc-minute Earth relief grid with holes", "fractures": "Table of hypothetical fracture lengths and azimuths", "hotspots": "Table of locations, names, and symbol sizes of hotpots from " @@ -81,7 +81,7 @@ def load_sample_data(name): # Dictionary of private load functions load_func = { - "compositions": _load_sample_compositions, + "rock_compositions": _load_rock_sample_compositions, "earth_relief_holes": _load_earth_relief_holes, "maunaloa_co2": _load_maunaloa_co2, "notre_dame_topography": _load_notre_dame_topography, @@ -362,7 +362,7 @@ def load_mars_shape(**kwargs): return data -def _load_sample_compositions(): +def _load_rock_sample_compositions(): """ Loads the remote file @ternary.txt. From 8db20cfff713475f6a43e47384446261781341b7 Mon Sep 17 00:00:00 2001 From: Michael Grund <23025878+michaelgrund@users.noreply.github.com> Date: Thu, 1 Dec 2022 20:48:27 +0100 Subject: [PATCH 10/19] Update samples.py --- pygmt/datasets/samples.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pygmt/datasets/samples.py b/pygmt/datasets/samples.py index db89704d1f3..d15bbb05496 100644 --- a/pygmt/datasets/samples.py +++ b/pygmt/datasets/samples.py @@ -369,11 +369,11 @@ def _load_rock_sample_compositions(): Returns ------- data : pandas.DataFrame - The data table with columns "a", "b", "c", "z". + The data table with columns "water", "air", "limestone", "z". """ fname = which("@ternary.txt", download="c") - data = pd.read_csv(fname, sep="\t", header=None, names=["a", "b", "c", "z"]) + data = pd.read_csv(fname, sep="\t", header=None, names=["water", "air", "limestone", "z"]) return data From 30c38ece12a8231c3677ec1bdf3a8044d1a15bc4 Mon Sep 17 00:00:00 2001 From: Michael Grund <23025878+michaelgrund@users.noreply.github.com> Date: Thu, 1 Dec 2022 20:49:55 +0100 Subject: [PATCH 11/19] Update test_datasets_samples.py --- pygmt/tests/test_datasets_samples.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/pygmt/tests/test_datasets_samples.py b/pygmt/tests/test_datasets_samples.py index 58c54a89a3c..f9a120a4725 100644 --- a/pygmt/tests/test_datasets_samples.py +++ b/pygmt/tests/test_datasets_samples.py @@ -192,14 +192,14 @@ def test_ternary(): """ Check that the @ternary.txt dataset loads without errors. """ - data = load_sample_data(name="compositions") + data = load_sample_data(name="rock_compositions") assert data.shape == (1000, 4) summary = data.describe() - assert summary.loc["min", "a"] == 0 - assert summary.loc["max", "a"] == 1 - assert summary.loc["min", "b"] == 0 - assert summary.loc["max", "b"] == 0.921 - assert summary.loc["min", "c"] == 0 - assert summary.loc["max", "c"] == 0.981 + assert summary.loc["min", "water"] == 0 + assert summary.loc["max", "water"] == 1 + assert summary.loc["min", "air"] == 0 + assert summary.loc["max", "air"] == 0.921 + assert summary.loc["min", "limestone"] == 0 + assert summary.loc["max", "limestone"] == 0.981 assert summary.loc["min", "z"] == 1.041 assert summary.loc["max", "z"] == 70.844 From 1a041083fd4371cc2358718d67f056521bb97bad Mon Sep 17 00:00:00 2001 From: Michael Grund <23025878+michaelgrund@users.noreply.github.com> Date: Fri, 2 Dec 2022 09:12:40 +0100 Subject: [PATCH 12/19] Update samples.py --- pygmt/datasets/samples.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/datasets/samples.py b/pygmt/datasets/samples.py index d15bbb05496..2e6b48cc662 100644 --- a/pygmt/datasets/samples.py +++ b/pygmt/datasets/samples.py @@ -24,7 +24,6 @@ def list_sample_data(): """ names = { "bathymetry": "Table of ship bathymetric observations off Baja California", - "rock_compositions": "Table of rock sample compositions", "earth_relief_holes": "Regional 20 arc-minute Earth relief grid with holes", "fractures": "Table of hypothetical fracture lengths and azimuths", "hotspots": "Table of locations, names, and symbol sizes of hotpots from " @@ -35,6 +34,7 @@ def list_sample_data(): "maunaloa_co2": "Table of CO2 readings from Mauna Loa", "ocean_ridge_points": "Table of ocean ridge points for the entire world", "notre_dame_topography": "Table 5.11 in Davis: Statistics and Data Analysis in Geology", + "rock_compositions": "Table of rock sample compositions", "usgs_quakes": "Table of global earthquakes from the USGS", } return names From 5abacb56c72e864da2ae96d9b03476291a5fe466 Mon Sep 17 00:00:00 2001 From: Michael Grund <23025878+michaelgrund@users.noreply.github.com> Date: Fri, 2 Dec 2022 09:12:52 +0100 Subject: [PATCH 13/19] Apply suggestions from code review Co-authored-by: Dongdong Tian --- pygmt/datasets/samples.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pygmt/datasets/samples.py b/pygmt/datasets/samples.py index 2e6b48cc662..ea592c3be3e 100644 --- a/pygmt/datasets/samples.py +++ b/pygmt/datasets/samples.py @@ -364,7 +364,7 @@ def load_mars_shape(**kwargs): def _load_rock_sample_compositions(): """ - Loads the remote file @ternary.txt. + Loads a table of rock sample compositions. Returns ------- @@ -373,8 +373,7 @@ def _load_rock_sample_compositions(): """ fname = which("@ternary.txt", download="c") - data = pd.read_csv(fname, sep="\t", header=None, names=["water", "air", "limestone", "z"]) - return data + return pd.read_csv(fname, sep="\t", header=None, names=["water", "air", "limestone", "z"]) def _load_notre_dame_topography(): From b904edecc9eb37eaac5d91da4b5b72f2ade9383a Mon Sep 17 00:00:00 2001 From: actions-bot <58130806+actions-bot@users.noreply.github.com> Date: Fri, 2 Dec 2022 10:23:12 +0000 Subject: [PATCH 14/19] [format-command] fixes --- pygmt/datasets/samples.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pygmt/datasets/samples.py b/pygmt/datasets/samples.py index ea592c3be3e..c5b223b6ca3 100644 --- a/pygmt/datasets/samples.py +++ b/pygmt/datasets/samples.py @@ -373,7 +373,9 @@ def _load_rock_sample_compositions(): """ fname = which("@ternary.txt", download="c") - return pd.read_csv(fname, sep="\t", header=None, names=["water", "air", "limestone", "z"]) + return pd.read_csv( + fname, sep="\t", header=None, names=["water", "air", "limestone", "z"] + ) def _load_notre_dame_topography(): From 0de3fa2c2cf44c62a655e3c00cd206d7dea7cd6b Mon Sep 17 00:00:00 2001 From: Michael Grund <23025878+michaelgrund@users.noreply.github.com> Date: Sun, 4 Dec 2022 16:21:57 +0100 Subject: [PATCH 15/19] Apply suggestions from code review Co-authored-by: Dongdong Tian --- pygmt/tests/test_datasets_samples.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/tests/test_datasets_samples.py b/pygmt/tests/test_datasets_samples.py index f9a120a4725..212f9713d97 100644 --- a/pygmt/tests/test_datasets_samples.py +++ b/pygmt/tests/test_datasets_samples.py @@ -188,7 +188,7 @@ def test_maunaloa_co2(): assert summary.loc["max", "co2_ppm"] == 414.83 -def test_ternary(): +def test_rock_sample_compositions(): """ Check that the @ternary.txt dataset loads without errors. """ From 809c578ff39c9305e7ed61ab4774c816c03e1649 Mon Sep 17 00:00:00 2001 From: Michael Grund <23025878+michaelgrund@users.noreply.github.com> Date: Sun, 4 Dec 2022 16:24:03 +0100 Subject: [PATCH 16/19] Update samples.py --- pygmt/datasets/samples.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pygmt/datasets/samples.py b/pygmt/datasets/samples.py index c5b223b6ca3..2250b4263eb 100644 --- a/pygmt/datasets/samples.py +++ b/pygmt/datasets/samples.py @@ -374,9 +374,8 @@ def _load_rock_sample_compositions(): fname = which("@ternary.txt", download="c") return pd.read_csv( - fname, sep="\t", header=None, names=["water", "air", "limestone", "z"] - ) - + fname, delim_whitespace=True, header=None, names=["water", "air", "limestone"], usecols=(0, 1, 2) + ) def _load_notre_dame_topography(): """ From 97f5338617248ad22d5b0bad4288c9f06a548059 Mon Sep 17 00:00:00 2001 From: Michael Grund <23025878+michaelgrund@users.noreply.github.com> Date: Sun, 4 Dec 2022 16:24:16 +0100 Subject: [PATCH 17/19] Apply suggestions from code review Co-authored-by: Dongdong Tian --- pygmt/datasets/samples.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pygmt/datasets/samples.py b/pygmt/datasets/samples.py index 2250b4263eb..9ce4613aea3 100644 --- a/pygmt/datasets/samples.py +++ b/pygmt/datasets/samples.py @@ -32,8 +32,8 @@ def list_sample_data(): "mars_shape": "Table of topographic signature of the hemispheric dichotomy of " " Mars from Smith and Zuber (1996)", "maunaloa_co2": "Table of CO2 readings from Mauna Loa", - "ocean_ridge_points": "Table of ocean ridge points for the entire world", "notre_dame_topography": "Table 5.11 in Davis: Statistics and Data Analysis in Geology", + "ocean_ridge_points": "Table of ocean ridge points for the entire world", "rock_compositions": "Table of rock sample compositions", "usgs_quakes": "Table of global earthquakes from the USGS", } From 213b2152f8a072787119ec4bba95d9dd9d80f2ec Mon Sep 17 00:00:00 2001 From: actions-bot <58130806+actions-bot@users.noreply.github.com> Date: Sun, 4 Dec 2022 15:25:49 +0000 Subject: [PATCH 18/19] [format-command] fixes --- pygmt/datasets/samples.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pygmt/datasets/samples.py b/pygmt/datasets/samples.py index 9ce4613aea3..5f473b6ac41 100644 --- a/pygmt/datasets/samples.py +++ b/pygmt/datasets/samples.py @@ -374,8 +374,13 @@ def _load_rock_sample_compositions(): fname = which("@ternary.txt", download="c") return pd.read_csv( - fname, delim_whitespace=True, header=None, names=["water", "air", "limestone"], usecols=(0, 1, 2) - ) + fname, + delim_whitespace=True, + header=None, + names=["water", "air", "limestone"], + usecols=(0, 1, 2), + ) + def _load_notre_dame_topography(): """ From 8ffb6e334a37eddddb21d489006059cf733d8c87 Mon Sep 17 00:00:00 2001 From: Michael Grund <23025878+michaelgrund@users.noreply.github.com> Date: Sun, 4 Dec 2022 17:40:51 +0100 Subject: [PATCH 19/19] Apply suggestions from code review Co-authored-by: Dongdong Tian --- pygmt/datasets/samples.py | 2 +- pygmt/tests/test_datasets_samples.py | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/pygmt/datasets/samples.py b/pygmt/datasets/samples.py index 5f473b6ac41..efe885bcfe0 100644 --- a/pygmt/datasets/samples.py +++ b/pygmt/datasets/samples.py @@ -369,7 +369,7 @@ def _load_rock_sample_compositions(): Returns ------- data : pandas.DataFrame - The data table with columns "water", "air", "limestone", "z". + The data table with columns "water", "air", and "limestone". """ fname = which("@ternary.txt", download="c") diff --git a/pygmt/tests/test_datasets_samples.py b/pygmt/tests/test_datasets_samples.py index 212f9713d97..e0d3b3f3a7c 100644 --- a/pygmt/tests/test_datasets_samples.py +++ b/pygmt/tests/test_datasets_samples.py @@ -193,7 +193,7 @@ def test_rock_sample_compositions(): Check that the @ternary.txt dataset loads without errors. """ data = load_sample_data(name="rock_compositions") - assert data.shape == (1000, 4) + assert data.shape == (1000, 3) summary = data.describe() assert summary.loc["min", "water"] == 0 assert summary.loc["max", "water"] == 1 @@ -201,5 +201,3 @@ def test_rock_sample_compositions(): assert summary.loc["max", "air"] == 0.921 assert summary.loc["min", "limestone"] == 0 assert summary.loc["max", "limestone"] == 0.981 - assert summary.loc["min", "z"] == 1.041 - assert summary.loc["max", "z"] == 70.844