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

Add a tutorial for grdhisteq #1821

Merged
merged 12 commits into from Apr 9, 2022
Merged

Add a tutorial for grdhisteq #1821

merged 12 commits into from Apr 9, 2022

Conversation

maxrjones
Copy link
Member

Description of proposed changes

This PR adds a tutorial showing how to find data values that divide a grid into equal patches of area and write grids with statistics based on cumulative distribution functions.

Fixes #

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 wrapping a new module, open a 'Wrap new GMT module' issue and submit reasonably-sized PRs.
  • 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

@maxrjones maxrjones added the documentation Improvements or additions to documentation label Mar 15, 2022
@seisman seisman added this to the 0.6.1 milestone Mar 16, 2022
region = [-119.825, -119.4, 37.6, 37.825]

grid = pygmt.datasets.load_earth_relief(resolution="03s", region=region)
grid_dist = pygmt.grd2xyz(grid=grid, outcols=2, output_type="numpy")[:, 0]
Copy link
Member

Choose a reason for hiding this comment

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

Not directly related to this PR, but running grd2xyz gives me unexpected output:

>>> pygmt.grd2xyz(grid=grid, outcols=2, output_type="numpy")
array([[1536.,   nan,   nan],
       [1539.,   nan,   nan],
       [1542.,   nan,   nan],
       ...,
       [2793.,   nan,   nan],
       [2800.,   nan,   nan],
       [2802.,   nan,   nan]])

So it looks like a bug, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, this is a PyGMT issue related to how the temp file output is read into a pandas.DataFrame.

Copy link
Member

@seisman seisman Mar 16, 2022

Choose a reason for hiding this comment

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

Two comments here:

  1. pygmt.grd2xyz(grid=grid, outtput_type="pandas")["elevation"] is more readable
  2. Should we limit the use of outcols to output_type="file" only, otherwise we have to parse outcols and process the output columns.

@weiji14 weiji14 mentioned this pull request Mar 30, 2022
30 tasks
maxrjones and others added 2 commits April 5, 2022 18:34
Co-authored-by: Dongdong Tian <seisman@users.noreply.github.com>
Co-authored-by: Dongdong Tian <seisman@users.noreply.github.com>
Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com>
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
@seisman seisman added the final review call This PR requires final review and approval from a second reviewer label Apr 8, 2022
Copy link
Member

@weiji14 weiji14 left a comment

Choose a reason for hiding this comment

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

Thanks for adding this tutorial Meghan, and happy last day! Hope you get a nice break before starting your next adventure 😃

examples/tutorials/advanced/grid_equalization.py Outdated Show resolved Hide resolved
Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com>
Copy link
Member

@michaelgrund michaelgrund left a comment

Choose a reason for hiding this comment

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

Execpt the two minor changes everything looks great. Thanks for this tutorial @meghanrjones.

examples/tutorials/advanced/grid_equalization.py Outdated Show resolved Hide resolved
examples/tutorials/advanced/grid_equalization.py Outdated Show resolved Hide resolved
Co-authored-by: Michael Grund <23025878+michaelgrund@users.noreply.github.com>
Co-authored-by: Michael Grund <23025878+michaelgrund@users.noreply.github.com>
@seisman seisman merged commit 687097c into main Apr 9, 2022
@seisman seisman deleted the grdhisteq-tutorial branch April 9, 2022 01:11
@seisman seisman removed the final review call This PR requires final review and approval from a second reviewer label Apr 9, 2022
sixy6e pushed a commit to sixy6e/pygmt that referenced this pull request Dec 21, 2022
Co-authored-by: Wei Ji <23487320+weiji14@users.noreply.github.com>
Co-authored-by: Dongdong Tian <seisman.info@gmail.com>
Co-authored-by: Michael Grund <23025878+michaelgrund@users.noreply.github.com>
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.

None yet

4 participants