Skip to content
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

Set gridline (if available) as the default grid registration for remote datasets #2266

Merged
merged 44 commits into from
Dec 28, 2022

Conversation

willschlitzer
Copy link
Contributor

This sets the default registration to "gridline" if both registration options are available.

Fixes #1929

Reminders

  • Run make format and make check to make sure the code follows the style guide.
  • Add tests for new features or tests that would have caught the bug that you're fixing.
  • Add new public functions/methods/classes to doc/api/index.rst.
  • Write detailed docstrings for all functions/methods.
  • If wrapping a new module, open a 'Wrap new GMT module' issue and submit reasonably-sized PRs.
  • If adding new functionality, add an example to docstrings or tutorials.
  • Use underscores (not hyphens) in names of Python files and directories.

Slash Commands

You can write slash commands (/command) in the first line of a comment to perform
specific operations. Supported slash commands are:

  • /format: automatically format and lint the code
  • /test-gmt-dev: run full tests on the latest GMT development version

@willschlitzer willschlitzer added this to the 0.8.0 milestone Dec 22, 2022
@willschlitzer willschlitzer self-assigned this Dec 22, 2022
Comment on lines 216 to 217
if registration is None:
registration = dataset.resolutions[resolution].registrations[0]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed my mind and now I think your solution in #1929 (comment) is better, because it's more clear that "gridline" is the default registration.

In either case, I also think we should put gridline before pixel, because letter g is in front of letter p and gridline and pixel are internally represented as 0 and 1 in GMT.

Copy link
Contributor Author

@willschlitzer willschlitzer Dec 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay. I will be back on December 26 and can update the PR then.

Copy link
Member

@seisman seisman Dec 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In either case, I also think we should put gridline before pixel, because letter g is in front of letter p and gridline and pixel are internally represented as 0 and 1 in GMT.

I feel these changes should be done in a separate PR so that this PR is smaller and easier to review.

Edit: Done in #2276.

@yvonnefroehlich yvonnefroehlich mentioned this pull request Dec 22, 2022
65 tasks
@willschlitzer
Copy link
Contributor Author

willschlitzer commented Dec 25, 2022

Should I add tests using high-resolution grids to test that the functions default to the appropriate registrations when only one is available?

@seisman
Copy link
Member

seisman commented Dec 25, 2022

Should I add tests using high-resolution grids to test that the functions default to the appropriate registrations when only one is available?

Yes, please. The earth_relief_15s grid is good for testing.

pygmt/datasets/load_remote_dataset.py Outdated Show resolved Hide resolved
pygmt/datasets/load_remote_dataset.py Outdated Show resolved Hide resolved
pygmt/datasets/load_remote_dataset.py Outdated Show resolved Hide resolved
Copy link
Member

@weiji14 weiji14 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer explicit documentation on what resolutions default to gridline and which are pixel only. Feel free to change the wording if needed.

pygmt/datasets/earth_age.py Outdated Show resolved Hide resolved
Comment on lines 47 to 48
``"gridline"`` for gridline registration. Default is ``"gridline"``
when available.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about rewording it explicitly to something like this?

Suggested change
``"gridline"`` for gridline registration. Default is ``"gridline"``
when available.
``"gridline"`` for gridline registration. Default is ``"gridline"``
for all resolutions except ``"01m"`` which is ``"pixel"`` only.

pygmt/datasets/earth_free_air_anomaly.py Outdated Show resolved Hide resolved
pygmt/datasets/earth_geoid.py Outdated Show resolved Hide resolved
pygmt/datasets/earth_magnetic_anomaly.py Outdated Show resolved Hide resolved
pygmt/datasets/earth_relief.py Outdated Show resolved Hide resolved
pygmt/datasets/earth_vertical_gravity_gradient.py Outdated Show resolved Hide resolved
assert data.sizes["lat"] == 121
assert data.sizes["lon"] == 121


def test_earth_age_05m_without_region():
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also update test_earth_age_05m_without_region to use the 01m resolution, so that we consistently use 01d and 01m in the tests.

Please also make the similar changes in other tests.

@@ -146,3 +130,19 @@ def test_earth_mag4km_05m_with_region():
assert data.lon.max() == -112
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test_earth_mag4km_05m_with_region(): is still using the 05m grid.

@willschlitzer
Copy link
Contributor Author

@seisman and @weiji14 Please feel free to commit any minor changes you suggest to this PR and #2241. I'm going to be away from my computer for a good portion of today, and don't want to hold up @yvonnefroehlich over something minor.

@seisman seisman changed the title Set default grid registration for remote datasets Set gridline (if available) as the default grid registration for remote datasets Dec 28, 2022
@seisman
Copy link
Member

seisman commented Dec 28, 2022

@seisman and @weiji14 Please feel free to commit any minor changes you suggest to this PR and #2241. I'm going to be away from my computer for a good portion of today, and don't want to hold up @yvonnefroehlich over something minor.

I've made the commit cedfa26 to make sure the 01d resolution always returns gridline-registered grids.

@seisman seisman added final review call This PR requires final review and approval from a second reviewer and removed needs review This PR has higher priority and needs review. labels Dec 28, 2022
@seisman seisman merged commit c833f88 into main Dec 28, 2022
@seisman seisman deleted the load-remote-dataset/set-default-registration branch December 28, 2022 15:17
@seisman seisman removed the final review call This PR requires final review and approval from a second reviewer label Dec 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improving an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

load_earth_relief now returns grid-registrated grids when registration is not specified
3 participants