-
Notifications
You must be signed in to change notification settings - Fork 245
Set gridline (if available) as the default grid registration for remote datasets #2266
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 30 commits
39203d5
dd1b685
dcb09b5
5d649e6
ead76a0
24b8931
bdfc550
7b0a219
2fefe64
3442893
d36f53d
24b3e73
2a64cf5
eaa57ae
040883e
79ca10e
664d7da
c7fa8f5
7ec384d
1fadc26
6f306fd
e24bcbc
087e6a9
75519f7
f668947
78fc8c1
ae6176d
3714ccc
9bfb317
bea25d5
05f79a1
8b09c33
6a984e5
60c1eee
224bbcf
c624d43
cad7796
706c5bc
9cb34ec
6235bab
f3fc043
f8553d5
a2e508d
cedfa26
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -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. | ||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What about rewording it explicitly to something like this?
Suggested change
willschlitzer marked this conversation as resolved.
Outdated
|
||||||||||
|
|
||||||||||
| Returns | ||||||||||
| ------- | ||||||||||
|
|
||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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,29 +52,13 @@ 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) | ||
| 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(): | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please also update Please also make the similar changes in other tests. |
||
| """ | ||
| Test loading high-resolution earth age without passing 'region'. | ||
|
|
@@ -89,3 +74,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) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
|
|
@@ -146,3 +130,19 @@ def test_earth_mag4km_05m_with_region(): | |
| assert data.lon.max() == -112 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| 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) | ||
Uh oh!
There was an error while loading. Please reload this page.