-
Notifications
You must be signed in to change notification settings - Fork 220
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
Wrap gmtselect #1429
Wrap gmtselect #1429
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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:
A
area_threshC
dist2pt?D
resolution?E
boundaryF
polygonG
gridmaskI
reverseL
dist2line?R
regionN
maskZ
z_subregion/zsubregionTo keep this PR small, I would prefer implementing only 4 out of 7 of the possible
gmtselect
filters, specifically-A
(once #1426 is done),-R
rectangular region subset,-D
/-N
coastline subset, and-Z
z 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):
select
function supports multiple file inputs, should we support this in PyGMT? See e.g.text
at 7a08ebd. Related to this is if we should support multiple table-like inputs (e.g. twogeopandas.GeoDataFrame
objects in a list).z_subregion
for-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)?-R
and-J
common aliases here inselect
doesn'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![image](https://user-images.githubusercontent.com/23487320/128861719-c17dffdb-026e-4d7b-a30d-ff01bf4766d9.png
Addresses first part of #1427.
Reminders
make format
andmake check
to make sure the code follows the style guide.doc/api/index.rst
.Slash Commands
You can write slash commands (
/command
) 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