Skip to content

A new module: grdselect#5929

Merged
PaulWessel merged 66 commits intomasterfrom
grdselect-module
Nov 17, 2021
Merged

A new module: grdselect#5929
PaulWessel merged 66 commits intomasterfrom
grdselect-module

Conversation

@PaulWessel
Copy link
Member

@PaulWessel PaulWessel commented Oct 31, 2021

Description of proposed changes

The grdselect module fills a gap in GMT capabilities and simplifies a series of workflows that otherwise require considerable scripting. The module operates on a series of grids (or data cubes) and then, depending on options, can

  • Find a subset of the data sources that satisfies various conditions, such as data range, increment size, registration type, overlap with -R, z-range (for cubes only), and number of NaNs. We output the subset of those data sources that passed any of the imposed conditions.
  • For the data sources that passed (or all if no conditions were imposed), determine either the union or the intersection of all the data sources regions. We then report either a single data record with the min/max coordinates (including the data range within the determined region), a -Rw/e/s/n[/b/t] string, or the closed bounding box polygon for the region.

I have added two tests so far. One computes the intersection and union (plus a pad of 2 degrees) of three geographic grids, of which one is off by 360 degrees relative to the others, and another that outputs the list of grids that passed a variety of tests.

Because we are close to 6.3 and this module may well need to add a few more features and/or revise what has been implemented after more discussion, it will remain WIP until after 6.3. Suggestions for additional capability can be added to this PR. Here is the image for the new test, showing in bold the determined regions:

region_u_i

See the man page for more details.

@PaulWessel PaulWessel added the new module PR that implements a new module label Oct 31, 2021
@PaulWessel PaulWessel added this to the Future release milestone Oct 31, 2021
@PaulWessel PaulWessel requested review from a team October 31, 2021 00:22
@PaulWessel PaulWessel self-assigned this Oct 31, 2021
@maxrjones
Copy link
Member

2. Support units in **-W**.  GMT does support a bunch of units in various options but they tend to be limited to geographic or plot distance units.  The **-W** option deals with the data units in grids.  That could be anything, from mGal to meter to whatever.  I am not sure what you had in mind here?

Ugh, sorry typed the wrong letter. I meant -M.

@PaulWessel
Copy link
Member Author

AH, -M. OK, well it currently supports arc units, so -M30m and -M15s/30s works. There is no support to accept distances in km, for instance, if that is what you where thinking?

BTW, I made minor changes to allow for images. Basically exclude -W -N for images.

@maxrjones
Copy link
Member

AH, -M. OK, well it currently supports arc units, so -M30m and -M15s/30s works. There is no support to accept distances in km, for instance, if that is what you where thinking?

It's not so much that I really want to be able to specify (e.g.) 10 km margins, but that I would prefer the description for -M specify what types of units are supported and what the default units are for margins if not given. Thanks for adding some details.

BTW, I made minor changes to allow for images. Basically exclude -W -N for images.

Great, thanks! Regarding images, the specific use case that I considered was selecting all images that have <X% of the pixels matching some criteria based on the data values (commonly used to select images with minimal cloud cover based on a bitmask band). I agree that it's better to get the base functionality merged rather than focus on additional features, so I am not requesting that this be included in this PR. But, do you think these types of selections based on values in images would be reasonable feature requests in the future?

@PaulWessel
Copy link
Member Author

Thanks, just updated -M description do say d, m, and s units are available for geographic grids.

@PaulWessel
Copy link
Member Author

Let me know if you think this one is OK to go. I added that it is experimental at the top of the RST docs.

@maxrjones
Copy link
Member

Let me know if you think this one is OK to go. I added that it is experimental at the top of the RST docs.

Yes, I think so. I haven't tried out the latest image addition but tested the other features this morning and it seems like a nice addition. My one comment for now is that the module description "Determine common regions from 2-D grids, images or 3-D cubes" doesn't capture the latest features that you've added.

Copy link
Member

@maxrjones maxrjones left a comment

Choose a reason for hiding this comment

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

There's some comments from my review this morning still at https://github.com/GenericMappingTools/gmt/pull/5929/files. OK to merge without them if you do not agree we the changes.

@PaulWessel
Copy link
Member Author

True. Maybe

Make selections or determine common regions from 2-D grids, images or 3-D

@PaulWessel PaulWessel changed the title WIP A new module: grdselect A new module: grdselect Nov 17, 2021
@maxrjones
Copy link
Member

True. Maybe

Make selections or determine common regions from 2-D grids, images or 3-D

Sounds good.

@PaulWessel
Copy link
Member Author

Strange, I went through a bunch of this hours ago and merged in but not in the repo...they were all suggestions and I accepted them. Now they are listed as differences - I guess I need to make the edits.

@PaulWessel PaulWessel merged commit eadadb9 into master Nov 17, 2021
@PaulWessel PaulWessel deleted the grdselect-module branch November 17, 2021 02:39
@seisman seisman removed this from the Future release milestone Jan 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

add-changelog Add PR to the changelog new module PR that implements a new module

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants