Conversation
Initial commit for wrapping the gmtselect function for #1427 which selects data table subsets based on multiple spatial criteria. Original GMT `gmtselect` documentation is at https://docs.generic-mapping-tools.org/6.2/gmtselect.html. Aliased non-common optional parameters reverse (I) and z_subregion (Z).
253163b to
53ef119
Compare
|
@weiji14 Is the intent just to have the output of this as the file or a DataFrame, or should their be an option for a numpy array as well? |
| Pass in either a file name to an ASCII data table, a 2D | ||
| {table-classes}. |
There was a problem hiding this comment.
| Pass in either a file name to an ASCII data table, a 2D | |
| {table-classes}. | |
| Pass in either a file name to an ASCII data table or a 2D | |
| {table-classes}. |
I"m not familiar with using gmtselect, but can't it accept 3D tables (as indicated by z_subregion?
There was a problem hiding this comment.
This docstring gets rendered like so:
So 2D numpy.array is correct. I don't think it's common to speak of a 3D table (though I did find https://stackoverflow.com/questions/24290495/constructing-3d-pandas-dataframe), but I know what you mean by having a z-column.
There was a problem hiding this comment.
Maybe something like "2D or 3D {table-classes}"? I understand that 3D tables aren't the norm, but it doesn't make sense to have a parameter specifically for a 3D table but then say that gmtselect only accepts a 2D table.
There was a problem hiding this comment.
This is what I get when I search for 3D data table:
If we are talking about a 3D numpy array, the shape will be something like (1, 2, 3), but in this case, our input cannot be like that. It can only be a 2D shape like (2, 3). The extra z-column isn't considered an extra dimension, more like an extra attribute.
There was a problem hiding this comment.
Okay! That makes sense to me; I was thinking a 3D table meant one with data for the third dimension.
| {A} | ||
| reverse : str | ||
| [**cflrsz**]. | ||
| Reverses the sense of the test for each of the criteria specified: |
There was a problem hiding this comment.
| Reverses the sense of the test for each of the criteria specified: | |
| Reverses the criteria of the test for each of the criteria specified: |
The use of "sense" doesn't make much sense to me. I know it's from the GMT docs, but would there be a better way to phrase this?
There was a problem hiding this comment.
Yeah, it doesn't sound nice, but I think the following statements ("select records NOT inside/within ...") should (hopefully) make it clear to users what is meant by reverse. So maybe just keep it as with the GMT docs?
There was a problem hiding this comment.
If it's easier to keep it in line with the GMT docs, I'm fine with it. But I might open a PR over at GMT; I don't think the current version makes much sense.
|
@weiji14 Are you intending to get this pull request complete for v0.5.0? |
Yes, I've added this PR to the priority list at #1576 (comment). |
Specifically, resolution (D), gridmask (G) and mask (N). These aliases are currently undocumented/disabled, but will be implemented/enabled in the future.
* Wrap the gmtselect function which selects data table subsets based on multiple spatial criteria. Aliased non-common optional parameters reverse (I) and z_subregion (Z), area_thresh (A), resolution (D), gridmask (G) and mask (N). *Add tests for select *Add imports for select Co-authored-by: Will Schlitzer <schlitzer90@gmail.com>


Description of proposed changes
Wrapping the gmtselect function which "Selects data table subsets based on multiple spatial criteria". For a GMT example, see https://docs.generic-mapping-tools.org/6.2/gallery/ex24.html.
Preview docs at https://pygmt-git-wrap-gmtselect-gmt.vercel.app/api/generated/pygmt.select.html
Crossref GMT.jl docs at https://www.generic-mapping-tools.org/GMT.jl/v0.31/#GMT.gmtselect.
Parameters/Aliases to wrap:
Aarea_threshCdist2pt?Dresolution?EboundaryFpolygonGgridmaskIreverseLdist2line?RregionNmaskZz_subregion/zsubregionTo keep this PR small, I would prefer implementing only 4 out of 7 of the possible
gmtselectfilters, specifically-A(once #1426 is done),-Rrectangular region subset,-D/-Ncoastline subset, and-Zz value data subset. These, plus the reverse (-I) and grid subset (-G) option. The others can be done in a follow-up PR.Other implementation points to consider (may need to be done in other PRs):
selectfunction supports multiple file inputs, should we support this in PyGMT? See e.g.textat 7a08ebd. Related to this is if we should support multiple table-like inputs (e.g. twogeopandas.GeoDataFrameobjects in a list).z_subregionfor-Z(followingpygmt.grdcut, xref Wrap grdcut #492). Should we usezsubregion(no underscore) instead, following policy set in https://github.com/GenericMappingTools/pygmt/blame/v0.4.1/doc/contributing.md#L446-L450)?-Rand-Jcommon aliases here inselectdoesn't look good since it's not a plotting function. Probably don't need the Required if this is the first plot command part. Edit: Will be resolved by Add region docstring to COMMON_OPTIONS for non-plotting modules #1493/Update region and projection standard docstrings #1510 in the first line of a comment to performspecific operations. Supported slash commands are:
/format: automatically format and lint the code/test-gmt-dev: run full tests on the latest GMT development version