
.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "examples/interp/plot_interpolated_surface.py"
.. LINE NUMBERS ARE GIVEN BELOW.

.. only:: html

    .. note::
        :class: sphx-glr-download-link-note

        :ref:`Go to the end <sphx_glr_download_examples_interp_plot_interpolated_surface.py>`
        to download the full example code.

.. rst-class:: sphx-glr-example-title

.. _sphx_glr_examples_interp_plot_interpolated_surface.py:


Interpolated with surface topo
==============================

Demonstrate interpolating two-dimensional model output when surface topography,
rather than bedrock topography, is present in the original data. The result is
the same as in the interpolated output example.

.. GENERATED FROM PYTHON SOURCE LINES 13-46



.. image-sg:: /examples/interp/images/sphx_glr_plot_interpolated_surface_001.png
   :alt: Interpolated output
   :srcset: /examples/interp/images/sphx_glr_plot_interpolated_surface_001.png
   :class: sphx-glr-single-img


.. rst-class:: sphx-glr-script-out

 .. code-block:: none

    /home/docs/checkouts/readthedocs.org/user_builds/hyoga/envs/stable/lib/python3.12/site-packages/hyoga/open/example.py:29: FutureWarning: In a future version, xarray will not decode timedelta values based on the presence of a timedelta-like units attribute by default. Instead it will rely on the presence of a timedelta64 dtype attribute, which is now xarray's default way of encoding timedelta64 values. To continue decoding timedeltas based on the presence of a timedelta-like units attribute, users will need to explicitly opt-in by passing True or CFTimedeltaCoder(decode_via_units=True) to decode_timedelta. To silence this warning, set decode_timedelta to True, False, or a 'CFTimedeltaCoder' instance.
      return xr.open_dataset(path)
    downloading https://raw.githubusercontent.com/juseg/hyoga-data/main/pism/pism.alps.vis.refined.nc...






|

.. code-block:: Python


    import matplotlib.pyplot as plt
    import hyoga

    # initialize figure
    ax = plt.subplot()

    # open demo data
    with hyoga.open.example('pism.alps.out.2d.nc') as ds:

        # compute surface altitude and remove bedrock altitude
        ds = ds.hyoga.assign(surface_altitude=ds.hyoga.getvar('surface_altitude'))
        ds = ds.drop_vars(ds.hyoga.getvar('bedrock_altitude').name)

        # compute isostatic adjustment from a reference input topography
        ds = ds.hyoga.assign_isostasy(hyoga.open.example('pism.alps.in.boot.nc'))

        # perform the actual interpolation
        ds = ds.hyoga.interp(hyoga.open.example('pism.alps.vis.refined.nc'))

        # plot model output
        ds.hyoga.plot.bedrock_altitude(ax=ax, cmap='Topographic', center=False)
        ds.hyoga.plot.surface_altitude_contours(ax=ax)
        ds.hyoga.plot.ice_margin(ax=ax, facecolor='w')

        # add scale bar
        ds.hyoga.plot.scale_bar()

    # set title
    ax.set_title('Interpolated output')

    # show
    plt.show()


.. rst-class:: sphx-glr-timing

   **Total running time of the script:** (0 minutes 0.974 seconds)


.. _sphx_glr_download_examples_interp_plot_interpolated_surface.py:

.. only:: html

  .. container:: sphx-glr-footer sphx-glr-footer-example

    .. container:: sphx-glr-download sphx-glr-download-jupyter

      :download:`Download Jupyter notebook: plot_interpolated_surface.ipynb <plot_interpolated_surface.ipynb>`

    .. container:: sphx-glr-download sphx-glr-download-python

      :download:`Download Python source code: plot_interpolated_surface.py <plot_interpolated_surface.py>`

    .. container:: sphx-glr-download sphx-glr-download-zip

      :download:`Download zipped: plot_interpolated_surface.zip <plot_interpolated_surface.zip>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_
