-
Notifications
You must be signed in to change notification settings - Fork 235
pygmt.grdfilter: Add parameters filter/width/highpass to set the filter [Part 1] #4401
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
Draft
seisman
wants to merge
10
commits into
main
Choose a base branch
from
grdfilter/filter-part1
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+152
−21
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
seisman
commented
Feb 10, 2026
pygmt/src/grdfilter.py
Outdated
Comment on lines
55
to
62
| mapping={ | ||
| "boxcar": "b", | ||
| "cosine_arch": "c", | ||
| "gaussian": "g", | ||
| "minall": "l", | ||
| "minpos": "L", | ||
| "maxall": "u", | ||
| "maxneg": "U", |
Member
Author
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.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
enhancement
Improving an existing feature
high-priority
needs review
This PR has higher priority and needs review.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is a subset of PR #4378, aiming to implement a Pythonic interface for the
-Foption of thegrdfiltermodule.The full syntax of the
-Foption is (https://docs.generic-mapping-tools.org/dev/grdfilter.html#f):-Fxwidth[/width2][+c|+h|+l|+qquantile|+u]
GMT supports 12 different types of filters, which can be specified by x. For most filters, the syntax is very simple (e.g.,
-Fg600). Some filters can accept more modifiers. For example,histogramfilter accepts+c/+l/+u;medianfilter accepts+q;Maximum likelihood probabilityfilter accepts+l/+u; and all filters accept+h(for highpass). For custom and operator filters, width is actually a weight file. As a result, this option is complicated to implement.PR #4378 tries to alias the
-Foption to multiple parametersfilter_type/filter_width/highpass/hist_bin_width/median_quantile/hist_center_bins/mode_extreme. As you can see, that PR is already very big and there are still many edge cases to be covered. I feel that PR will take a very long time to finish and will definitely delay the submission of the paper. Instead, I'm opening this PR to implement a subset of the-Foption, which should cover most (80%, I guess) use cases of the-Foption. A more feature-complete version can be added after the paper submission.Previously, the
-Foption is aliased to a single parameterfilter. In this PR, three new parameters are added:filter_type: specify the filter typefilter_width: specify the filter widthhighpass: for the+hmodifierThen, in our paper,
filter="g600"would befilter_type="gaussian", filter_width=600.We still need to discuss the parameter names:
filteris a built-in function in Python, so the old aliasfilteris not a good name.filter_type/filter_widthare good, but the prefixfilter_is not necessary as the method name isgrdfilter(andda.gmt.filterin the GMT accessor). Buttypeis also a built-in function in Python.I feel we have some choices:
filter_type/filter_widthfilter_type/widthfilter/widthtype/widthI'm a little inclined to
filter/width. What do you think @GenericMappingTools/pygmt-maintainers?Edit: I've renamed the parameters to
filter/width.Preview: https://pygmt-dev--4401.org.readthedocs.build/en/4401/api/generated/pygmt.grdfilter.html