WIP: Add gallery example OR tutorial showing the usage of pygmt.grdmask#4525
Draft
yvonnefroehlich wants to merge 26 commits into
Draft
WIP: Add gallery example OR tutorial showing the usage of pygmt.grdmask#4525yvonnefroehlich wants to merge 26 commits into
yvonnefroehlich wants to merge 26 commits into
Conversation
This reverts commit 5173eff.
seisman
reviewed
Jun 21, 2026
| region = [125, 135, 25, 36] | ||
|
|
||
| # Define two closed polygons, here a square and a triangle. | ||
| # Use an np.nan to separate the polygons |
Member
There was a problem hiding this comment.
Suggested change
| # Use an np.nan to separate the polygons | |
| # Use a record with np.nan to separate the polygons |
Comment on lines
+48
to
+55
| # Create a grid mask based on the two polygons defined above | ||
| # Set all grid nodes outside the polygons to NaN | ||
| mask_out = pygmt.grdmask(region=region, data=polygon, spacing="30s", outside="NaN") | ||
| # Set all grid nodes inside the polygons to NaN | ||
| # Set the outside parameter to a value larger 0 to keep the nodes outside unchanged | ||
| mask_in = pygmt.grdmask( | ||
| region=region, data=polygon, spacing="30s", inside="NaN", outside=1 | ||
| ) |
Member
There was a problem hiding this comment.
Perhaps we should explain the default values for inside/outside/edge to better understand the behavior.
| fig.grdimage(grid=grid_mask_in, cmap=True) | ||
| fig.plot(data=polygon, pen="2p,darkorange") | ||
|
|
||
| fig.colorbar(frame=True) |
Member
There was a problem hiding this comment.
What about removing the Figure.colorbar call because it's not the main focus of this example:
Suggested change
| fig.colorbar(frame=True) |
| fig.show() | ||
|
|
||
|
|
||
| # %% |
Member
There was a problem hiding this comment.
A gallery example usually contains only one example, but this one has three examples. Maybe it fits the tutorial section better?
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description of proposed changes
This PR aims to add a gallery example OR a tutorial showing the usage of
pygmt.grdmask.TODO
inside,outside,edgepygmt.grdlandmaskPreview: https://pygmt-dev--4525.org.readthedocs.build/en/4525/gallery/images/grdmask.html
Guidelines
Slash Commands
You can write slash commands (
/command) in the first line of a comment to performspecific operations. Supported slash command is:
/format: automatically format and lint the code