Skip to content

pygmt.grdmask: Create mask grid from polygons or point coverage(required arguments)#4428

Open
Chuan1937 wants to merge 50 commits intoGenericMappingTools:mainfrom
Chuan1937:grdmask1
Open

pygmt.grdmask: Create mask grid from polygons or point coverage(required arguments)#4428
Chuan1937 wants to merge 50 commits intoGenericMappingTools:mainfrom
Chuan1937:grdmask1

Conversation

@Chuan1937
Copy link
Member

@Chuan1937 Chuan1937 commented Feb 25, 2026

pygmt.grdmask: Create mask grid from polygons or point coverage(required arguments)

Preview: https://pygmt-dev--4428.org.readthedocs.build/en/4428/api/generated/pygmt.grdmask.html#pygmt.grdmask

@Chuan1937 Chuan1937 changed the title pygmt.grdmask: Create mask grid from polygons or point coverage pygmt.grdmask: Create mask grid from polygons or point coverage(required arguments) Feb 25, 2026
@Chuan1937 Chuan1937 self-assigned this Feb 25, 2026
Chuan1937 and others added 3 commits February 25, 2026 22:01
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Chuan1937 and others added 2 commits February 25, 2026 22:21
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
@Chuan1937 Chuan1937 requested a review from seisman February 26, 2026 05:40
@Chuan1937 Chuan1937 requested a review from seisman March 2, 2026 03:29
Chuan1937 and others added 4 commits March 2, 2026 17:53
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Chuan1937 and others added 3 commits March 3, 2026 10:16
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
@Chuan1937 Chuan1937 requested a review from seisman March 3, 2026 02:27
Chuan1937 and others added 4 commits March 4, 2026 15:14
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Chuan1937 and others added 8 commits March 6, 2026 10:08
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Chuan1937 and others added 4 commits March 6, 2026 10:58
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>

Examples
--------
>>> _alias_option_N()._value
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if users pass outside=1 only?

Copy link
Member Author

@Chuan1937 Chuan1937 Mar 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

outside=1 alone would generate -N1/None/None which passes invalid None strings to GMT. Fixed by returning None when inside is not set, so GMT uses its default values.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think your changes don't make sense. outside=3 should return -N3/0/1 rather than None.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added a more comprehensive test

@Chuan1937 Chuan1937 requested a review from seisman March 12, 2026 14:16
Comment on lines +98 to +101
Reads one or more files containing polygon or data point
coordinates, and creates a grid where nodes that fall inside, on the
edge, or outside the polygons (or within the search radius from data points) are
assigned values based on ``outside``, ``edge``, and ``inside`` parameters.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rewrap these lines to 88 characters.

Comment on lines +69 to +71
elif inside is None and outside is None and edge is None:
# All three are None, return None (GMT uses default 0/0/1)
mask_values = None
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change it to something like

if all(v is None for v in (outside, inside, edge)):
    return Alias(None, name="mask_values")

and move it to the start of the function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature Brand new feature needs review This PR has higher priority and needs review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants