From 39203d59b7f4dc4cce48b21f14ad480927503934 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Thu, 22 Dec 2022 08:41:53 -0500 Subject: [PATCH 01/40] update default registration for load_earth_relief --- pygmt/datasets/load_remote_dataset.py | 38 ++++++++++++----------- pygmt/tests/test_datasets_earth_relief.py | 5 ++- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/pygmt/datasets/load_remote_dataset.py b/pygmt/datasets/load_remote_dataset.py index aec1ac6fd8a..2b80f8823a5 100644 --- a/pygmt/datasets/load_remote_dataset.py +++ b/pygmt/datasets/load_remote_dataset.py @@ -71,18 +71,18 @@ class GMTRemoteDataset(NamedTuple): units="meters", extra_attributes={"vertical_datum": "EGM96", "horizontal_datum": "WGS84"}, resolutions={ - "01d": Resolution(["pixel", "gridline"], False), - "30m": Resolution(["pixel", "gridline"], False), - "20m": Resolution(["pixel", "gridline"], False), - "15m": Resolution(["pixel", "gridline"], False), - "10m": Resolution(["pixel", "gridline"], False), - "06m": Resolution(["pixel", "gridline"], False), - "05m": Resolution(["pixel", "gridline"], True), - "04m": Resolution(["pixel", "gridline"], True), - "03m": Resolution(["pixel", "gridline"], True), - "02m": Resolution(["pixel", "gridline"], True), - "01m": Resolution(["pixel", "gridline"], True), - "30s": Resolution(["pixel", "gridline"], True), + "01d": Resolution(["gridline", "pixel"], False), + "30m": Resolution(["gridline", "pixel"], False), + "20m": Resolution(["gridline", "pixel"], False), + "15m": Resolution(["gridline", "pixel"], False), + "10m": Resolution(["gridline", "pixel"], False), + "06m": Resolution(["gridline", "pixel"], False), + "05m": Resolution(["gridline", "pixel"], True), + "04m": Resolution(["gridline", "pixel"], True), + "03m": Resolution(["gridline", "pixel"], True), + "02m": Resolution(["gridline", "pixel"], True), + "01m": Resolution(["gridline", "pixel"], True), + "30s": Resolution(["gridline", "pixel"], True), "15s": Resolution(["pixel"], True), "03s": Resolution(["gridline"], True), "01s": Resolution(["gridline"], True), @@ -210,10 +210,14 @@ def _load_remote_dataset( The returned :class:`xarray.DataArray` doesn't support slice operation for tiled grids. """ - - if registration in ("pixel", "gridline", None): + dataset = datasets[dataset_name] + if resolution not in dataset.resolutions.keys(): + raise GMTInvalidInput(f"Invalid resolution '{resolution}'.") + if registration is None: + registration = dataset.resolutions[resolution].registrations[0] + if registration in ("pixel", "gridline"): # If None, let GMT decide on Pixel/Gridline type - reg = f"_{registration[0]}" if registration else "" + reg = f"_{registration[0]}" else: raise GMTInvalidInput( f"Invalid grid registration: '{registration}', should be either " @@ -221,9 +225,7 @@ def _load_remote_dataset( "pixel-registered grid is returned unless only the " "gridline-registered grid is available." ) - dataset = datasets[dataset_name] - if resolution not in dataset.resolutions.keys(): - raise GMTInvalidInput(f"Invalid resolution '{resolution}'.") + if registration and ( registration not in dataset.resolutions[resolution].registrations ): diff --git a/pygmt/tests/test_datasets_earth_relief.py b/pygmt/tests/test_datasets_earth_relief.py index 5e6bfe02247..27615aa901c 100644 --- a/pygmt/tests/test_datasets_earth_relief.py +++ b/pygmt/tests/test_datasets_earth_relief.py @@ -27,14 +27,13 @@ def test_earth_relief_01d_igpp_synbath(data_source): Test some properties of the earth relief 01d data with IGPP and SYNBATH data. """ - data = load_earth_relief( - resolution="01d", registration="gridline", data_source=data_source - ) + data = load_earth_relief(resolution="01d", data_source=data_source) assert data.name == "elevation" assert data.attrs["units"] == "meters" assert data.attrs["long_name"] == "Earth elevation relative to the geoid" assert data.attrs["vertical_datum"] == "EGM96" assert data.attrs["horizontal_datum"] == "WGS84" + assert data.gmt.registration == 0 assert data.shape == (181, 361) npt.assert_allclose(data.lat, np.arange(-90, 91, 1)) npt.assert_allclose(data.lon, np.arange(-180, 181, 1)) From dd1b68544929e8f3c3ca82bb8f6d2e8e2f9be5bb Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Thu, 22 Dec 2022 08:45:03 -0500 Subject: [PATCH 02/40] update default registration for load_earth_age --- pygmt/datasets/load_remote_dataset.py | 20 ++++++++++---------- pygmt/tests/test_datasets_earth_age.py | 4 +++- pygmt/tests/test_datasets_earth_relief.py | 1 + 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/pygmt/datasets/load_remote_dataset.py b/pygmt/datasets/load_remote_dataset.py index 2b80f8823a5..fc3dd90a666 100644 --- a/pygmt/datasets/load_remote_dataset.py +++ b/pygmt/datasets/load_remote_dataset.py @@ -95,16 +95,16 @@ class GMTRemoteDataset(NamedTuple): units="Myr", extra_attributes={"horizontal_datum": "WGS84"}, resolutions={ - "01d": Resolution(["pixel", "gridline"], False), - "30m": Resolution(["pixel", "gridline"], False), - "20m": Resolution(["pixel", "gridline"], False), - "15m": Resolution(["pixel", "gridline"], False), - "10m": Resolution(["pixel", "gridline"], False), - "06m": Resolution(["pixel", "gridline"], False), - "05m": Resolution(["pixel", "gridline"], True), - "04m": Resolution(["pixel", "gridline"], True), - "03m": Resolution(["pixel", "gridline"], True), - "02m": Resolution(["pixel", "gridline"], True), + "01d": Resolution(["gridline", "pixel"], False), + "30m": Resolution(["gridline", "pixel"], False), + "20m": Resolution(["gridline", "pixel"], False), + "15m": Resolution(["gridline", "pixel"], False), + "10m": Resolution(["gridline", "pixel"], False), + "06m": Resolution(["gridline", "pixel"], False), + "05m": Resolution(["gridline", "pixel"], True), + "04m": Resolution(["gridline", "pixel"], True), + "03m": Resolution(["gridline", "pixel"], True), + "02m": Resolution(["gridline", "pixel"], True), "01m": Resolution(["gridline"], True), }, ), diff --git a/pygmt/tests/test_datasets_earth_age.py b/pygmt/tests/test_datasets_earth_age.py index a3ebfdba409..70f648cc64a 100644 --- a/pygmt/tests/test_datasets_earth_age.py +++ b/pygmt/tests/test_datasets_earth_age.py @@ -31,12 +31,13 @@ def test_earth_age_01d(): """ Test some properties of the earth age 01d data. """ - data = load_earth_age(resolution="01d", registration="gridline") + data = load_earth_age(resolution="01d") assert data.name == "seafloor_age" assert data.attrs["units"] == "Myr" assert data.attrs["long_name"] == "age of seafloor crust" assert data.attrs["horizontal_datum"] == "WGS84" assert data.shape == (181, 361) + assert data.gmt.registration == 0 npt.assert_allclose(data.lat, np.arange(-90, 91, 1)) npt.assert_allclose(data.lon, np.arange(-180, 181, 1)) npt.assert_allclose(data.min(), 0.167381, rtol=1e-5) @@ -51,6 +52,7 @@ def test_earth_age_01d_with_region(): resolution="01d", region=[-10, 10, -5, 5], registration="gridline" ) assert data.shape == (11, 21) + assert data.gmt.registration == 0 npt.assert_allclose(data.lat, np.arange(-5, 6, 1)) npt.assert_allclose(data.lon, np.arange(-10, 11, 1)) npt.assert_allclose(data.min(), 11.293945) diff --git a/pygmt/tests/test_datasets_earth_relief.py b/pygmt/tests/test_datasets_earth_relief.py index 27615aa901c..7079803c5a4 100644 --- a/pygmt/tests/test_datasets_earth_relief.py +++ b/pygmt/tests/test_datasets_earth_relief.py @@ -131,6 +131,7 @@ def test_earth_gebcosi_15m_with_region(): data_source="gebcosi", ) assert data.shape == (16, 8) + assert data.gmt.registration == 1 npt.assert_allclose(data.lat, np.arange(-87.875, -84, 0.25)) npt.assert_allclose(data.lon, np.arange(85.125, 87, 0.25)) npt.assert_allclose(data.min(), -531) From 5d649e644bf6d23f1dba5383b7306ec7f70d7649 Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Mon, 26 Dec 2022 23:05:30 +0800 Subject: [PATCH 03/40] Update pygmt/datasets/load_remote_dataset.py --- pygmt/datasets/load_remote_dataset.py | 24 ------------------------ 1 file changed, 24 deletions(-) diff --git a/pygmt/datasets/load_remote_dataset.py b/pygmt/datasets/load_remote_dataset.py index 978db2a359f..43c9c8f9851 100644 --- a/pygmt/datasets/load_remote_dataset.py +++ b/pygmt/datasets/load_remote_dataset.py @@ -64,30 +64,6 @@ class GMTRemoteDataset(NamedTuple): datasets = { - "earth_relief": GMTRemoteDataset( - title="Earth relief", - name="elevation", - long_name="Earth elevation relative to the geoid", - units="meters", - extra_attributes={"vertical_datum": "EGM96", "horizontal_datum": "WGS84"}, - resolutions={ - "01d": Resolution(["gridline", "pixel"], False), - "30m": Resolution(["gridline", "pixel"], False), - "20m": Resolution(["gridline", "pixel"], False), - "15m": Resolution(["gridline", "pixel"], False), - "10m": Resolution(["gridline", "pixel"], False), - "06m": Resolution(["gridline", "pixel"], False), - "05m": Resolution(["gridline", "pixel"], True), - "04m": Resolution(["gridline", "pixel"], True), - "03m": Resolution(["gridline", "pixel"], True), - "02m": Resolution(["gridline", "pixel"], True), - "01m": Resolution(["gridline", "pixel"], True), - "30s": Resolution(["gridline", "pixel"], True), - "15s": Resolution(["pixel"], True), - "03s": Resolution(["gridline"], True), - "01s": Resolution(["gridline"], True), - }, - ), "earth_age": GMTRemoteDataset( title="seafloor age", name="seafloor_age", From 24b8931b5f255f805f2961c804c188b780540b3d Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Tue, 27 Dec 2022 06:30:22 -0500 Subject: [PATCH 04/40] change if statement for default registration --- pygmt/datasets/load_remote_dataset.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pygmt/datasets/load_remote_dataset.py b/pygmt/datasets/load_remote_dataset.py index 43c9c8f9851..20f22e70570 100644 --- a/pygmt/datasets/load_remote_dataset.py +++ b/pygmt/datasets/load_remote_dataset.py @@ -234,7 +234,12 @@ def _load_remote_dataset( if resolution not in dataset.resolutions.keys(): raise GMTInvalidInput(f"Invalid resolution '{resolution}'.") if registration is None: - registration = dataset.resolutions[resolution].registrations[0] + # Check if "gridline" is an available registration for the resolution + if "gridline" in dataset.resolutions[resolution].registrations: + # Use default of gridline registration if available + registration = "gridline" + else: + registration = "pixel" if registration in ("pixel", "gridline"): # If None, let GMT decide on Pixel/Gridline type reg = f"_{registration[0]}" From bdfc550f15c1b43e044e229db8ef190ffb92d2fc Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Tue, 27 Dec 2022 06:45:17 -0500 Subject: [PATCH 05/40] add default registration testing for test_datasets_earth_age.py --- pygmt/datasets/load_remote_dataset.py | 1 - pygmt/helpers/testing.py | 1 + pygmt/tests/test_datasets_earth_age.py | 16 ++++++++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/pygmt/datasets/load_remote_dataset.py b/pygmt/datasets/load_remote_dataset.py index 20f22e70570..4855896917e 100644 --- a/pygmt/datasets/load_remote_dataset.py +++ b/pygmt/datasets/load_remote_dataset.py @@ -241,7 +241,6 @@ def _load_remote_dataset( else: registration = "pixel" if registration in ("pixel", "gridline"): - # If None, let GMT decide on Pixel/Gridline type reg = f"_{registration[0]}" else: raise GMTInvalidInput( diff --git a/pygmt/helpers/testing.py b/pygmt/helpers/testing.py index 06eb3af0482..78111092960 100644 --- a/pygmt/helpers/testing.py +++ b/pygmt/helpers/testing.py @@ -180,6 +180,7 @@ def download_test_data(): # Earth seafloor age grids "@earth_age_01d_g", "@S90W180.earth_age_05m_g.nc", # Specific grid for 05m test + "@N00W030.earth_age_01m_g.nc", # Specific grid for 01m test # Earth geoid grids "@earth_geoid_01d_g", "@S90W180.earth_geoid_05m_g.nc", # Specific grid for 05m test diff --git a/pygmt/tests/test_datasets_earth_age.py b/pygmt/tests/test_datasets_earth_age.py index 70f648cc64a..259cfde638e 100644 --- a/pygmt/tests/test_datasets_earth_age.py +++ b/pygmt/tests/test_datasets_earth_age.py @@ -91,3 +91,19 @@ def test_earth_age_incorrect_resolution_registration(): """ with pytest.raises(GMTInvalidInput): load_earth_age(resolution="01m", region=[0, 1, 3, 5], registration="pixel") + +def test_earth_age_01m_default_registration(): + """ + Test that the grid returned by default for the 1 arc-minute resolution + has a "gridline" registration. + """ + data = load_earth_age(resolution="01m", region=[-10, -9, 3, 5]) + assert data.shape == (121, 61) + assert data.gmt.registration == 0 + assert data.coords["lat"].data.min() == 3.0 + assert data.coords["lat"].data.max() == 5.0 + assert data.coords["lon"].data.min() == -10.0 + assert data.coords["lon"].data.max() == -9.0 + npt.assert_allclose(data.min(), 88.63) + npt.assert_allclose(data.max(), 125.25) + From 7b0a219c402f0d52b0d80ef78df57608c659ea7d Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Tue, 27 Dec 2022 06:47:47 -0500 Subject: [PATCH 06/40] update earth_age registration docstring --- pygmt/datasets/earth_age.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pygmt/datasets/earth_age.py b/pygmt/datasets/earth_age.py index 8b0fc50ec4e..43cee8341d7 100644 --- a/pygmt/datasets/earth_age.py +++ b/pygmt/datasets/earth_age.py @@ -44,9 +44,8 @@ def load_earth_age(resolution="01d", region=None, registration=None): registration : str Grid registration type. Either ``"pixel"`` for pixel registration or - ``"gridline"`` for gridline registration. Default is ``None``, where - a pixel-registered grid is returned unless only the - gridline-registered grid is available. + ``"gridline"`` for gridline registration. Default is ``"gridline"`` + when available. Returns ------- From 2fefe641c8a92bfde0e46b774c1b9e116cd16bdf Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Tue, 27 Dec 2022 06:57:20 -0500 Subject: [PATCH 07/40] update earth_free_air_anomaly registration docstring --- pygmt/datasets/earth_free_air_anomaly.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pygmt/datasets/earth_free_air_anomaly.py b/pygmt/datasets/earth_free_air_anomaly.py index afc94a4bbdf..d35497b3306 100644 --- a/pygmt/datasets/earth_free_air_anomaly.py +++ b/pygmt/datasets/earth_free_air_anomaly.py @@ -44,9 +44,8 @@ def load_earth_free_air_anomaly(resolution="01d", region=None, registration=None registration : str Grid registration type. Either ``"pixel"`` for pixel registration or - ``"gridline"`` for gridline registration. Default is ``None``, where - a pixel-registered grid is returned unless only the - gridline-registered grid is available. + ``"gridline"`` for gridline registration. Default is ``"gridline"`` + when available. Returns ------- From 3442893a3b396589737b64719ef3072c51a1278f Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Tue, 27 Dec 2022 06:58:51 -0500 Subject: [PATCH 08/40] update test_datasets_earth_free_air_anomaly.py for default registration --- pygmt/helpers/testing.py | 1 + .../tests/test_datasets_earth_free_air_anomaly.py | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/pygmt/helpers/testing.py b/pygmt/helpers/testing.py index 78111092960..dfff6983a85 100644 --- a/pygmt/helpers/testing.py +++ b/pygmt/helpers/testing.py @@ -192,6 +192,7 @@ def download_test_data(): # Earth free-air anomaly grids "@earth_faa_01d_g", "@S90W180.earth_faa_05m_g.nc", # Specific grid for 05m test + "@N00W030.earth_faa_01m_g.nc", # Specific grid for 01m test # Earth vertical gravity gradient grids "@earth_vgg_01d_g", "@S90W180.earth_vgg_05m_g.nc", # Specific grid for 05m test diff --git a/pygmt/tests/test_datasets_earth_free_air_anomaly.py b/pygmt/tests/test_datasets_earth_free_air_anomaly.py index f2351e24c11..c4e566dfda9 100644 --- a/pygmt/tests/test_datasets_earth_free_air_anomaly.py +++ b/pygmt/tests/test_datasets_earth_free_air_anomaly.py @@ -80,3 +80,18 @@ def test_earth_faa_05m_without_region(): """ with pytest.raises(GMTInvalidInput): load_earth_free_air_anomaly("05m") + +def test_earth_age_01m_default_registration(): + """ + Test that the grid returned by default for the 1 arc-minute resolution + has a "pixel" registration. + """ + data = load_earth_free_air_anomaly(resolution="01m", region=[-10, -9, 3, 5]) + assert data.shape == (120, 60) + assert data.gmt.registration == 1 + npt.assert_allclose(data.coords["lat"].data.min(), 3.008333333) + npt.assert_allclose(data.coords["lat"].data.max(), 4.991666666) + npt.assert_allclose(data.coords["lon"].data.min(), -9.99166666) + npt.assert_allclose(data.coords["lon"].data.max(), -9.00833333) + npt.assert_allclose(data.min(), -51) + npt.assert_allclose(data.max(), 113.675) From d36f53d5e814ed5fbba7db4dacf364af6b1b778f Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Tue, 27 Dec 2022 07:05:37 -0500 Subject: [PATCH 09/40] update registration docstring in earth_geoid.py --- pygmt/datasets/earth_geoid.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pygmt/datasets/earth_geoid.py b/pygmt/datasets/earth_geoid.py index 87228ef771b..5025e7383fe 100644 --- a/pygmt/datasets/earth_geoid.py +++ b/pygmt/datasets/earth_geoid.py @@ -44,9 +44,8 @@ def load_earth_geoid(resolution="01d", region=None, registration=None): registration : str Grid registration type. Either ``"pixel"`` for pixel registration or - ``"gridline"`` for gridline registration. Default is ``None``, where - a pixel-registered grid is returned unless only the - gridline-registered grid is available. + ``"gridline"`` for gridline registration. Default is ``"gridline"`` + when available. Returns ------- From 24b3e73a73afa9e51eba6a65beaa0ebd7515a3b8 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Tue, 27 Dec 2022 07:11:04 -0500 Subject: [PATCH 10/40] add test to test_datasets_earth_geoid.py for default registration --- pygmt/helpers/testing.py | 1 + .../test_datasets_earth_free_air_anomaly.py | 2 +- pygmt/tests/test_datasets_earth_geoid.py | 16 ++++++++++++++++ 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/pygmt/helpers/testing.py b/pygmt/helpers/testing.py index dfff6983a85..8e0c4ca6e42 100644 --- a/pygmt/helpers/testing.py +++ b/pygmt/helpers/testing.py @@ -184,6 +184,7 @@ def download_test_data(): # Earth geoid grids "@earth_geoid_01d_g", "@S90W180.earth_geoid_05m_g.nc", # Specific grid for 05m test + "@N00W030.earth_geoid_01m_g.nc", # Specific grid for 01m test # Earth magnetic anomaly grids "@earth_mag_01d_g", "@S90W180.earth_mag_05m_g.nc", # Specific grid for 05m test diff --git a/pygmt/tests/test_datasets_earth_free_air_anomaly.py b/pygmt/tests/test_datasets_earth_free_air_anomaly.py index c4e566dfda9..3ae5bf9f06f 100644 --- a/pygmt/tests/test_datasets_earth_free_air_anomaly.py +++ b/pygmt/tests/test_datasets_earth_free_air_anomaly.py @@ -81,7 +81,7 @@ def test_earth_faa_05m_without_region(): with pytest.raises(GMTInvalidInput): load_earth_free_air_anomaly("05m") -def test_earth_age_01m_default_registration(): +def test_earth_faa_01m_default_registration(): """ Test that the grid returned by default for the 1 arc-minute resolution has a "pixel" registration. diff --git a/pygmt/tests/test_datasets_earth_geoid.py b/pygmt/tests/test_datasets_earth_geoid.py index 281a5a957d9..a88089301ca 100644 --- a/pygmt/tests/test_datasets_earth_geoid.py +++ b/pygmt/tests/test_datasets_earth_geoid.py @@ -89,3 +89,19 @@ def test_earth_geoid_incorrect_resolution_registration(): """ with pytest.raises(GMTInvalidInput): load_earth_geoid(resolution="01m", region=[0, 1, 3, 5], registration="pixel") + +def test_earth_geoid_01m_default_registration(): + """ + Test that the grid returned by default for the 1 arc-minute resolution + has a "gridline" registration. + """ + data = load_earth_geoid(resolution="01m", region=[-10, -9, 3, 5]) + assert data.shape == (121, 61) + assert data.gmt.registration == 0 + assert data.coords["lat"].data.min() == 3.0 + assert data.coords["lat"].data.max() == 5.0 + assert data.coords["lon"].data.min() == -10.0 + assert data.coords["lon"].data.max() == -9.0 + npt.assert_allclose(data.min(), 20.34) + npt.assert_allclose(data.max(), 30.039999) + From 2a64cf5dbe707ea176de18785b87e4b7701fbcda Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Tue, 27 Dec 2022 07:12:13 -0500 Subject: [PATCH 11/40] update registration docstring in earth_magnetic_anomaly.py --- pygmt/datasets/earth_magnetic_anomaly.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pygmt/datasets/earth_magnetic_anomaly.py b/pygmt/datasets/earth_magnetic_anomaly.py index c7d010acf6b..629c5ba974e 100644 --- a/pygmt/datasets/earth_magnetic_anomaly.py +++ b/pygmt/datasets/earth_magnetic_anomaly.py @@ -49,9 +49,8 @@ def load_earth_magnetic_anomaly( registration : str Grid registration type. Either ``"pixel"`` for pixel registration or - ``"gridline"`` for gridline registration. Default is ``None``, where - a pixel-registered grid is returned unless only the - gridline-registered grid is available. + ``"gridline"`` for gridline registration. Default is ``"gridline"`` + when available. mag4km : bool Choose the data version to use. The default is ``False``, which is From eaa57aed892326e33e55c17599bd856e07cd95cd Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Tue, 27 Dec 2022 07:25:33 -0500 Subject: [PATCH 12/40] add test to test_datasets_earth_magnetic_anomaly.py for default registration --- pygmt/helpers/testing.py | 1 + .../tests/test_datasets_earth_magnetic_anomaly.py | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/pygmt/helpers/testing.py b/pygmt/helpers/testing.py index 8e0c4ca6e42..35c448ec5e3 100644 --- a/pygmt/helpers/testing.py +++ b/pygmt/helpers/testing.py @@ -188,6 +188,7 @@ def download_test_data(): # Earth magnetic anomaly grids "@earth_mag_01d_g", "@S90W180.earth_mag_05m_g.nc", # Specific grid for 05m test + "@S30W060.earth_mag_02m_p.nc", # Specific grid for 02m test "@earth_mag4km_01d_g", "@S90W180.earth_mag4km_05m_g.nc", # Specific grid for 05m test # Earth free-air anomaly grids diff --git a/pygmt/tests/test_datasets_earth_magnetic_anomaly.py b/pygmt/tests/test_datasets_earth_magnetic_anomaly.py index 6c2f939ab55..b5ac9833f03 100644 --- a/pygmt/tests/test_datasets_earth_magnetic_anomaly.py +++ b/pygmt/tests/test_datasets_earth_magnetic_anomaly.py @@ -146,3 +146,18 @@ def test_earth_mag4km_05m_with_region(): assert data.lon.max() == -112 npt.assert_allclose(data.min(), -128.40015) npt.assert_allclose(data.max(), 76.80005) + +def test_earth_mag_02m_default_registration(): + """ + Test that the grid returned by default for the 2 arc-minute resolution + has a "pixel" registration. + """ + data = load_earth_magnetic_anomaly(resolution="02m", region=[-10, -9, 3, 5]) + assert data.shape == (60, 30) + assert data.gmt.registration == 1 + npt.assert_allclose(data.coords["lat"].data.min(), 3.016666667) + npt.assert_allclose(data.coords["lat"].data.max(), 4.983333333) + npt.assert_allclose(data.coords["lon"].data.min(), -9.98333333) + npt.assert_allclose(data.coords["lon"].data.max(), -9.01666667) + npt.assert_allclose(data.min(), -231) + npt.assert_allclose(data.max(), 131.79999) From 040883e568054bc37316c30ef774c0827b6d23e9 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Tue, 27 Dec 2022 07:27:26 -0500 Subject: [PATCH 13/40] update registration docstring in earth_vertical_gravity_gradient.py --- pygmt/datasets/earth_vertical_gravity_gradient.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pygmt/datasets/earth_vertical_gravity_gradient.py b/pygmt/datasets/earth_vertical_gravity_gradient.py index b47daad94c7..62b9dd2c802 100644 --- a/pygmt/datasets/earth_vertical_gravity_gradient.py +++ b/pygmt/datasets/earth_vertical_gravity_gradient.py @@ -45,9 +45,9 @@ def load_earth_vertical_gravity_gradient( registration : str Grid registration type. Either ``"pixel"`` for pixel registration or - ``"gridline"`` for gridline registration. Default is ``None``, where - a pixel-registered grid is returned unless only the - gridline-registered grid is available. + ``"gridline"`` for gridline registration. Default is ``"gridline"`` + when available. + Returns ------- From 79ca10e763f06c6587ad6b65160b241262e4c723 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Tue, 27 Dec 2022 07:27:53 -0500 Subject: [PATCH 14/40] run make format --- pygmt/tests/test_datasets_earth_age.py | 6 +++--- pygmt/tests/test_datasets_earth_free_air_anomaly.py | 5 +++-- pygmt/tests/test_datasets_earth_geoid.py | 6 +++--- pygmt/tests/test_datasets_earth_magnetic_anomaly.py | 5 +++-- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/pygmt/tests/test_datasets_earth_age.py b/pygmt/tests/test_datasets_earth_age.py index 259cfde638e..1654b63e504 100644 --- a/pygmt/tests/test_datasets_earth_age.py +++ b/pygmt/tests/test_datasets_earth_age.py @@ -92,10 +92,11 @@ def test_earth_age_incorrect_resolution_registration(): with pytest.raises(GMTInvalidInput): load_earth_age(resolution="01m", region=[0, 1, 3, 5], registration="pixel") + def test_earth_age_01m_default_registration(): """ - Test that the grid returned by default for the 1 arc-minute resolution - has a "gridline" registration. + Test that the grid returned by default for the 1 arc-minute resolution has + a "gridline" registration. """ data = load_earth_age(resolution="01m", region=[-10, -9, 3, 5]) assert data.shape == (121, 61) @@ -106,4 +107,3 @@ def test_earth_age_01m_default_registration(): assert data.coords["lon"].data.max() == -9.0 npt.assert_allclose(data.min(), 88.63) npt.assert_allclose(data.max(), 125.25) - diff --git a/pygmt/tests/test_datasets_earth_free_air_anomaly.py b/pygmt/tests/test_datasets_earth_free_air_anomaly.py index 3ae5bf9f06f..8c26bae533f 100644 --- a/pygmt/tests/test_datasets_earth_free_air_anomaly.py +++ b/pygmt/tests/test_datasets_earth_free_air_anomaly.py @@ -81,10 +81,11 @@ def test_earth_faa_05m_without_region(): with pytest.raises(GMTInvalidInput): load_earth_free_air_anomaly("05m") + def test_earth_faa_01m_default_registration(): """ - Test that the grid returned by default for the 1 arc-minute resolution - has a "pixel" registration. + Test that the grid returned by default for the 1 arc-minute resolution has + a "pixel" registration. """ data = load_earth_free_air_anomaly(resolution="01m", region=[-10, -9, 3, 5]) assert data.shape == (120, 60) diff --git a/pygmt/tests/test_datasets_earth_geoid.py b/pygmt/tests/test_datasets_earth_geoid.py index a88089301ca..2d76fa67d9a 100644 --- a/pygmt/tests/test_datasets_earth_geoid.py +++ b/pygmt/tests/test_datasets_earth_geoid.py @@ -90,10 +90,11 @@ def test_earth_geoid_incorrect_resolution_registration(): with pytest.raises(GMTInvalidInput): load_earth_geoid(resolution="01m", region=[0, 1, 3, 5], registration="pixel") + def test_earth_geoid_01m_default_registration(): """ - Test that the grid returned by default for the 1 arc-minute resolution - has a "gridline" registration. + Test that the grid returned by default for the 1 arc-minute resolution has + a "gridline" registration. """ data = load_earth_geoid(resolution="01m", region=[-10, -9, 3, 5]) assert data.shape == (121, 61) @@ -104,4 +105,3 @@ def test_earth_geoid_01m_default_registration(): assert data.coords["lon"].data.max() == -9.0 npt.assert_allclose(data.min(), 20.34) npt.assert_allclose(data.max(), 30.039999) - diff --git a/pygmt/tests/test_datasets_earth_magnetic_anomaly.py b/pygmt/tests/test_datasets_earth_magnetic_anomaly.py index b5ac9833f03..00b2b896eb5 100644 --- a/pygmt/tests/test_datasets_earth_magnetic_anomaly.py +++ b/pygmt/tests/test_datasets_earth_magnetic_anomaly.py @@ -147,10 +147,11 @@ def test_earth_mag4km_05m_with_region(): npt.assert_allclose(data.min(), -128.40015) npt.assert_allclose(data.max(), 76.80005) + def test_earth_mag_02m_default_registration(): """ - Test that the grid returned by default for the 2 arc-minute resolution - has a "pixel" registration. + Test that the grid returned by default for the 2 arc-minute resolution has + a "pixel" registration. """ data = load_earth_magnetic_anomaly(resolution="02m", region=[-10, -9, 3, 5]) assert data.shape == (60, 30) From 664d7daa84f2cbdbfedcac73d2cc95752cf13ace Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Tue, 27 Dec 2022 07:35:42 -0500 Subject: [PATCH 15/40] add test for default registration to test_datasets_earth_vertical_gravity_gradient.py --- pygmt/helpers/testing.py | 3 ++- ...datasets_earth_vertical_gravity_gradient.py | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/pygmt/helpers/testing.py b/pygmt/helpers/testing.py index 35c448ec5e3..759754cc3ae 100644 --- a/pygmt/helpers/testing.py +++ b/pygmt/helpers/testing.py @@ -194,10 +194,11 @@ def download_test_data(): # Earth free-air anomaly grids "@earth_faa_01d_g", "@S90W180.earth_faa_05m_g.nc", # Specific grid for 05m test - "@N00W030.earth_faa_01m_g.nc", # Specific grid for 01m test + "@N00W030.earth_faa_01m_p.nc", # Specific grid for 01m test # Earth vertical gravity gradient grids "@earth_vgg_01d_g", "@S90W180.earth_vgg_05m_g.nc", # Specific grid for 05m test + "@N00W030.earth_vgg_01m_p.nc", # Specific grid for 01m test # Other cache files "@capitals.gmt", "@earth_relief_20m_holes.grd", diff --git a/pygmt/tests/test_datasets_earth_vertical_gravity_gradient.py b/pygmt/tests/test_datasets_earth_vertical_gravity_gradient.py index 2bbb85764d5..2030b909803 100644 --- a/pygmt/tests/test_datasets_earth_vertical_gravity_gradient.py +++ b/pygmt/tests/test_datasets_earth_vertical_gravity_gradient.py @@ -96,3 +96,21 @@ def test_earth_vertical_gravity_gradient_incorrect_resolution_registration(): load_earth_vertical_gravity_gradient( resolution="01m", region=[0, 1, 3, 5], registration="gridline" ) + + +def test_earth_vertical_gravity_gradient_01m_default_registration(): + """ + Test that the grid returned by default for the 1 arc-minute resolution has + a "pixel" registration. + """ + data = load_earth_vertical_gravity_gradient( + resolution="01m", region=[-10, -9, 3, 5] + ) + assert data.shape == (120, 60) + assert data.gmt.registration == 1 + npt.assert_allclose(data.coords["lat"].data.min(), 3.008333333) + npt.assert_allclose(data.coords["lat"].data.max(), 4.991666666) + npt.assert_allclose(data.coords["lon"].data.min(), -9.99166666) + npt.assert_allclose(data.coords["lon"].data.max(), -9.00833333) + npt.assert_allclose(data.min(), -40.25) + npt.assert_allclose(data.max(), 81.75) From c7fa8f5c3e818ed16ac268ff4593fbf1a023d0ca Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Tue, 27 Dec 2022 07:37:21 -0500 Subject: [PATCH 16/40] update registration docstring to earth_relief.py --- pygmt/datasets/earth_relief.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pygmt/datasets/earth_relief.py b/pygmt/datasets/earth_relief.py index fe8937492a9..a712c8b0ec8 100644 --- a/pygmt/datasets/earth_relief.py +++ b/pygmt/datasets/earth_relief.py @@ -57,9 +57,8 @@ def load_earth_relief( registration : str Grid registration type. Either ``"pixel"`` for pixel registration or - ``"gridline"`` for gridline registration. Default is ``None``, where - a gridline-registered grid is returned unless only the pixel-registered - grid is available. + ``"gridline"`` for gridline registration. Default is ``"gridline"`` + when available. **Note**: For GMT 6.3, ``registration=None`` returns a pixel-registered grid by default unless only the gridline-registered grid is available. From 7ec384da43841cb643c88321735fc15b6a360679 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Tue, 27 Dec 2022 07:37:51 -0500 Subject: [PATCH 17/40] remove note in earth_relief.py --- pygmt/datasets/earth_relief.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/pygmt/datasets/earth_relief.py b/pygmt/datasets/earth_relief.py index a712c8b0ec8..7a2ea6c3115 100644 --- a/pygmt/datasets/earth_relief.py +++ b/pygmt/datasets/earth_relief.py @@ -60,9 +60,6 @@ def load_earth_relief( ``"gridline"`` for gridline registration. Default is ``"gridline"`` when available. - **Note**: For GMT 6.3, ``registration=None`` returns a pixel-registered - grid by default unless only the gridline-registered grid is available. - data_source : str Select the source for the Earth relief data. From 1fadc26cef8295c98f6e4e68560ea54d7194e1bd Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Tue, 27 Dec 2022 08:10:57 -0500 Subject: [PATCH 18/40] add tests for loading default registrations for 15s and 03s to test_datasets_earth_relief.py --- pygmt/helpers/testing.py | 2 ++ pygmt/tests/test_datasets_earth_relief.py | 30 +++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/pygmt/helpers/testing.py b/pygmt/helpers/testing.py index 759754cc3ae..7811076057b 100644 --- a/pygmt/helpers/testing.py +++ b/pygmt/helpers/testing.py @@ -175,6 +175,8 @@ def download_test_data(): "@N37W120.earth_relief_03s_g.nc", "@N00W090.earth_relief_03m_p.nc", "@N00E135.earth_relief_30s_g.nc", + "@N00W010.earth_relief_15s_p.nc", # Specific grid for 15s test + "@N04W010.earth_relief_03s_g.nc", # Specific grid for 03s test # Earth synbath relief grids "@S15W105.earth_synbath_30s_p.nc", # Earth seafloor age grids diff --git a/pygmt/tests/test_datasets_earth_relief.py b/pygmt/tests/test_datasets_earth_relief.py index 7079803c5a4..44d410aa884 100644 --- a/pygmt/tests/test_datasets_earth_relief.py +++ b/pygmt/tests/test_datasets_earth_relief.py @@ -247,3 +247,33 @@ def test_earth_relief_incorrect_resolution_registration(data_source): registration="gridline", data_source=data_source, ) + +def test_earth_relief_15s_default_registration(): + """ + Test that the grid returned by default for the 15 arc-second resolution has + a "pixel" registration. + """ + data = load_earth_relief(resolution="15s", region=[-10, -9.5, 4, 5]) + assert data.shape == (240, 120) + assert data.gmt.registration == 1 + npt.assert_allclose(data.coords["lat"].data.min(), 4.002083) + npt.assert_allclose(data.coords["lat"].data.max(), 4.997917) + npt.assert_allclose(data.coords["lon"].data.min(), -9.997917) + npt.assert_allclose(data.coords["lon"].data.max(), -9.502083) + npt.assert_allclose(data.min(), -3897) + npt.assert_allclose(data.max(), -74) + +def test_earth_relief_03s_default_registration(): + """ + Test that the grid returned by default for the 3 arc-second resolution has + a "gridline" registration. + """ + data = load_earth_relief(resolution="03s", region=[-10, -9.8, 4.9, 5]) + assert data.shape == (121, 241) + assert data.gmt.registration == 0 + npt.assert_allclose(data.coords["lat"].data.min(), 4.9) + npt.assert_allclose(data.coords["lat"].data.max(), 5) + npt.assert_allclose(data.coords["lon"].data.min(), -10) + npt.assert_allclose(data.coords["lon"].data.max(), -9.8) + npt.assert_allclose(data.min(), -2069.996) + npt.assert_allclose(data.max(), -924.0801) From 6f306fdf55903b3eafbdd78dfcb8b055f4e1d5b2 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Tue, 27 Dec 2022 08:11:29 -0500 Subject: [PATCH 19/40] run make format --- pygmt/tests/test_datasets_earth_relief.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pygmt/tests/test_datasets_earth_relief.py b/pygmt/tests/test_datasets_earth_relief.py index 44d410aa884..e54c32f7321 100644 --- a/pygmt/tests/test_datasets_earth_relief.py +++ b/pygmt/tests/test_datasets_earth_relief.py @@ -248,6 +248,7 @@ def test_earth_relief_incorrect_resolution_registration(data_source): data_source=data_source, ) + def test_earth_relief_15s_default_registration(): """ Test that the grid returned by default for the 15 arc-second resolution has @@ -263,6 +264,7 @@ def test_earth_relief_15s_default_registration(): npt.assert_allclose(data.min(), -3897) npt.assert_allclose(data.max(), -74) + def test_earth_relief_03s_default_registration(): """ Test that the grid returned by default for the 3 arc-second resolution has From e24bcbca834079a8bd8ffa7e3ebcf90cdbb36deb Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Tue, 27 Dec 2022 08:11:58 -0500 Subject: [PATCH 20/40] Update pygmt/datasets/load_remote_dataset.py Co-authored-by: Dongdong Tian --- pygmt/datasets/load_remote_dataset.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pygmt/datasets/load_remote_dataset.py b/pygmt/datasets/load_remote_dataset.py index 4855896917e..c5953e1c727 100644 --- a/pygmt/datasets/load_remote_dataset.py +++ b/pygmt/datasets/load_remote_dataset.py @@ -246,8 +246,8 @@ def _load_remote_dataset( raise GMTInvalidInput( f"Invalid grid registration: '{registration}', should be either " "'pixel', 'gridline' or None. Default is None, where a " - "pixel-registered grid is returned unless only the " - "gridline-registered grid is available." + "gridline-registered grid is returned unless only the " + "pixel-registered grid is available." ) if registration and ( From 087e6a9a222ce4394740bf1ec6b04b58e6837d67 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Tue, 27 Dec 2022 10:07:38 -0500 Subject: [PATCH 21/40] remove test_earth_age_05m_with_region from test_datasets_earth_age.py --- pygmt/helpers/testing.py | 1 - pygmt/tests/test_datasets_earth_age.py | 16 ---------------- 2 files changed, 17 deletions(-) diff --git a/pygmt/helpers/testing.py b/pygmt/helpers/testing.py index 7811076057b..0654ec105f0 100644 --- a/pygmt/helpers/testing.py +++ b/pygmt/helpers/testing.py @@ -181,7 +181,6 @@ def download_test_data(): "@S15W105.earth_synbath_30s_p.nc", # Earth seafloor age grids "@earth_age_01d_g", - "@S90W180.earth_age_05m_g.nc", # Specific grid for 05m test "@N00W030.earth_age_01m_g.nc", # Specific grid for 01m test # Earth geoid grids "@earth_geoid_01d_g", diff --git a/pygmt/tests/test_datasets_earth_age.py b/pygmt/tests/test_datasets_earth_age.py index 1654b63e504..182425e860a 100644 --- a/pygmt/tests/test_datasets_earth_age.py +++ b/pygmt/tests/test_datasets_earth_age.py @@ -59,22 +59,6 @@ def test_earth_age_01d_with_region(): npt.assert_allclose(data.max(), 125.1189) -def test_earth_age_05m_with_region(): - """ - Test loading a subregion of high-resolution earth age. - """ - data = load_earth_age( - resolution="05m", region=[-50, -40, 20, 30], registration="gridline" - ) - assert data.coords["lat"].data.min() == 20.0 - assert data.coords["lat"].data.max() == 30.0 - assert data.coords["lon"].data.min() == -50.0 - assert data.coords["lon"].data.max() == -40.0 - npt.assert_allclose(data.data.min(), 0.040000916) - npt.assert_allclose(data.data.max(), 46.530003) - assert data.sizes["lat"] == 121 - assert data.sizes["lon"] == 121 - def test_earth_age_05m_without_region(): """ From 75519f7d75adc9140eead79e3c7e154f323c8088 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Tue, 27 Dec 2022 10:08:49 -0500 Subject: [PATCH 22/40] remove test_earth_faa_05m_with_region from test_datasets_earth_free_air_anomaly.py --- pygmt/helpers/testing.py | 1 - pygmt/tests/test_datasets_earth_age.py | 1 - .../test_datasets_earth_free_air_anomaly.py | 16 ---------------- 3 files changed, 18 deletions(-) diff --git a/pygmt/helpers/testing.py b/pygmt/helpers/testing.py index 0654ec105f0..95512ec1dcb 100644 --- a/pygmt/helpers/testing.py +++ b/pygmt/helpers/testing.py @@ -194,7 +194,6 @@ def download_test_data(): "@S90W180.earth_mag4km_05m_g.nc", # Specific grid for 05m test # Earth free-air anomaly grids "@earth_faa_01d_g", - "@S90W180.earth_faa_05m_g.nc", # Specific grid for 05m test "@N00W030.earth_faa_01m_p.nc", # Specific grid for 01m test # Earth vertical gravity gradient grids "@earth_vgg_01d_g", diff --git a/pygmt/tests/test_datasets_earth_age.py b/pygmt/tests/test_datasets_earth_age.py index 182425e860a..16b7784e4f6 100644 --- a/pygmt/tests/test_datasets_earth_age.py +++ b/pygmt/tests/test_datasets_earth_age.py @@ -59,7 +59,6 @@ def test_earth_age_01d_with_region(): npt.assert_allclose(data.max(), 125.1189) - def test_earth_age_05m_without_region(): """ Test loading high-resolution earth age without passing 'region'. diff --git a/pygmt/tests/test_datasets_earth_free_air_anomaly.py b/pygmt/tests/test_datasets_earth_free_air_anomaly.py index 8c26bae533f..c9f3a782f19 100644 --- a/pygmt/tests/test_datasets_earth_free_air_anomaly.py +++ b/pygmt/tests/test_datasets_earth_free_air_anomaly.py @@ -57,22 +57,6 @@ def test_earth_faa_01d_with_region(): npt.assert_allclose(data.max(), 69.524994) -def test_earth_faa_05m_with_region(): - """ - Test loading a subregion of high-resolution earth free air anomaly data. - """ - data = load_earth_free_air_anomaly( - resolution="05m", region=[-115, -112, 4, 6], registration="gridline" - ) - assert data.shape == (25, 37) - assert data.lat.min() == 4 - assert data.lat.max() == 6 - assert data.lon.min() == -115 - assert data.lon.max() == -112 - npt.assert_allclose(data.min(), -20.5) - npt.assert_allclose(data.max(), -3.9500122) - - def test_earth_faa_05m_without_region(): """ Test loading high-resolution earth free air anomaly without passing From f66894758b093e503b9cd84aa0d3d3f8ccfd3252 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Tue, 27 Dec 2022 10:11:00 -0500 Subject: [PATCH 23/40] remove test_earth_geoid_05m_with_region from test_datasets_earth_geoid.py --- pygmt/helpers/testing.py | 1 - pygmt/tests/test_datasets_earth_geoid.py | 17 ----------------- 2 files changed, 18 deletions(-) diff --git a/pygmt/helpers/testing.py b/pygmt/helpers/testing.py index 95512ec1dcb..6b6a4711757 100644 --- a/pygmt/helpers/testing.py +++ b/pygmt/helpers/testing.py @@ -184,7 +184,6 @@ def download_test_data(): "@N00W030.earth_age_01m_g.nc", # Specific grid for 01m test # Earth geoid grids "@earth_geoid_01d_g", - "@S90W180.earth_geoid_05m_g.nc", # Specific grid for 05m test "@N00W030.earth_geoid_01m_g.nc", # Specific grid for 01m test # Earth magnetic anomaly grids "@earth_mag_01d_g", diff --git a/pygmt/tests/test_datasets_earth_geoid.py b/pygmt/tests/test_datasets_earth_geoid.py index 2d76fa67d9a..f530987082d 100644 --- a/pygmt/tests/test_datasets_earth_geoid.py +++ b/pygmt/tests/test_datasets_earth_geoid.py @@ -57,23 +57,6 @@ def test_earth_geoid_01d_with_region(): npt.assert_allclose(data.max(), 29.89) -def test_earth_geoid_05m_with_region(): - """ - Test loading a subregion of high-resolution earth geoid. - """ - data = load_earth_geoid( - resolution="05m", region=[-50, -40, 20, 30], registration="gridline" - ) - assert data.coords["lat"].data.min() == 20.0 - assert data.coords["lat"].data.max() == 30.0 - assert data.coords["lon"].data.min() == -50.0 - assert data.coords["lon"].data.max() == -40.0 - npt.assert_allclose(data.min(), -32.79) - npt.assert_allclose(data.max(), 16.57) - assert data.sizes["lat"] == 121 - assert data.sizes["lon"] == 121 - - def test_earth_geoid_05m_without_region(): """ Test loading high-resolution earth geoid without passing 'region'. From 78fc8c1c1b34ceb91492b3486de90e490e24681f Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Tue, 27 Dec 2022 10:11:58 -0500 Subject: [PATCH 24/40] remove test_earth_mag_05m_with_region from test_datasets_earth_magnetic_anomaly.py --- pygmt/helpers/testing.py | 1 - .../test_datasets_earth_magnetic_anomaly.py | 16 ---------------- 2 files changed, 17 deletions(-) diff --git a/pygmt/helpers/testing.py b/pygmt/helpers/testing.py index 6b6a4711757..c8fadf8fdb9 100644 --- a/pygmt/helpers/testing.py +++ b/pygmt/helpers/testing.py @@ -187,7 +187,6 @@ def download_test_data(): "@N00W030.earth_geoid_01m_g.nc", # Specific grid for 01m test # Earth magnetic anomaly grids "@earth_mag_01d_g", - "@S90W180.earth_mag_05m_g.nc", # Specific grid for 05m test "@S30W060.earth_mag_02m_p.nc", # Specific grid for 02m test "@earth_mag4km_01d_g", "@S90W180.earth_mag4km_05m_g.nc", # Specific grid for 05m test diff --git a/pygmt/tests/test_datasets_earth_magnetic_anomaly.py b/pygmt/tests/test_datasets_earth_magnetic_anomaly.py index 00b2b896eb5..7603eba3ce4 100644 --- a/pygmt/tests/test_datasets_earth_magnetic_anomaly.py +++ b/pygmt/tests/test_datasets_earth_magnetic_anomaly.py @@ -57,22 +57,6 @@ def test_earth_mag_01d_with_region(): npt.assert_allclose(data.max(), 127.39996) -def test_earth_mag_05m_with_region(): - """ - Test loading a subregion of high-resolution earth magnetic anomaly data. - """ - data = load_earth_magnetic_anomaly( - resolution="05m", region=[-115, -112, 4, 6], registration="gridline" - ) - assert data.shape == (25, 37) - assert data.lat.min() == 4 - assert data.lat.max() == 6 - assert data.lon.min() == -115 - assert data.lon.max() == -112 - npt.assert_allclose(data.min(), -189.20001) - npt.assert_allclose(data.max(), 107) - - def test_earth_mag_05m_without_region(): """ Test loading high-resolution earth magnetic anomaly without passing From ae6176d07f3fd3132631da4d91e0ed8ed85656d7 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Tue, 27 Dec 2022 10:12:41 -0500 Subject: [PATCH 25/40] remove test_earth_vertical_gravity_gradient_05m_with_region from test_datasets_earth_vertical_gravity_gradient.py --- pygmt/helpers/testing.py | 1 - ..._datasets_earth_vertical_gravity_gradient.py | 17 ----------------- 2 files changed, 18 deletions(-) diff --git a/pygmt/helpers/testing.py b/pygmt/helpers/testing.py index c8fadf8fdb9..3c078f36a35 100644 --- a/pygmt/helpers/testing.py +++ b/pygmt/helpers/testing.py @@ -195,7 +195,6 @@ def download_test_data(): "@N00W030.earth_faa_01m_p.nc", # Specific grid for 01m test # Earth vertical gravity gradient grids "@earth_vgg_01d_g", - "@S90W180.earth_vgg_05m_g.nc", # Specific grid for 05m test "@N00W030.earth_vgg_01m_p.nc", # Specific grid for 01m test # Other cache files "@capitals.gmt", diff --git a/pygmt/tests/test_datasets_earth_vertical_gravity_gradient.py b/pygmt/tests/test_datasets_earth_vertical_gravity_gradient.py index 2030b909803..ee2864e2857 100644 --- a/pygmt/tests/test_datasets_earth_vertical_gravity_gradient.py +++ b/pygmt/tests/test_datasets_earth_vertical_gravity_gradient.py @@ -62,23 +62,6 @@ def test_earth_vertical_gravity_gradient_01d_with_region(): npt.assert_allclose(data.max(), 19.78125) -def test_earth_vertical_gravity_gradient_05m_with_region(): - """ - Test loading a subregion of high-resolution earth vgg. - """ - data = load_earth_vertical_gravity_gradient( - resolution="05m", region=[-50, -40, 20, 26], registration="gridline" - ) - assert data.coords["lat"].data.min() == 20.0 - assert data.coords["lat"].data.max() == 26.0 - assert data.coords["lon"].data.min() == -50.0 - assert data.coords["lon"].data.max() == -40.0 - npt.assert_allclose(data.min(), -107.625) - npt.assert_allclose(data.max(), 159.75) - assert data.sizes["lat"] == 73 - assert data.sizes["lon"] == 121 - - def test_earth_vertical_gravity_gradient_05m_without_region(): """ Test loading high-resolution earth vgg without passing 'region'. From 3714cccfd7d3db0a549dcddf8890b6dc1b71e7d5 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Tue, 27 Dec 2022 10:14:30 -0500 Subject: [PATCH 26/40] remove test_earth_relief_05m_with_region from test_datasets_earth_relief.py --- pygmt/tests/test_datasets_earth_relief.py | 17 ----------------- 1 file changed, 17 deletions(-) diff --git a/pygmt/tests/test_datasets_earth_relief.py b/pygmt/tests/test_datasets_earth_relief.py index e54c32f7321..1d4d06ef44b 100644 --- a/pygmt/tests/test_datasets_earth_relief.py +++ b/pygmt/tests/test_datasets_earth_relief.py @@ -103,23 +103,6 @@ def test_earth_relief_30m(): npt.assert_allclose(data.max(), 5887.5) -def test_earth_relief_05m_with_region(): - """ - Test loading a subregion of high-resolution earth relief grid. - """ - data = load_earth_relief( - resolution="05m", region=[120, 160, 30, 60], registration="gridline" - ) - assert data.coords["lat"].data.min() == 30.0 - assert data.coords["lat"].data.max() == 60.0 - assert data.coords["lon"].data.min() == 120.0 - assert data.coords["lon"].data.max() == 160.0 - assert data.data.min() == -9633.0 - assert data.data.max() == 2532.0 - assert data.sizes["lat"] == 361 - assert data.sizes["lon"] == 481 - - def test_earth_gebcosi_15m_with_region(): """ Test loading a subregion of 15 arc-minutes resolution earth_gebcosi grid. From 9bfb3178d70dbcd8a8c9a7b57aec3b7ee93d5dff Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Tue, 27 Dec 2022 15:09:08 -0500 Subject: [PATCH 27/40] uncomment pull_request for cache data --- .github/workflows/cache_data.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cache_data.yaml b/.github/workflows/cache_data.yaml index 0c3f748a162..ef2704fb67c 100644 --- a/.github/workflows/cache_data.yaml +++ b/.github/workflows/cache_data.yaml @@ -3,7 +3,7 @@ name: Cache data on: # Uncomment the 'pull_request' line below to manually re-cache data artifacts - # pull_request: + pull_request: # Schedule runs on 12 noon every Sunday schedule: - cron: '0 12 * * 0' From bea25d5ce2d7661e18b89c4bd404143585d1335c Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Tue, 27 Dec 2022 16:22:38 -0500 Subject: [PATCH 28/40] recomment pull_request for cache data --- .github/workflows/cache_data.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cache_data.yaml b/.github/workflows/cache_data.yaml index ef2704fb67c..0c3f748a162 100644 --- a/.github/workflows/cache_data.yaml +++ b/.github/workflows/cache_data.yaml @@ -3,7 +3,7 @@ name: Cache data on: # Uncomment the 'pull_request' line below to manually re-cache data artifacts - pull_request: + # pull_request: # Schedule runs on 12 noon every Sunday schedule: - cron: '0 12 * * 0' From 05f79a191dc4333315bfa290c04378573f122792 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Wed, 28 Dec 2022 09:18:17 -0500 Subject: [PATCH 29/40] Apply suggestions from code review Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com> --- pygmt/datasets/earth_age.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pygmt/datasets/earth_age.py b/pygmt/datasets/earth_age.py index 43cee8341d7..a84fc93c733 100644 --- a/pygmt/datasets/earth_age.py +++ b/pygmt/datasets/earth_age.py @@ -44,8 +44,7 @@ def load_earth_age(resolution="01d", region=None, registration=None): registration : str Grid registration type. Either ``"pixel"`` for pixel registration or - ``"gridline"`` for gridline registration. Default is ``"gridline"`` - when available. + ``"gridline"`` for gridline registration. Default is ``"gridline"``. Returns ------- From 8b09c33051eab9bae087226b5750b22de7711457 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Wed, 28 Dec 2022 09:18:53 -0500 Subject: [PATCH 30/40] Apply suggestions from code review Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com> --- pygmt/datasets/earth_free_air_anomaly.py | 2 +- pygmt/datasets/earth_geoid.py | 3 +-- pygmt/datasets/earth_magnetic_anomaly.py | 2 +- pygmt/datasets/earth_relief.py | 2 +- pygmt/datasets/earth_vertical_gravity_gradient.py | 3 +-- 5 files changed, 5 insertions(+), 7 deletions(-) diff --git a/pygmt/datasets/earth_free_air_anomaly.py b/pygmt/datasets/earth_free_air_anomaly.py index d35497b3306..a81b7e77895 100644 --- a/pygmt/datasets/earth_free_air_anomaly.py +++ b/pygmt/datasets/earth_free_air_anomaly.py @@ -45,7 +45,7 @@ def load_earth_free_air_anomaly(resolution="01d", region=None, registration=None registration : str Grid registration type. Either ``"pixel"`` for pixel registration or ``"gridline"`` for gridline registration. Default is ``"gridline"`` - when available. + for all resolutions except ``"01m"`` which is ``"pixel"`` only. Returns ------- diff --git a/pygmt/datasets/earth_geoid.py b/pygmt/datasets/earth_geoid.py index 5025e7383fe..fa5d1ad020d 100644 --- a/pygmt/datasets/earth_geoid.py +++ b/pygmt/datasets/earth_geoid.py @@ -44,8 +44,7 @@ def load_earth_geoid(resolution="01d", region=None, registration=None): registration : str Grid registration type. Either ``"pixel"`` for pixel registration or - ``"gridline"`` for gridline registration. Default is ``"gridline"`` - when available. + ``"gridline"`` for gridline registration. Default is ``"gridline"``. Returns ------- diff --git a/pygmt/datasets/earth_magnetic_anomaly.py b/pygmt/datasets/earth_magnetic_anomaly.py index 629c5ba974e..0de1d9e52c6 100644 --- a/pygmt/datasets/earth_magnetic_anomaly.py +++ b/pygmt/datasets/earth_magnetic_anomaly.py @@ -50,7 +50,7 @@ def load_earth_magnetic_anomaly( registration : str Grid registration type. Either ``"pixel"`` for pixel registration or ``"gridline"`` for gridline registration. Default is ``"gridline"`` - when available. + for all resolutions except ``"02m"`` which is ``"pixel"`` only. mag4km : bool Choose the data version to use. The default is ``False``, which is diff --git a/pygmt/datasets/earth_relief.py b/pygmt/datasets/earth_relief.py index 7a2ea6c3115..af12d59a301 100644 --- a/pygmt/datasets/earth_relief.py +++ b/pygmt/datasets/earth_relief.py @@ -58,7 +58,7 @@ def load_earth_relief( registration : str Grid registration type. Either ``"pixel"`` for pixel registration or ``"gridline"`` for gridline registration. Default is ``"gridline"`` - when available. + for all resolutions except ``"15s"`` which is ``"pixel"`` only. data_source : str Select the source for the Earth relief data. diff --git a/pygmt/datasets/earth_vertical_gravity_gradient.py b/pygmt/datasets/earth_vertical_gravity_gradient.py index 62b9dd2c802..fde1e82ccaa 100644 --- a/pygmt/datasets/earth_vertical_gravity_gradient.py +++ b/pygmt/datasets/earth_vertical_gravity_gradient.py @@ -46,8 +46,7 @@ def load_earth_vertical_gravity_gradient( registration : str Grid registration type. Either ``"pixel"`` for pixel registration or ``"gridline"`` for gridline registration. Default is ``"gridline"`` - when available. - + for all resolutions except ``"01m"`` which is ``"pixel"`` only. Returns ------- From 60c1eee8a9a47c83bab600b6b905b198e657bcc3 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Wed, 28 Dec 2022 09:20:53 -0500 Subject: [PATCH 31/40] remove 05m mag4km test --- pygmt/helpers/testing.py | 1 - .../test_datasets_earth_magnetic_anomaly.py | 19 ------------------- 2 files changed, 20 deletions(-) diff --git a/pygmt/helpers/testing.py b/pygmt/helpers/testing.py index 3c078f36a35..01395c86093 100644 --- a/pygmt/helpers/testing.py +++ b/pygmt/helpers/testing.py @@ -189,7 +189,6 @@ def download_test_data(): "@earth_mag_01d_g", "@S30W060.earth_mag_02m_p.nc", # Specific grid for 02m test "@earth_mag4km_01d_g", - "@S90W180.earth_mag4km_05m_g.nc", # Specific grid for 05m test # Earth free-air anomaly grids "@earth_faa_01d_g", "@N00W030.earth_faa_01m_p.nc", # Specific grid for 01m test diff --git a/pygmt/tests/test_datasets_earth_magnetic_anomaly.py b/pygmt/tests/test_datasets_earth_magnetic_anomaly.py index 7603eba3ce4..fc01cbace7d 100644 --- a/pygmt/tests/test_datasets_earth_magnetic_anomaly.py +++ b/pygmt/tests/test_datasets_earth_magnetic_anomaly.py @@ -112,25 +112,6 @@ def test_earth_mag4km_01d_with_region(): npt.assert_allclose(data.max(), 113.59985) -def test_earth_mag4km_05m_with_region(): - """ - Test loading a subregion of high-resolution earth magnetic anomaly 4km - data. - """ - data = load_earth_magnetic_anomaly( - resolution="05m", - region=[-115, -112, 4, 6], - registration="gridline", - mag4km=True, - ) - assert data.shape == (25, 37) - assert data.lat.min() == 4 - assert data.lat.max() == 6 - assert data.lon.min() == -115 - assert data.lon.max() == -112 - npt.assert_allclose(data.min(), -128.40015) - npt.assert_allclose(data.max(), 76.80005) - def test_earth_mag_02m_default_registration(): """ From 224bbcfb6884eeafadfcd117d88bb2a780f11b69 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Wed, 28 Dec 2022 09:21:40 -0500 Subject: [PATCH 32/40] change 05m to 01m resolution in test_datasets_earth_magnetic_anomaly.py --- pygmt/tests/test_datasets_earth_magnetic_anomaly.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pygmt/tests/test_datasets_earth_magnetic_anomaly.py b/pygmt/tests/test_datasets_earth_magnetic_anomaly.py index fc01cbace7d..e17feb003a5 100644 --- a/pygmt/tests/test_datasets_earth_magnetic_anomaly.py +++ b/pygmt/tests/test_datasets_earth_magnetic_anomaly.py @@ -57,13 +57,13 @@ def test_earth_mag_01d_with_region(): npt.assert_allclose(data.max(), 127.39996) -def test_earth_mag_05m_without_region(): +def test_earth_mag_01m_without_region(): """ Test loading high-resolution earth magnetic anomaly without passing 'region'. """ with pytest.raises(GMTInvalidInput): - load_earth_magnetic_anomaly("05m") + load_earth_magnetic_anomaly("01m") def test_earth_mag_incorrect_resolution_registration(): From c624d437836083ee0861aaa08a8f7f4194dd8eb1 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Wed, 28 Dec 2022 09:22:26 -0500 Subject: [PATCH 33/40] change 05m to 01m resolution in test_datasets_earth_age.py --- pygmt/tests/test_datasets_earth_age.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pygmt/tests/test_datasets_earth_age.py b/pygmt/tests/test_datasets_earth_age.py index 16b7784e4f6..930888b025c 100644 --- a/pygmt/tests/test_datasets_earth_age.py +++ b/pygmt/tests/test_datasets_earth_age.py @@ -59,12 +59,12 @@ def test_earth_age_01d_with_region(): npt.assert_allclose(data.max(), 125.1189) -def test_earth_age_05m_without_region(): +def test_earth_age_01m_without_region(): """ Test loading high-resolution earth age without passing 'region'. """ with pytest.raises(GMTInvalidInput): - load_earth_age("05m") + load_earth_age("01m") def test_earth_age_incorrect_resolution_registration(): From cad77964c86d90e5d9aa789138453a53fd5023f6 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Wed, 28 Dec 2022 09:23:36 -0500 Subject: [PATCH 34/40] change 05m to 01m resolution in test_datasets_earth_free_air_anomaly.py --- pygmt/tests/test_datasets_earth_free_air_anomaly.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pygmt/tests/test_datasets_earth_free_air_anomaly.py b/pygmt/tests/test_datasets_earth_free_air_anomaly.py index c9f3a782f19..ea65a0e83a8 100644 --- a/pygmt/tests/test_datasets_earth_free_air_anomaly.py +++ b/pygmt/tests/test_datasets_earth_free_air_anomaly.py @@ -57,13 +57,13 @@ def test_earth_faa_01d_with_region(): npt.assert_allclose(data.max(), 69.524994) -def test_earth_faa_05m_without_region(): +def test_earth_faa_01m_without_region(): """ Test loading high-resolution earth free air anomaly without passing 'region'. """ with pytest.raises(GMTInvalidInput): - load_earth_free_air_anomaly("05m") + load_earth_free_air_anomaly("01m") def test_earth_faa_01m_default_registration(): From 706c5bcd5bb3096af4ad07741dd1e4213a05d90f Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Wed, 28 Dec 2022 09:24:54 -0500 Subject: [PATCH 35/40] change 05m to 01m resolution in test_datasets_earth_geoid.py --- pygmt/tests/test_datasets_earth_geoid.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pygmt/tests/test_datasets_earth_geoid.py b/pygmt/tests/test_datasets_earth_geoid.py index f530987082d..639178c0ddc 100644 --- a/pygmt/tests/test_datasets_earth_geoid.py +++ b/pygmt/tests/test_datasets_earth_geoid.py @@ -57,12 +57,12 @@ def test_earth_geoid_01d_with_region(): npt.assert_allclose(data.max(), 29.89) -def test_earth_geoid_05m_without_region(): +def test_earth_geoid_01m_without_region(): """ Test loading high-resolution earth geoid without passing 'region'. """ with pytest.raises(GMTInvalidInput): - load_earth_geoid("05m") + load_earth_geoid("01m") def test_earth_geoid_incorrect_resolution_registration(): From 9cb34ecfb815c856e5daa2a741ba6f4e406dce69 Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Wed, 28 Dec 2022 09:25:37 -0500 Subject: [PATCH 36/40] change 05m to 01m resolution in test_datasets_earth_relief.py --- pygmt/tests/test_datasets_earth_relief.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pygmt/tests/test_datasets_earth_relief.py b/pygmt/tests/test_datasets_earth_relief.py index 1d4d06ef44b..22baff35fbf 100644 --- a/pygmt/tests/test_datasets_earth_relief.py +++ b/pygmt/tests/test_datasets_earth_relief.py @@ -136,12 +136,12 @@ def test_earth_relief_30s_synbath(): npt.assert_allclose(data.max(), -2154) -def test_earth_relief_05m_without_region(): +def test_earth_relief_01m_without_region(): """ Test loading high-resolution earth relief without passing 'region'. """ with pytest.raises(GMTInvalidInput): - load_earth_relief("05m") + load_earth_relief("01m") def test_earth_relief_03s_landonly_srtm(): From 6235babe80928120c1d639022ec6b0b715b98e0d Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Wed, 28 Dec 2022 09:25:55 -0500 Subject: [PATCH 37/40] change 05m to 01m resolution in test_datasets_earth_vertical_gravity_gradient.py --- pygmt/tests/test_datasets_earth_vertical_gravity_gradient.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pygmt/tests/test_datasets_earth_vertical_gravity_gradient.py b/pygmt/tests/test_datasets_earth_vertical_gravity_gradient.py index ee2864e2857..44ef9f71885 100644 --- a/pygmt/tests/test_datasets_earth_vertical_gravity_gradient.py +++ b/pygmt/tests/test_datasets_earth_vertical_gravity_gradient.py @@ -62,12 +62,12 @@ def test_earth_vertical_gravity_gradient_01d_with_region(): npt.assert_allclose(data.max(), 19.78125) -def test_earth_vertical_gravity_gradient_05m_without_region(): +def test_earth_vertical_gravity_gradient_01m_without_region(): """ Test loading high-resolution earth vgg without passing 'region'. """ with pytest.raises(GMTInvalidInput): - load_earth_vertical_gravity_gradient("05m") + load_earth_vertical_gravity_gradient("01m") def test_earth_vertical_gravity_gradient_incorrect_resolution_registration(): From f8553d57ceb5a50ba85f0f6b763d3e61022e47ec Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Wed, 28 Dec 2022 09:42:51 -0500 Subject: [PATCH 38/40] Apply suggestions from code review Co-authored-by: Dongdong Tian --- pygmt/tests/test_datasets_earth_magnetic_anomaly.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pygmt/tests/test_datasets_earth_magnetic_anomaly.py b/pygmt/tests/test_datasets_earth_magnetic_anomaly.py index e17feb003a5..c1bffddab5e 100644 --- a/pygmt/tests/test_datasets_earth_magnetic_anomaly.py +++ b/pygmt/tests/test_datasets_earth_magnetic_anomaly.py @@ -57,13 +57,13 @@ def test_earth_mag_01d_with_region(): npt.assert_allclose(data.max(), 127.39996) -def test_earth_mag_01m_without_region(): +def test_earth_mag_02m_without_region(): """ Test loading high-resolution earth magnetic anomaly without passing 'region'. """ with pytest.raises(GMTInvalidInput): - load_earth_magnetic_anomaly("01m") + load_earth_magnetic_anomaly("02m") def test_earth_mag_incorrect_resolution_registration(): From a2e508d1762fac88b7dddf33acdb7c97d98895ca Mon Sep 17 00:00:00 2001 From: Will Schlitzer Date: Wed, 28 Dec 2022 09:46:04 -0500 Subject: [PATCH 39/40] run make format --- pygmt/tests/test_datasets_earth_magnetic_anomaly.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pygmt/tests/test_datasets_earth_magnetic_anomaly.py b/pygmt/tests/test_datasets_earth_magnetic_anomaly.py index c1bffddab5e..d93ba82c0f1 100644 --- a/pygmt/tests/test_datasets_earth_magnetic_anomaly.py +++ b/pygmt/tests/test_datasets_earth_magnetic_anomaly.py @@ -112,7 +112,6 @@ def test_earth_mag4km_01d_with_region(): npt.assert_allclose(data.max(), 113.59985) - def test_earth_mag_02m_default_registration(): """ Test that the grid returned by default for the 2 arc-minute resolution has From cedfa26efebc8792c488f81883f62bcc9741e4ce Mon Sep 17 00:00:00 2001 From: Dongdong Tian Date: Wed, 28 Dec 2022 22:55:44 +0800 Subject: [PATCH 40/40] Always check if gridline is the default registration for 01d resolution --- pygmt/tests/test_datasets_earth_age.py | 4 +--- pygmt/tests/test_datasets_earth_free_air_anomaly.py | 8 ++++---- pygmt/tests/test_datasets_earth_geoid.py | 8 ++++---- pygmt/tests/test_datasets_earth_magnetic_anomaly.py | 13 ++++++------- pygmt/tests/test_datasets_earth_relief.py | 12 ++++++------ ...test_datasets_earth_vertical_gravity_gradient.py | 8 ++++---- 6 files changed, 25 insertions(+), 28 deletions(-) diff --git a/pygmt/tests/test_datasets_earth_age.py b/pygmt/tests/test_datasets_earth_age.py index 930888b025c..b14c74352ca 100644 --- a/pygmt/tests/test_datasets_earth_age.py +++ b/pygmt/tests/test_datasets_earth_age.py @@ -48,9 +48,7 @@ def test_earth_age_01d_with_region(): """ Test loading low-resolution earth age with 'region'. """ - data = load_earth_age( - resolution="01d", region=[-10, 10, -5, 5], registration="gridline" - ) + data = load_earth_age(resolution="01d", region=[-10, 10, -5, 5]) assert data.shape == (11, 21) assert data.gmt.registration == 0 npt.assert_allclose(data.lat, np.arange(-5, 6, 1)) diff --git a/pygmt/tests/test_datasets_earth_free_air_anomaly.py b/pygmt/tests/test_datasets_earth_free_air_anomaly.py index ea65a0e83a8..f9164ac2e50 100644 --- a/pygmt/tests/test_datasets_earth_free_air_anomaly.py +++ b/pygmt/tests/test_datasets_earth_free_air_anomaly.py @@ -31,12 +31,13 @@ def test_earth_faa_01d(): """ Test some properties of the free air anomaly 01d data. """ - data = load_earth_free_air_anomaly(resolution="01d", registration="gridline") + data = load_earth_free_air_anomaly(resolution="01d") assert data.name == "free_air_anomaly" assert data.attrs["long_name"] == "IGPP Global Earth Free-Air Anomaly" assert data.attrs["units"] == "mGal" assert data.attrs["horizontal_datum"] == "WGS84" assert data.shape == (181, 361) + assert data.gmt.registration == 0 npt.assert_allclose(data.lat, np.arange(-90, 91, 1)) npt.assert_allclose(data.lon, np.arange(-180, 181, 1)) npt.assert_allclose(data.min(), -275.75) @@ -47,10 +48,9 @@ def test_earth_faa_01d_with_region(): """ Test loading low-resolution earth free air anomaly with 'region'. """ - data = load_earth_free_air_anomaly( - resolution="01d", region=[-10, 10, -5, 5], registration="gridline" - ) + data = load_earth_free_air_anomaly(resolution="01d", region=[-10, 10, -5, 5]) assert data.shape == (11, 21) + assert data.gmt.registration == 0 npt.assert_allclose(data.lat, np.arange(-5, 6, 1)) npt.assert_allclose(data.lon, np.arange(-10, 11, 1)) npt.assert_allclose(data.min(), -58.75) diff --git a/pygmt/tests/test_datasets_earth_geoid.py b/pygmt/tests/test_datasets_earth_geoid.py index 639178c0ddc..2fdfcee2057 100644 --- a/pygmt/tests/test_datasets_earth_geoid.py +++ b/pygmt/tests/test_datasets_earth_geoid.py @@ -31,12 +31,13 @@ def test_earth_geoid_01d(): """ Test some properties of the earth geoid 01d data. """ - data = load_earth_geoid(resolution="01d", registration="gridline") + data = load_earth_geoid(resolution="01d") assert data.name == "earth_geoid" assert data.attrs["units"] == "m" assert data.attrs["long_name"] == "EGM2008 Global Earth Geoid" assert data.attrs["horizontal_datum"] == "WGS84" assert data.shape == (181, 361) + assert data.gmt.registration == 0 npt.assert_allclose(data.lat, np.arange(-90, 91, 1)) npt.assert_allclose(data.lon, np.arange(-180, 181, 1)) npt.assert_allclose(data.min(), -106.45) @@ -47,10 +48,9 @@ def test_earth_geoid_01d_with_region(): """ Test loading low-resolution earth geoid with 'region'. """ - data = load_earth_geoid( - resolution="01d", region=[-10, 10, -5, 5], registration="gridline" - ) + data = load_earth_geoid(resolution="01d", region=[-10, 10, -5, 5]) assert data.shape == (11, 21) + assert data.gmt.registration == 0 npt.assert_allclose(data.lat, np.arange(-5, 6, 1)) npt.assert_allclose(data.lon, np.arange(-10, 11, 1)) npt.assert_allclose(data.min(), 4.87) diff --git a/pygmt/tests/test_datasets_earth_magnetic_anomaly.py b/pygmt/tests/test_datasets_earth_magnetic_anomaly.py index d93ba82c0f1..3ba87eaa209 100644 --- a/pygmt/tests/test_datasets_earth_magnetic_anomaly.py +++ b/pygmt/tests/test_datasets_earth_magnetic_anomaly.py @@ -31,12 +31,13 @@ def test_earth_mag_01d(): """ Test some properties of the magnetic anomaly 01d data. """ - data = load_earth_magnetic_anomaly(resolution="01d", registration="gridline") + data = load_earth_magnetic_anomaly(resolution="01d") assert data.name == "magnetic_anomaly" assert data.attrs["long_name"] == "Earth magnetic anomaly" assert data.attrs["units"] == "nT" assert data.attrs["horizontal_datum"] == "WGS84" assert data.shape == (181, 361) + assert data.gmt.registration == 0 npt.assert_allclose(data.lat, np.arange(-90, 91, 1)) npt.assert_allclose(data.lon, np.arange(-180, 181, 1)) npt.assert_allclose(data.min(), -384) @@ -47,10 +48,9 @@ def test_earth_mag_01d_with_region(): """ Test loading low-resolution earth magnetic anomaly with 'region'. """ - data = load_earth_magnetic_anomaly( - resolution="01d", region=[-10, 10, -5, 5], registration="gridline" - ) + data = load_earth_magnetic_anomaly(resolution="01d", region=[-10, 10, -5, 5]) assert data.shape == (11, 21) + assert data.gmt.registration == 0 npt.assert_allclose(data.lat, np.arange(-5, 6, 1)) npt.assert_allclose(data.lon, np.arange(-10, 11, 1)) npt.assert_allclose(data.min(), -180.40002) @@ -81,14 +81,13 @@ def test_earth_mag4km_01d(): """ Test some properties of the magnetic anomaly 4km 01d data. """ - data = load_earth_magnetic_anomaly( - resolution="01d", registration="gridline", mag4km=True - ) + data = load_earth_magnetic_anomaly(resolution="01d", mag4km=True) assert data.name == "magnetic_anomaly" assert data.attrs["long_name"] == "Earth magnetic anomaly" assert data.attrs["units"] == "nT" assert data.attrs["horizontal_datum"] == "WGS84" assert data.shape == (181, 361) + assert data.gmt.registration == 0 npt.assert_allclose(data.lat, np.arange(-90, 91, 1)) npt.assert_allclose(data.lon, np.arange(-180, 181, 1)) npt.assert_allclose(data.min(), -799.19995) diff --git a/pygmt/tests/test_datasets_earth_relief.py b/pygmt/tests/test_datasets_earth_relief.py index 22baff35fbf..e8b176f491b 100644 --- a/pygmt/tests/test_datasets_earth_relief.py +++ b/pygmt/tests/test_datasets_earth_relief.py @@ -47,10 +47,9 @@ def test_earth_relief_01d_gebco(data_source): Test some properties of the earth relief 01d data with GEBCO and GEBOCSI data. """ - data = load_earth_relief( - resolution="01d", registration="gridline", data_source=data_source - ) + data = load_earth_relief(resolution="01d", data_source=data_source) assert data.shape == (181, 361) + assert data.gmt.registration == 0 npt.assert_allclose(data.lat, np.arange(-90, 91, 1)) npt.assert_allclose(data.lon, np.arange(-180, 181, 1)) npt.assert_allclose(data.min(), -8598) @@ -64,10 +63,10 @@ def test_earth_relief_01d_with_region_srtm(): data = load_earth_relief( resolution="01d", region=[-10, 10, -5, 5], - registration="gridline", data_source="igpp", ) assert data.shape == (11, 21) + assert data.gmt.registration == 0 npt.assert_allclose(data.lat, np.arange(-5, 6, 1)) npt.assert_allclose(data.lon, np.arange(-10, 11, 1)) npt.assert_allclose(data.min(), -5154) @@ -81,10 +80,10 @@ def test_earth_relief_01d_with_region_gebco(): data = load_earth_relief( resolution="01d", region=[-10, 10, -5, 5], - registration="gridline", data_source="gebco", ) assert data.shape == (11, 21) + assert data.gmt.registration == 0 npt.assert_allclose(data.lat, np.arange(-5, 6, 1)) npt.assert_allclose(data.lon, np.arange(-10, 11, 1)) npt.assert_allclose(data.min(), -5146) @@ -95,8 +94,9 @@ def test_earth_relief_30m(): """ Test some properties of the earth relief 30m data. """ - data = load_earth_relief(resolution="30m", registration="gridline") + data = load_earth_relief(resolution="30m") assert data.shape == (361, 721) + assert data.gmt.registration == 0 npt.assert_allclose(data.lat, np.arange(-90, 90.5, 0.5)) npt.assert_allclose(data.lon, np.arange(-180, 180.5, 0.5)) npt.assert_allclose(data.min(), -9454.5) diff --git a/pygmt/tests/test_datasets_earth_vertical_gravity_gradient.py b/pygmt/tests/test_datasets_earth_vertical_gravity_gradient.py index 44ef9f71885..e9307d3742d 100644 --- a/pygmt/tests/test_datasets_earth_vertical_gravity_gradient.py +++ b/pygmt/tests/test_datasets_earth_vertical_gravity_gradient.py @@ -33,14 +33,13 @@ def test_earth_vertical_gravity_gradient_01d(): """ Test some properties of the earth vgg 01d data. """ - data = load_earth_vertical_gravity_gradient( - resolution="01d", registration="gridline" - ) + data = load_earth_vertical_gravity_gradient(resolution="01d") assert data.name == "earth_vgg" assert data.attrs["units"] == "Eotvos" assert data.attrs["long_name"] == "IGPP Global Earth Vertical Gravity Gradient" assert data.attrs["horizontal_datum"] == "WGS84" assert data.shape == (181, 361) + assert data.gmt.registration == 0 npt.assert_allclose(data.lat, np.arange(-90, 91, 1)) npt.assert_allclose(data.lon, np.arange(-180, 181, 1)) npt.assert_allclose(data.min(), -136.34375) @@ -53,9 +52,10 @@ def test_earth_vertical_gravity_gradient_01d_with_region(): Test loading low-resolution earth vgg with 'region'. """ data = load_earth_vertical_gravity_gradient( - resolution="01d", region=[-10, 10, -5, 5], registration="gridline" + resolution="01d", region=[-10, 10, -5, 5] ) assert data.shape == (11, 21) + assert data.gmt.registration == 0 npt.assert_allclose(data.lat, np.arange(-5, 6, 1)) npt.assert_allclose(data.lon, np.arange(-10, 11, 1)) npt.assert_allclose(data.min(), -16.34375)