-
Notifications
You must be signed in to change notification settings - Fork 235
pygmt.grdgradient: Add parameters 'normalize'/'norm_ambient'/'norm_amp'/'norm_sigma'/'norm_offset' for normalization #4365
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
base: main
Are you sure you want to change the base?
Conversation
c64f483 to
80afd26
Compare
…p'/'norm_sigma'/'norm_offset' for normalization
80afd26 to
c3d9ee3
Compare
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.
Pull request overview
This PR refactors the grdgradient function to provide a more Pythonic interface for the normalization option (-N in GMT). Instead of requiring users to provide GMT CLI-style strings, the PR introduces dedicated parameters for normalization control.
Changes:
- Adds new parameters
normalize,norm_amp,norm_ambient,norm_sigma, andnorm_offsettopygmt.grdgradientfor more intuitive normalization control - Implements backward compatibility by allowing the old GMT CLI string syntax while preventing mixed usage of old and new syntax
- Updates documentation to explain the new Pythonic parameter interface and mathematical formulas
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| pygmt/src/grdgradient.py | Adds helper function _alias_option_N to handle new normalization parameters and their conversion to GMT CLI format; updates function signature and documentation |
| pygmt/tests/test_grdgradient.py | Adds tests to verify that mixing old GMT syntax with new parameters raises appropriate errors |
| examples/gallery/images/grdgradient_shading.py | Updates example to demonstrate new Pythonic normalization syntax with normalize="cauchy"/"laplace" and norm_amp parameter |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Description of proposed changes
This PR provides a more Pythonic implementation for the -N option.
Preview: https://pygmt-dev--4365.org.readthedocs.build/en/4365/api/generated/pygmt.grdgradient.html
https://pygmt-dev--4365.org.readthedocs.build/en/4365/gallery/images/grdgradient_shading.html