-
Notifications
You must be signed in to change notification settings - Fork 224
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 grdview #330
Wrap grdview #330
Conversation
Initial commit for wrapping the grdview function raised at #328, to be implemented under base_plotting.py alongside the other mapping related stuff. Original GMT `grdview` documentation can be found at https://docs.generic-mapping-tools.org/latest/grdview.html. Storing sample test cases under test_grdview.py. Current implementation takes in a reliefgrid either as a filename or xarray.DataArray. Aliased the 'required' arguments 'Jz' to 'zscale' and 'JZ' to 'zsize' (similar to GMT julia wrappper). Also aliased 'p' to 'perspective' (as is standard in upstream GMT) so that we can have some 3D test plots to compare against, instead of just some flat (birds-eye view) maps.
Giving our grdview wrapper the ability to color plots! The cmap (C) parameter (which stands for colormap) should be straightforward, while the surftype (Q) parameter is a little bit more complicated. Some more tests added to check that we can indeed produce colored perspective-view plots.
Included test for setting a plain z-axis plane at a fixed height, and a test for colouring the frontal facade too.
afc56c2
to
78a6205
Compare
Included test to check that plotting a vertical z-axis frame works.
Plus add test examples ensuring the different pens work.
Included one test for a valid (xarray.DataArray) drapegrid input, and one test for an invalid input. Also using contextlib.ExitStack() as we have more than one file_context (one for reliefgrid, one for drapegrid) to enter and exit properly (see https://stackoverflow.com/questions/3024925/create-a-with-block-on-several-context-managers).
Ready for review. I've updated the docstrings to conform to the new 79 char length standard and make it look nicer with napolean sphinx. Rendered docs at https://pygmt-38g8s97im.now.sh/api/generated/pygmt.Figure.grdview.html#pygmt.Figure.grdview. |
Refresh baseline plots to use SRTM15+V2.1 grids as per #401. Ran `pytest --mpl-generate-path=baseline pygmt/tests/test_grdview.py` to generate the png images.
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.
Many thanks for keeping this going! Looks good to me. Just one minor suggestion to be consistent with the other methods.
To be consistent with the other `grd...` functions.
Description of proposed changes
Wrapping the
grdview
function!Also taking a cue from the Julia wrapper/implementation at https://www.generic-mapping-tools.org/GMT.jl/latest/#GMT.grdview and GenericMappingTools/GMT.jl#218.
Parameters/Aliases to wrap:
...
Fixes #328
Reminders
make format
andmake check
to make sure the code follows the style guide.doc/api/index.rst
.