.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/postprocessing/plot_multiple_scenarios.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_multiple_scenarios.py: Combine multiple simulation results =========================== We show here how multiple simulation results can be combined to build, e.g., scenario-based hazard maps. .. GENERATED FROM PYTHON SOURCE LINES 11-12 Initial import .. GENERATED FROM PYTHON SOURCE LINES 12-18 .. code-block:: Python import matplotlib.pyplot as plt import numpy as np import tilupy.read import pytopomap.plot .. GENERATED FROM PYTHON SOURCE LINES 19-22 Specify where results are stored. If results are stored in a different folder than './shaltop_frankslide', ``folder_simus`` must be changed accordingly .. GENERATED FROM PYTHON SOURCE LINES 22-27 .. code-block:: Python # import tilupy.download_data # tilupy.download_data.import_shaltop_frankslide() folder_simus = "./shaltop_frankslide" .. GENERATED FROM PYTHON SOURCE LINES 28-33 We consider here three simulations with the Coulomb rheology and friction coefficients :math:`\mu_S=\tan(\delta)`, with :math:`\delta=15°`, :math:`\delta=20°` and :math:`\delta=25°`. The lower the friction angle :math:`\delta`, the higher the mobility. We will thus create map combining the impacted area for the three friction coefficients. We first make a list with the different parameters files .. GENERATED FROM PYTHON SOURCE LINES 33-39 .. code-block:: Python deltas = [15, 20, 25] param_files = [ "delta_{:5.2f}".format(delta).replace(".", "p") + ".txt" for delta in deltas ] .. GENERATED FROM PYTHON SOURCE LINES 40-42 Initiate result array with the same shape as the grid in the simulations. We also display the initial mass. .. GENERATED FROM PYTHON SOURCE LINES 42-49 .. code-block:: Python res = tilupy.read.get_results( "shaltop", folder=folder_simus, file_params=param_files[0] ) impacted_area = np.zeros(res.z.shape) res.plot("h_init") .. image-sg:: /auto_examples/postprocessing/images/sphx_glr_plot_multiple_scenarios_001.png :alt: plot multiple scenarios :srcset: /auto_examples/postprocessing/images/sphx_glr_plot_multiple_scenarios_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none [WARNING] h_init not found with _read_from_file for shaltop, use get_spatial_stat .. GENERATED FROM PYTHON SOURCE LINES 50-53 For each simulation, we recover the total impacted area by considering the area where the mximum simulated thickness is aboce a given threshold, here ``h_thresh=0.1``. It is added incrementally to the array ``impacted_area``, starting with the most mobile simulation (:math:`\delta=15°`). .. GENERATED FROM PYTHON SOURCE LINES 53-64 .. code-block:: Python h_thresh = 0.1 for i in range(3): tmp = tilupy.read.get_results( "shaltop", folder=folder_simus, file_params=param_files[i] ) ind = ( tmp.h_max > h_thresh ) # here res.h_max is equivalent to res.get_output('h_max').d impacted_area[ind] = deltas[i] plt.imshow(impacted_area) .. image-sg:: /auto_examples/postprocessing/images/sphx_glr_plot_multiple_scenarios_002.png :alt: plot multiple scenarios :srcset: /auto_examples/postprocessing/images/sphx_glr_plot_multiple_scenarios_002.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none .. GENERATED FROM PYTHON SOURCE LINES 65-72 We assume that increasing the friction cofficient necessarily reduces the impacted area. In the array ``impacted_area`` - ``impacted_area=25`` for a point impacted in the three simulations - ``impacted_area=20`` for a point impacted with :math:`\delta=20°` and :math:`\delta=15°` - ``impacted_area=15`` for a point impacted with :math:`\delta=15°` only - ``impacted_area=0`` for a point impacted by no simulation Results are rendered with :mod:`pytopomap`. .. GENERATED FROM PYTHON SOURCE LINES 72-86 .. code-block:: Python axe = pytopomap.plot.plot_data_on_topo( res.x, res.y, res.z, impacted_area, figsize=(18 / 2.54, 12 / 2.54), cmap="inferno_r", unique_values=True, # Make nice colorbar considering unique values alpha=0.7, # Add transparency to see the topography plot_colorbar=True, colorbar_kwargs=dict(label="Friction angle"), ) labels = ["$\\mu_S=\\tan({:.1f}$°$)$".format(delta) for delta in deltas] axe.figure.axes[-1].set_yticklabels(labels) .. image-sg:: /auto_examples/postprocessing/images/sphx_glr_plot_multiple_scenarios_003.png :alt: plot multiple scenarios :srcset: /auto_examples/postprocessing/images/sphx_glr_plot_multiple_scenarios_003.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none [Text(1, 16.0, '$\\mu_S=\\tan(15.0$°$)$'), Text(1, 20.0, '$\\mu_S=\\tan(20.0$°$)$'), Text(1, 24.0, '$\\mu_S=\\tan(25.0$°$)$')] .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.440 seconds) .. _sphx_glr_download_auto_examples_postprocessing_plot_multiple_scenarios.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_multiple_scenarios.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_multiple_scenarios.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_multiple_scenarios.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_