Skip to content
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

Wrapper for gmtselect #1427

Closed
weiji14 opened this issue Aug 10, 2021 · 2 comments
Closed

Wrapper for gmtselect #1427

weiji14 opened this issue Aug 10, 2021 · 2 comments
Assignees
Labels
feature request New feature wanted
Milestone

Comments

@weiji14
Copy link
Member

weiji14 commented Aug 10, 2021

Description of the desired feature

Implement gmtselect which "Select data table subsets based on multiple spatial criteria".

Mentioned at https://twitter.com/ATiredGradStdnt/status/1417189659365498884, also partially used before at https://forum.generic-mapping-tools.org/t/gmt-example-18-with-pygmt-volumes-and-spatial-selections/1585.

This function will probably be named select, i.e. called using pygmt.select(). As a table in, table out function, the implementation would be similar to already wrapped functions like blockmedian/blockmean. The code snippet would look something like so:

with GMTTempFile(suffix=".csv") as tmpfile:
with Session() as lib:
# Choose how data will be passed into the module
table_context = lib.virtualfile_from_data(
check_kind="vector", data=table, x=x, y=y, z=z
)
# Run blockm* on data table
with table_context as infile:
if outfile is None:
outfile = tmpfile.name
arg_str = " ".join([infile, build_arg_string(kwargs), "->" + outfile])
lib.call_module(module=block_method, args=arg_str)
# Read temporary csv output to a pandas table
if outfile == tmpfile.name: # if user did not set outfile, return pd.DataFrame
try:
column_names = table.columns.to_list()
result = pd.read_csv(tmpfile.name, sep="\t", names=column_names)
except AttributeError: # 'str' object has no attribute 'columns'
result = pd.read_csv(tmpfile.name, sep="\t", header=None, comment=">")
elif outfile != tmpfile.name: # return None if outfile set, output in outfile
result = None
return result

Xref table I/O discussion at #1268 and #1318. Best to wrap this module after #1426.

Are you willing to help implement and maintain this feature? Yes

@weiji14 weiji14 added the feature request New feature wanted label Aug 10, 2021
weiji14 added a commit that referenced this issue Aug 10, 2021
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).
@weiji14 weiji14 mentioned this issue Aug 10, 2021
19 tasks
weiji14 added a commit that referenced this issue Aug 10, 2021
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).
@weiji14 weiji14 added this to the 0.5.0 milestone Aug 10, 2021
@weiji14 weiji14 self-assigned this Aug 10, 2021
@seisman
Copy link
Member

seisman commented Mar 9, 2022

Can we close the issue, since the initial wrapper has been done in #1429? Or do we still want to keep this issue open to tracking missing aliases, and gallery examples? Keeping the issue open makes me think that it has not been wrapped.

Related to #1599.

@weiji14
Copy link
Member Author

weiji14 commented Mar 13, 2022

Ok, closing as initial implementation done at #1429. Tracking progress on project board https://github.com/GenericMappingTools/pygmt/projects/9#card-72007028 instead.

@weiji14 weiji14 closed this as completed Mar 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature wanted
Projects
None yet
Development

No branches or pull requests

2 participants