.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/postprocessing/plot_frankslide_results.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_postprocessing_plot_frankslide_results.py: Load and display results as maps =========================== We show here how simulation results can be loaded, and 2D results displayed as figures. .. GENERATED FROM PYTHON SOURCE LINES 11-12 Initial import .. GENERATED FROM PYTHON SOURCE LINES 12-15 .. code-block:: Python import matplotlib.pyplot as plt import tilupy.read .. GENERATED FROM PYTHON SOURCE LINES 16-17 Import :doc:`pytopomap` package to control pricesly plots. pytopomap is used by tilupy to generate plots (see below) .. GENERATED FROM PYTHON SOURCE LINES 17-19 .. code-block:: Python import pytopomap.plot .. GENERATED FROM PYTHON SOURCE LINES 20-23 Initatiate Results instance. The first two lines can be used to download examples of results. If results are stored in a different folder than './shaltop_frankslide', ``folder_simus`` must be changed accordingly .. GENERATED FROM PYTHON SOURCE LINES 23-30 .. code-block:: Python # import tilupy.download_data # tilupy.download_data.import_shaltop_frankslide() folder_simus = "./shaltop_frankslide" res = tilupy.read.get_results( "shaltop", folder=folder_simus, file_params="delta_25p00.txt" ) .. GENERATED FROM PYTHON SOURCE LINES 31-32 Get x, y and z (topography) arrays .. GENERATED FROM PYTHON SOURCE LINES 32-36 .. code-block:: Python x, y, z = res.x, res.y, res.z fig, axe = plt.subplots() axe.imshow(z) .. image-sg:: /auto_examples/postprocessing/images/sphx_glr_plot_frankslide_results_001.png :alt: plot frankslide results :srcset: /auto_examples/postprocessing/images/sphx_glr_plot_frankslide_results_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 37-38 You can also display the topography with the pytopomap package is installed along with tilupy). .. GENERATED FROM PYTHON SOURCE LINES 38-41 .. code-block:: Python pytopomap.plot.plot_topo(z, x, y) .. image-sg:: /auto_examples/postprocessing/images/sphx_glr_plot_frankslide_results_002.png :alt: plot frankslide results :srcset: /auto_examples/postprocessing/images/sphx_glr_plot_frankslide_results_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 42-47 Simulation results get be obtained with the 'get_output' method and the name of the Result type. A 'Result' instance has several attributes describing it (e.g. name, unit, time, ...), the raw data is loaded in the attribute 'd' in a 'numpy.ndarray'. For instance to get the thickness recorded at different time steps: .. GENERATED FROM PYTHON SOURCE LINES 47-51 .. code-block:: Python h_res = res.get_output("h") print(h_res.t) plt.imshow(h_res.d[:, :, -1]) # Plot final thickness. .. image-sg:: /auto_examples/postprocessing/images/sphx_glr_plot_frankslide_results_003.png :alt: plot frankslide results :srcset: /auto_examples/postprocessing/images/sphx_glr_plot_frankslide_results_003.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none [ 0. 10. 20. 30. 40. 50. 60. 70. 80. 90. 100.] .. GENERATED FROM PYTHON SOURCE LINES 52-55 The final thickness can also be derived more directly with ``h_final``. It can be plotted on the topography with built-in functions returning the axe where the plot was created. Note that an already existing axe instance can be used with the ``ax`` parameter of the ``plot`` method. .. GENERATED FROM PYTHON SOURCE LINES 55-59 .. code-block:: Python h_final = res.get_output("h_final") axe = h_final.plot() .. image-sg:: /auto_examples/postprocessing/images/sphx_glr_plot_frankslide_results_004.png :alt: plot frankslide results :srcset: /auto_examples/postprocessing/images/sphx_glr_plot_frankslide_results_004.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none [WARNING] h_final not found with _read_from_file for shaltop, use get_spatial_stat .. GENERATED FROM PYTHON SOURCE LINES 60-65 Due to numerical dispersion, a large area is covered with a very thin layer of materials at the end of the simulation, which is not physically relevant. This can be removed from plots by imposing a minimum value. More generally, is the case of 2D data (:data:`tilupy.read.TEMPORAL_DATA_2D` and :data:`tilupy.read.STATIC_DATA_2D`), plots can be customized with parameters passed on to :func:`pytopomap.plot.plot_data_on_topo`, for instance: .. GENERATED FROM PYTHON SOURCE LINES 65-78 .. code-block:: Python # Parameters for topography topo_kwargs = dict( contour_step=50, # Interval between thin contour lines step_contour_bold=250, # Interval between bold contour lines ) # parameters passed on to pytopomap.plot.plot_data_on_topo kwargs = dict( vmin=0.2, # Minimum value to be displayed vmax=80, # Maximum value to be displayed cmap="viridis", # Colormap setting topo_kwargs=topo_kwargs, ) .. GENERATED FROM PYTHON SOURCE LINES 79-81 Here, the following call to the ``plot`` method is equivalent to ``pytopomap.plot.plot_data_on_topo(res.x, res.y, res.z, h_final.d, **kwargs)`` .. GENERATED FROM PYTHON SOURCE LINES 81-83 .. code-block:: Python axe = h_final.plot(**kwargs) .. image-sg:: /auto_examples/postprocessing/images/sphx_glr_plot_frankslide_results_005.png :alt: plot frankslide results :srcset: /auto_examples/postprocessing/images/sphx_glr_plot_frankslide_results_005.png :class: sphx-glr-single-img .. GENERATED FROM PYTHON SOURCE LINES 84-85 Sequential colormaps can also be easily created. .. GENERATED FROM PYTHON SOURCE LINES 85-91 .. code-block:: Python kwargs = dict( cmap_intervals=[0.5, 2, 10, 25, 50, 75, 100], cmap="viridis", topo_kwargs=topo_kwargs, ) h_final.plot(**kwargs) .. image-sg:: /auto_examples/postprocessing/images/sphx_glr_plot_frankslide_results_006.png :alt: plot frankslide results :srcset: /auto_examples/postprocessing/images/sphx_glr_plot_frankslide_results_006.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.847 seconds) .. _sphx_glr_download_auto_examples_postprocessing_plot_frankslide_results.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_frankslide_results.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_frankslide_results.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_frankslide_results.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_