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 grdtrack #307

Closed
weiji14 opened this issue May 22, 2019 · 0 comments · Fixed by #308
Closed

Wrapper for grdtrack #307

weiji14 opened this issue May 22, 2019 · 0 comments · Fixed by #308
Labels
feature request New feature wanted
Milestone

Comments

@weiji14
Copy link
Member

weiji14 commented May 22, 2019

Description of the desired feature

Implement grdtrack which "Sample grids at specified (x,y) locations". Continuing to add data processing functionality to pygmt following my earlier work on #245.

The grdtrack function belongs to the "Sampling of 1-D and 2-D Data" family of functions in GMT (see module quickref). It is slightly tricky to implement as it takes 2 input files (a table and a grid), but is nevertheless useful for people working on stuff like radar or laser altimetry, as mentioned by @steo85it in https://gitter.im/GenericMappingTools/pygmt?at=5c89603a8f294b134a38ed82.

Notes

  • May want to future proof the code to share it with other sampling functions like sample1d, grdsample, etc.
  • Test cases will require new sample datasets. hawaii_topo.nc would be nice but I can't find it, so I'm suggesting @ridge.txt and @spac_33.nc used in https://gmt.soest.hawaii.edu/doc/latest/gallery/ex33.html.
  • Handle I/O better, as mentioned here. Should we separate data reading/writing from data processing? I.e. have pygmt function running only on pandas tables, xarray grids.

Idea for structure

Store the grdtrack function under sampling.py. Similar to how e.g. surface is under gridding.py.

# File at gmt/sampling.py
"""
GMT modules for Sampling of 1-D and 2-D Data
"""

def grdtrack(table: pd.DataFrame, grid: xr.DataArray, **kwargs):

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

weiji14 referenced this issue in weiji14/pygmt May 22, 2019
Initial commit for #307. Implement GMT grdtrack function under sampling.py. Test cases checking proper pandas.DataFrame and xarray.DataArray inputs stored in test_grdtrack.py. Sample datasets for tests uses newly created load_east_pacific_rise_grid and load_ocean_ridge_points functions in datasets/tutorial.py.

GMT grdtrack documentation can be found at https://gmt.soest.hawaii.edu/doc/latest/grdtrack. Originally, grdtrack should take in an xyfile and -Ggridfile as parameters, and pass the output table to stdout. Here, the implementation (currently) takes in a pandas.DataFrame table and xarray.DataArray grid instead as input, and returns a pandas.DataFrame with an extra column for the sampled grid data.
@weiji14 weiji14 mentioned this issue May 22, 2019
5 tasks
@weiji14 weiji14 added the feature request New feature wanted label Oct 1, 2019
@weiji14 weiji14 added this to the 0.1.0 milestone Oct 4, 2019
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

Successfully merging a pull request may close this issue.

1 participant