Skip to content

Remove mention of multiple grid inputs in grdtrack docstring - #1345

Closed
willschlitzer wants to merge 1 commit into
masterfrom
grdtrack-grid-input-docs
Closed

willschlitzer wants to merge 1 commit into
masterfrom
grdtrack-grid-input-docs

Conversation

@willschlitzer

Copy link
Copy Markdown
Contributor

The documentation for grdtrack states that it can accept multiple grid inputs for grid. As grid= can't be repeated in the same function call and it doesn't accept a list of grids, this pull request changes the documentation to state that the grdtrack accepts a single grid.

Reminders

  • Run make format and make check to make sure the code follows the style guide.
  • Add tests for new features or tests that would have caught the bug that you're fixing.
  • Add new public functions/methods/classes to doc/api/index.rst.
  • Write detailed docstrings for all functions/methods.
  • If adding new functionality, add an example to docstrings or tutorials.

Slash Commands

You can write slash commands (/command) in the first line of a comment to perform
specific operations. Supported slash commands are:

  • /format: automatically format and lint the code
  • /test-gmt-dev: run full tests on the latest GMT development version

@willschlitzer willschlitzer added the documentation Improvements or additions to documentation label Jun 21, 2021
@willschlitzer willschlitzer added this to the 0.5.0 milestone Jun 21, 2021
@willschlitzer willschlitzer self-assigned this Jun 21, 2021
Comment thread pygmt/src/grdtrack.py
first two columns (more columns may be present). It interpolates the
grid(s) at the positions in the table and writes out the table with the
grid at the positions in the table and writes out the table with the
interpolated values added as (one or more) new columns. Alternatively

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Is adding more than one new column possible with a single grid input, which I would assume could happen for a grid input with more than 3 dimensions? Or could this only be the case with multiple grid inputs in a single function?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

One could set crossprofile/-C and get more columns (with just a single grid as input), but this would only work for file outputs, as 3 columns are currently assumed for pandas.DataFrame output (lon, lat, z).

@weiji14 weiji14 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks like you've stumbled on some limitations of the current pygmt.grdtrack function. Now my question is, do we want to

  1. Restrict pygmt.grdtrack to only handle one grid? In which case this documentation PR would make sense, and users working on multiple grids would need to write for-loops or use GMT C instead; or
  2. Add in an enhancement so that pygmt.grdtrack can handle multiple grids? Which would be a bit more involved, but is presumably something that needs to be done anyway at some point. Something related to this is the need to handle multiple column outputs as hinted on in #1345 (comment) for people using grdtrack -C.

Comment thread pygmt/src/grdtrack.py
Sample grids at specified (x,y) locations.

Reads one or more grid files and a table (from file or an array input; but
Reads a grid file and a table (from file or an array input; but

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

As grid= can't be repeated in the same function call and it doesn't accept a list of grids, this pull request changes the documentation to state that the grdtrack accepts a single grid.

Technically someone smart enough could figure out that doing grid="grid1.nc -Ggrid2.nc -Ggrid3.nc" would work, but it's more of a hacky solution 🙃

Comment thread pygmt/src/grdtrack.py
first two columns (more columns may be present). It interpolates the
grid(s) at the positions in the table and writes out the table with the
grid at the positions in the table and writes out the table with the
interpolated values added as (one or more) new columns. Alternatively

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

One could set crossprofile/-C and get more columns (with just a single grid as input), but this would only work for file outputs, as 3 columns are currently assumed for pandas.DataFrame output (lon, lat, z).

@maxrjones

Copy link
Copy Markdown
Member

Looks like you've stumbled on some limitations of the current pygmt.grdtrack function. Now my question is, do we want to

1. Restrict `pygmt.grdtrack` to only handle one grid? In which case this documentation PR would make sense, and users working on multiple grids would need to write for-loops or use GMT C instead; or

2. Add in an enhancement so that `pygmt.grdtrack` can handle multiple grids? Which would be a bit more involved, but is presumably something that needs to be done anyway at some point. Something related to this is the need to handle multiple column outputs as hinted on in [#1345 (comment)](https://github.com/GenericMappingTools/pygmt/pull/1345#discussion_r655171335) for people using `grdtrack -C`.

I think option 2 is better.

@willschlitzer

Copy link
Copy Markdown
Contributor Author

Looks like you've stumbled on some limitations of the current pygmt.grdtrack function. Now my question is, do we want to

1. Restrict `pygmt.grdtrack` to only handle one grid? In which case this documentation PR would make sense, and users working on multiple grids would need to write for-loops or use GMT C instead; or

2. Add in an enhancement so that `pygmt.grdtrack` can handle multiple grids? Which would be a bit more involved, but is presumably something that needs to be done anyway at some point. Something related to this is the need to handle multiple column outputs as hinted on in [#1345 (comment)](https://github.com/GenericMappingTools/pygmt/pull/1345#discussion_r655171335) for people using `grdtrack -C`.

I think option 2 is better.

While I'm in favor of making this PyGMT module as functionally equivalent to its GMT counterpart as possible, I think these two options are different in scope and not mutually exclusive. I think the documentation should match the capabilities of the current PyGMT module, and can be further updated to reflect when PyGMT's grdtrack has been upgraded to accept multiple grid inputs.

@willschlitzer

Copy link
Copy Markdown
Contributor Author

@weiji14 @meghanrjones Should I close this PR? It looks like you are in favor of modifying grdtrack to accept multiple grids.

@maxrjones

Copy link
Copy Markdown
Member

@weiji14 @meghanrjones Should I close this PR? It looks like you are in favor of modifying grdtrack to accept multiple grids.

I agree with your comment about updating the documentation for current usage here, then opening a separate issue/PR for the enhancement.

@maxrjones maxrjones left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I am fine with this intermediate solution, but an enhancement issue should be opened before merging so we do not lose track of the need to add support for multiple inputs.

@maxrjones

Copy link
Copy Markdown
Member

Actually, I just noticed in the gmt docs the -G+llist option. I have not tested if this would work as part of a str argument to the grid parameter in pygmt's grdtrack, but if it does then documenting that option would be a better intermediate solution for multiple grids IMO.

@maxrjones
maxrjones self-requested a review June 28, 2021 22:14
@maxrjones

Copy link
Copy Markdown
Member

OK so pygmt.grdtrack works with multiple grid inputs but needs some improvements. Here's the test for that case:
In bash shell:

gmt grdcut @earth_relief_02m_g -Ggrid1.nc -R-118/-107/-49/-42
gmt grdcut @earth_age_02m_g -Ggrid2.nc -R-118/-107/-49/-42
echo "grid1.nc" > list.txt
echo "grid2.nc" >> list.txt

In python console:

from pygmt import grdtrack, which
from pygmt.datasets import load_ocean_ridge_points

dataframe = load_ocean_ridge_points()
output = grdtrack(points=dataframe, grid="+llist.txt",newcolname="data")

So in my opinion two things that need fixing are documenting grid="+lgrids" and updating newcolname to work with multiple column outputs. While I don't think that the grid="grid1.nc -Ggrid2.nc -Ggrid3.nc" hack should be considered a supported feature, since we do not always fully replicate gmt docs the grid="+lgrids" could be considered a feature. So, I no longer think we should remove mentions of multiple grid inputs.

@willschlitzer

Copy link
Copy Markdown
Contributor Author

Per @meghanrjones's comment, this change is no longer valid, so I'm closing the PR.

This branch was previously deployed

1 inactive deployment
Preview — 48e3e16f Deployed Jun 21, 2021 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants