-
Notifications
You must be signed in to change notification settings - Fork 225
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 grdtrack #308
Wrap grdtrack #308
Conversation
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.
Enable passing in netcdf file as input into grdtrack, instead of just xarray.DataArray. Also fix bug with kwargs being overwritten instead of appended to...
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.
Hi @weiji14 thanks for taking the time to implement this! I left a few minor comments. It would be great to have a gallery example of grdtrack and the new data sets as well (as simple as possible).
One thing I'm considering is if we need the East Pacific Rise grid. We can recreate that by slicing the Earth relief grids. This way we have one less function to test.
What do you think?
Rename 'table' parameter to 'points', remove default 'newcolname' parameter (require it to be explicitly set) and change the output 'ret' to 'track' in docstring. Unit tests updated accordingly.
I'll see if I have time over the weekend for making the examples (most likely in a separate pull request though). Is the sphinx gallery stable again?
That's actually a brilliant idea! |
One less dataset to test by replacing the east_pacific_rise_grid with the earth_relief 60m grid (sliced to the same area). Also add tests for loading the ocean_ridge_points dataset.
PyGMT grdtrack added under "Operations on grids" (though it does require a tabular data input). Also added the ocean_ridge_points tutorial dataset used in grdtrack's unit tests and reordered the tutorial datasets alphabetically.
Enable passing in ascii file inputs (csv, txt, etc) into grdtrack's 'points' parameter instead of just pandas.DataFrame. This requires a new 'outfile' parameter to be set. The type of 'points' input determines the type of 'track' returned, i.e. pd.DataFrame in, pd.DataFrame out; filename in, filename out. Extra unit tests created to test the various new input combinations and associated outputs.
New raster grid gallery example for grdtrack! Plotting bathymetry sampled along ocean ridge points around the globe. As this 'grid' subsection is new to the gallery, I've added it to the ExplicitOrder part within the sphinx conf.py file.
@leouieda, when you have time, please review some of the changes I've made to It's been a while since I used gmt to do any plotting, and my first time using sphinx-gallery, so I really welcome any comments on how this gallery example might be improved 😄 |
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.
@weiji14 the gallery plot looks great! Thanks for all this work 🎉
I left a few comments and suggestions. Overall, this just needs a few tweaks and should be good to merge.
Using numpy.testing.assert_allclose in test_grdtrack.py unit tests and make some cosmetic changes to docs and gallery example. To make the gallery example plot clearer, grid background colormap was changed from 'ocean' to 'gray', and the points are made slightly bigger. Also changed map to be Pacific-centered!
Ok, I've made the requested tweaks and it should be good to merge 🔀! There was a small timeout issue on the Travis CI MacOS build failing to download the earth relief 60m resolution grid 🌐, but I've restarted it and the automated checks have all passed now 🎉. |
Please don't apologize, I'd rather have GMT6 released properly more than anything now! I see #311 has been merged so I'm gonna install 6.0.0rc1 on my linux system as well and run some tests to see if there's any issues. Let me know once everything settles and I can merge in the changes from PyGMT master into this Pull Request :) |
29220bd
to
421e10d
Compare
Just checking in here 👋. I've merged in the latest 6.0.0rc4 stuff and the tests have passed. Would love to get this PR merged in soon as there's the "ocean ridge points" dataset that will be great from testing some of the other wrappers. Plus |
Right, the documentation preview (from #344) is awesome! You can see the new gallery example at https://pygmt-git-fork-weiji14-sampling-grdtrack.gmt.now.sh/gallery/grid/track_sampling.html. However, there's a yellow box called 'Out' printing the stdout that comes from downloading the earth relief grid 🤦♂️ ... Something to do with the sphinx extension? |
@weiji14 nice! I’ll have a look at this soon. The Out box is captured by Sphinx-gallery so you can |
Due to new SRTM15+V2 grids, see also #350.
@leouieda, did you have anything extra to add here? It's been more than half a year and I'd like to get on with merging this pull request (and maybe some of the other 'Wrapper' code I wrote). |
Make tests pass again, by fixing the test bathymetry values, and cutting our docstrings to 79 characters instead of 88.
1cb310e
to
f0b6de3
Compare
Status checks for Travis not being updated properly (see https://travis-ci.community/t/github-status-not-posted-on-commits-on-repositories-using-legacy-service-integration/7798). I think we need to migrate to using the Travis Github Apps Integration. Issue opened at #403. |
Description of proposed changes
Wrapping the
grdtrack
sampling function. Also added new tutorial functionload_ocean_ridge_points()
to use in test cases.Fixes #307
Reminders
make format
andmake check
to make sure the code follows the style guide.doc/api/index.rst
.