-
Notifications
You must be signed in to change notification settings - Fork 224
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
Wrap nearneighbor #1379
Wrap nearneighbor #1379
Conversation
The implementation mirrors that of the already implemented surface. The documentation has been cobbled together from similar portions in surface and from the [official GMT documentation on nearneighbor](https://docs.generic-mapping-tools.org/latest/nearneighbor.html). Additional long-form flags have been added, reflecting the flags particularly useful for nearneighbor, mainly `-Ssearch_radius`, `-Eempty` and `-Nsectors`. Tests have been blatently copied from those testing surface, since the two functions should operate broadly similarly.
💖 Thanks for opening this pull request! 💖 Please make sure you read our contributing guidelines and abide by our code of conduct. A few things to keep in mind:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @JamieJQuinn, thank you for opening up this PR! I see that you have a parallel implementation over at UCL/pyCascadia#65, so good on you for bringing this into PyGMT. Overall, your implementation is actually solid and works properly. I have listed a few suggested changes below, mostly related to modernization of the code style (the surface
module you based your code on hasn't really been updated since 2019).
If you agree to the changes, feel free to do a "Commit suggestion" directly, or pool several together using "Add suggestion to batch" before committing. See also https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/incorporating-feedback-in-your-pull-request#applying-a-suggested-change.
There are many pieces of older code mirroring those found in the implementation of `surface`. These have since been updating in other parts of pyGMT. Most of the review suggestions modernise this PR. Co-authored-by: Wei Ji <[email protected]>
@weiji14 cheers for the suggestions! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm more or less happy with the implementation here, aside from a couple of tiny things. Would appreciate it if someone from @GenericMappingTools/pygmt-maintainers takes a look too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me (but agree with @weiji14's two suggestions)!
Enhance nearneighbour documentation Co-authored-by: Wei Ji <[email protected]>
Co-authored-by: Wei Ji <[email protected]>
Co-authored-by: Wei Ji <[email protected]>
Co-authored-by: Wei Ji <[email protected]>
Co-authored-by: Wei Ji <[email protected]>
Co-Authored-By: Dongdong Tian <[email protected]>
Check that numpy.array and xarray.Dataset inputs work.
Maintainers, please give this a final review (docs preview at https://pygmt-git-fork-jamiejquinn-feature-implement-nearneighbour-gmt.vercel.app/api/generated/pygmt.nearneighbor.html), and if there are no major objections, will merge in ~24 hours 🚀 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me except for two suggestions on docstrings.
Co-Authored-By: Dongdong Tian <[email protected]>
🎉🎉🎉 Congrats on merging your first pull request and welcome to the team! 🎉🎉🎉 Please open a new pull request to add yourself to the |
Thanks again for your contribution @JamieJQuinn 😄 The
This will install the version of PyGMT from TestPyPI at https://test.pypi.org/project/pygmt/0.4.2.dev64. Oh, and you're welcome to send in new feature requests or ideas to our issue tracker at https://github.com/GenericMappingTools/pygmt/issues. Looking forward to seeing you around more! |
@JamieJQuinn Feel free to open up a pull request to add yourself to |
Wrapping the nearneighbor function which grids table data using a "Nearest neighbor" algorithm. Official GMT documentation is at https://docs.generic-mapping-tools.org/6.2/nearneighbor.html. Aliased empty (E), spacing (I), sectors (N), search_radius (S). * Add nearneighbor to API index * Add similar figure to that found in GMTs nearneighbor documentation * Ignore flake8 error using noqa W505 * Shorten line length to under 100 using the dev image * Merge two tests using pytest parametrize Check that numpy.array and xarray.Dataset inputs work. Co-authored-by: Wei Ji <[email protected]> Co-authored-by: Meghan Jones <[email protected]> Co-authored-by: Michael Grund <[email protected]> Co-authored-by: Dongdong Tian <[email protected]>
Description of proposed changes
This PR adds an implementation of
nearneighbor
, mirroring that of the already implementedsurface
.The documentation has been cobbled together from similar portions in
surface and from the official GMT documentation on
nearneighbor.
Additional long-form flags have been added, reflecting the flags
particularly useful for nearneighbor, mainly
-Ssearch_radius
,-Eempty
and-Nsectors
.Tests have been blatantly copied from those testing surface, since the
two functions should operate broadly similarly.
The nearneighbor command is particularly important for remove-restore, an algorithm used to combine different datasets into one grid. In my case, this is implemented in a package I manage, pyCascadia, which is using pyGMT to implement remove-restore for the purposes of combining bathymetry datasets. It would be useful to pyCascadia to have nearneighbor implemented to the same degree as e.g.
surface
.Preview docs at https://pygmt-git-fork-jamiejquinn-feature-implement-nearneighbour-gmt.vercel.app/api/generated/pygmt.nearneighbor.html
Reminders
make format
andmake check
to make sure the code follows the style guide.doc/api/index.rst
.Slash Commands
You can write slash commands (
/command
) in the first line of a comment to performspecific operations. Supported slash commands are:
/format
: automatically format and lint the code/test-gmt-dev
: run full tests on the latest GMT development version