Skip to content

Deprecate pygmt.io.load_dataarray, use xarray.load_dataarray instead #3922

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

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

weiji14
Copy link
Member

@weiji14 weiji14 commented Apr 19, 2025

Description of proposed changes

Deprecate usage of pygmt.io.load_dataarray for loading NetCDF and other grids, use xr.load_dataarray(..., engine="gmt") instead.

TODO:

  • Add FutureWarning
  • Update load_dataarray to xr.load_dataarray(..., engine="gmt", raster_kind="grid") internally
  • Move benchmark on test_io_load_dataarray to somewhere else
  • etc

Cherry-picked from #3919

Preview:

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.

Slash Commands

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

  • /format: automatically format and lint the code

Deprecate usage of `pygmt.io.load_dataarray` for loading NetCDF and other grids, use `xr.load_dataarray(..., engine="gmt")` instead.
@weiji14 weiji14 added the deprecation Deprecating a feature label Apr 19, 2025
@weiji14 weiji14 self-assigned this Apr 19, 2025
Specifically with arguments (..., engine="gmt", decode_kind="grid").
weiji14 added a commit that referenced this pull request Apr 19, 2025
@seisman
Copy link
Member

seisman commented Apr 20, 2025

Perhaps we should also replace xr.open_dataarray with xr.load_dataarray in the tests?

@seisman seisman mentioned this pull request Apr 26, 2025
3 tasks
@seisman seisman added this to the 0.16.0 milestone Apr 26, 2025
@weiji14
Copy link
Member Author

weiji14 commented Apr 27, 2025

Perhaps we should also replace xr.open_dataarray with xr.load_dataarray in the tests?

I see you're doing some of that in #3643 already. Do you want to do it there, or in this PR?

@weiji14 weiji14 added the run/benchmark Trigger the benchmark workflow in PRs label Apr 27, 2025
Copy link

codspeed-hq bot commented Apr 27, 2025

CodSpeed Performance Report

Merging #3922 will degrade performances by 85.18%

Comparing deprecate/load_dataarray (898f349) with main (f389e05)

Summary

❌ 2 regressions
✅ 102 untouched benchmarks
🆕 1 new benchmarks
⁉️ 1 dropped benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Benchmarks breakdown

Benchmark BASE HEAD Change
test_put_matrix_grid 69 ms 465.9 ms -85.18%
test_earth_relief_holes 39.2 ms 66 ms -40.6%
⁉️ test_io_load_dataarray 23.9 ms N/A N/A
🆕 test_xarray_backend_load_dataarray N/A 64.7 ms N/A

@seisman
Copy link
Member

seisman commented Apr 28, 2025

Perhaps we should also replace xr.open_dataarray with xr.load_dataarray in the tests?

I see you're doing some of that in #3643 already. Do you want to do it there, or in this PR?

Please do it in this PR.

@weiji14 weiji14 marked this pull request as ready for review April 29, 2025 02:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deprecation Deprecating a feature run/benchmark Trigger the benchmark workflow in PRs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants