From caf3cc12b474f3f2a4919fae3f994d441714c8e5 Mon Sep 17 00:00:00 2001 From: Santiago Soler Date: Fri, 22 Mar 2024 16:14:20 -0700 Subject: [PATCH] Fix missing PyGMT images in user guide (#474) Add hidden cell in user guide examples configuring PyGMT to use `"notebook"` as display method. This way `jupyter-sphinx` is able to render the images in the generated HTML files. This issue should be fixed upstream in PyGMT. --- .../equivalent_sources/block-averaged-eqs.rst | 13 +++++++++++++ .../equivalent_sources/eq-sources-spherical.rst | 12 ++++++++++++ .../eqs-parameters-estimation.rst | 12 ++++++++++++ .../equivalent_sources/gradient-boosted-eqs.rst | 12 ++++++++++++ doc/user_guide/equivalent_sources/index.rst | 12 ++++++++++++ doc/user_guide/forward_modelling/point.rst | 12 ++++++++++++ doc/user_guide/forward_modelling/prism.rst | 12 ++++++++++++ doc/user_guide/forward_modelling/tesseroid.rst | 12 ++++++++++++ doc/user_guide/gravity_disturbance.rst | 12 ++++++++++++ doc/user_guide/topographic_correction.rst | 12 ++++++++++++ 10 files changed, 121 insertions(+) diff --git a/doc/user_guide/equivalent_sources/block-averaged-eqs.rst b/doc/user_guide/equivalent_sources/block-averaged-eqs.rst index e9d6b389a..f7fe20c29 100644 --- a/doc/user_guide/equivalent_sources/block-averaged-eqs.rst +++ b/doc/user_guide/equivalent_sources/block-averaged-eqs.rst @@ -62,6 +62,19 @@ And project the geographic coordinates to plain Cartesian ones: coordinates = (easting, northing, data.height_m) xy_region=vd.get_region(coordinates) + +.. jupyter-execute:: + :hide-code: + + import pygmt + + # Needed so that displaying works on jupyter-sphinx and sphinx-gallery at + # the same time. Using PYGMT_USE_EXTERNAL_DISPLAY="false" in the Makefile + # for sphinx-gallery to work means that fig.show won't display anything here + # either. + pygmt.set_display(method="notebook") + + .. jupyter-execute:: import pygmt diff --git a/doc/user_guide/equivalent_sources/eq-sources-spherical.rst b/doc/user_guide/equivalent_sources/eq-sources-spherical.rst index 77aff218d..bdd672cc2 100644 --- a/doc/user_guide/equivalent_sources/eq-sources-spherical.rst +++ b/doc/user_guide/equivalent_sources/eq-sources-spherical.rst @@ -146,6 +146,18 @@ grid points that are too far away from any data point: Lets plot it: +.. jupyter-execute:: + :hide-code: + + import pygmt + + # Needed so that displaying works on jupyter-sphinx and sphinx-gallery at + # the same time. Using PYGMT_USE_EXTERNAL_DISPLAY="false" in the Makefile + # for sphinx-gallery to work means that fig.show won't display anything here + # either. + pygmt.set_display(method="notebook") + + .. jupyter-execute:: import pygmt diff --git a/doc/user_guide/equivalent_sources/eqs-parameters-estimation.rst b/doc/user_guide/equivalent_sources/eqs-parameters-estimation.rst index c62573201..22b5c2c57 100644 --- a/doc/user_guide/equivalent_sources/eqs-parameters-estimation.rst +++ b/doc/user_guide/equivalent_sources/eqs-parameters-estimation.rst @@ -188,6 +188,18 @@ And grid the data using the two equivalent sources: Lets plot it: +.. jupyter-execute:: + :hide-code: + + import pygmt + + # Needed so that displaying works on jupyter-sphinx and sphinx-gallery at + # the same time. Using PYGMT_USE_EXTERNAL_DISPLAY="false" in the Makefile + # for sphinx-gallery to work means that fig.show won't display anything here + # either. + pygmt.set_display(method="notebook") + + .. jupyter-execute:: import pygmt diff --git a/doc/user_guide/equivalent_sources/gradient-boosted-eqs.rst b/doc/user_guide/equivalent_sources/gradient-boosted-eqs.rst index 3ecd6ad63..eb339d179 100644 --- a/doc/user_guide/equivalent_sources/gradient-boosted-eqs.rst +++ b/doc/user_guide/equivalent_sources/gradient-boosted-eqs.rst @@ -145,6 +145,18 @@ point. We can do so through the :func:`verde.distance_mask` function. And plot it: +.. jupyter-execute:: + :hide-code: + + import pygmt + + # Needed so that displaying works on jupyter-sphinx and sphinx-gallery at + # the same time. Using PYGMT_USE_EXTERNAL_DISPLAY="false" in the Makefile + # for sphinx-gallery to work means that fig.show won't display anything here + # either. + pygmt.set_display(method="notebook") + + .. jupyter-execute:: import pygmt diff --git a/doc/user_guide/equivalent_sources/index.rst b/doc/user_guide/equivalent_sources/index.rst index d287fffe0..a7a40b1ff 100644 --- a/doc/user_guide/equivalent_sources/index.rst +++ b/doc/user_guide/equivalent_sources/index.rst @@ -112,6 +112,18 @@ sources are able to reproduce the observed field. And plot it: +.. jupyter-execute:: + :hide-code: + + import pygmt + + # Needed so that displaying works on jupyter-sphinx and sphinx-gallery at + # the same time. Using PYGMT_USE_EXTERNAL_DISPLAY="false" in the Makefile + # for sphinx-gallery to work means that fig.show won't display anything here + # either. + pygmt.set_display(method="notebook") + + .. jupyter-execute:: import pygmt diff --git a/doc/user_guide/forward_modelling/point.rst b/doc/user_guide/forward_modelling/point.rst index 7017ea960..004058c0d 100644 --- a/doc/user_guide/forward_modelling/point.rst +++ b/doc/user_guide/forward_modelling/point.rst @@ -91,6 +91,18 @@ generated by the whole set of point sources on every computation point: Lets plot this gravitational field: +.. jupyter-execute:: + :hide-code: + + import pygmt + + # Needed so that displaying works on jupyter-sphinx and sphinx-gallery at + # the same time. Using PYGMT_USE_EXTERNAL_DISPLAY="false" in the Makefile + # for sphinx-gallery to work means that fig.show won't display anything here + # either. + pygmt.set_display(method="notebook") + + .. jupyter-execute:: import pygmt diff --git a/doc/user_guide/forward_modelling/prism.rst b/doc/user_guide/forward_modelling/prism.rst index f95245a37..4cbfa5abe 100644 --- a/doc/user_guide/forward_modelling/prism.rst +++ b/doc/user_guide/forward_modelling/prism.rst @@ -185,6 +185,18 @@ generated by the whole set of prisms on every computation point: Lets plot this gravitational field: +.. jupyter-execute:: + :hide-code: + + import pygmt + + # Needed so that displaying works on jupyter-sphinx and sphinx-gallery at + # the same time. Using PYGMT_USE_EXTERNAL_DISPLAY="false" in the Makefile + # for sphinx-gallery to work means that fig.show won't display anything here + # either. + pygmt.set_display(method="notebook") + + .. jupyter-execute:: import pygmt diff --git a/doc/user_guide/forward_modelling/tesseroid.rst b/doc/user_guide/forward_modelling/tesseroid.rst index e4b76def8..21c4a5c47 100644 --- a/doc/user_guide/forward_modelling/tesseroid.rst +++ b/doc/user_guide/forward_modelling/tesseroid.rst @@ -96,6 +96,18 @@ generates on the computation point: And finally plot the computed gravitational field +.. jupyter-execute:: + :hide-code: + + import pygmt + + # Needed so that displaying works on jupyter-sphinx and sphinx-gallery at + # the same time. Using PYGMT_USE_EXTERNAL_DISPLAY="false" in the Makefile + # for sphinx-gallery to work means that fig.show won't display anything here + # either. + pygmt.set_display(method="notebook") + + .. jupyter-execute:: import pygmt diff --git a/doc/user_guide/gravity_disturbance.rst b/doc/user_guide/gravity_disturbance.rst index 1a5354f68..a27da1c5e 100644 --- a/doc/user_guide/gravity_disturbance.rst +++ b/doc/user_guide/gravity_disturbance.rst @@ -63,6 +63,18 @@ These observations are located on a regular grid on geodetic coordinates at the same height of 10 km above the reference ellipsoid. Lets plot it: +.. jupyter-execute:: + :hide-code: + + import pygmt + + # Needed so that displaying works on jupyter-sphinx and sphinx-gallery at + # the same time. Using PYGMT_USE_EXTERNAL_DISPLAY="false" in the Makefile + # for sphinx-gallery to work means that fig.show won't display anything here + # either. + pygmt.set_display(method="notebook") + + .. jupyter-execute:: import pygmt diff --git a/doc/user_guide/topographic_correction.rst b/doc/user_guide/topographic_correction.rst index 274a50b7e..af3b1cdde 100644 --- a/doc/user_guide/topographic_correction.rst +++ b/doc/user_guide/topographic_correction.rst @@ -52,6 +52,18 @@ in Southern Africa. And plot it: +.. jupyter-execute:: + :hide-code: + + import pygmt + + # Needed so that displaying works on jupyter-sphinx and sphinx-gallery at + # the same time. Using PYGMT_USE_EXTERNAL_DISPLAY="false" in the Makefile + # for sphinx-gallery to work means that fig.show won't display anything here + # either. + pygmt.set_display(method="notebook") + + .. jupyter-execute:: import pygmt