.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/postprocessing/process_results_cmd.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_process_results_cmd.py: Process multiple simulations at once =========================== We show here how multiple simulation results can be processed at once to generate plots or rasters, here with shaltop. .. GENERATED FROM PYTHON SOURCE LINES 10-11 Initial import: .. GENERATED FROM PYTHON SOURCE LINES 11-13 .. code-block:: Python import tilupy.cmd .. GENERATED FROM PYTHON SOURCE LINES 14-16 Specify where simulation results are located. You can dowload an example folder containing shaltop results by uncommenting the first two lines. .. GENERATED FROM PYTHON SOURCE LINES 16-21 .. code-block:: Python # import tilupy.download_data # tilupy.download_data.import_shaltop_frankslide() folder_simus = "./shaltop_frankslide" .. GENERATED FROM PYTHON SOURCE LINES 22-24 Multiple simulations can be processed at once from a given Unix style pattern for the parameter files, e.g.: .. GENERATED FROM PYTHON SOURCE LINES 24-26 .. code-block:: Python params_files = "delta_2*p00.txt" .. GENERATED FROM PYTHON SOURCE LINES 27-30 The :module:`tilupy.cmd` module can then be used to process all the corresponding simulations. In this example, we plot all the thicknesses at the different recorded time steps, and save results in the simulation result folder, in a new 'plots' folder. The plots can be displayed with ``display_plot=True`` .. GENERATED FROM PYTHON SOURCE LINES 30-35 .. code-block:: Python state = "h" tilupy.cmd.plot_results( "shaltop", state, params_files, folder_simus, save=True, display_plot=False ) .. GENERATED FROM PYTHON SOURCE LINES 36-38 ``cmd.plot_results`` calls the ``plot`` method of result instance corresponding to the specified ``state``. It can be parametrized accordingly, for instance: .. GENERATED FROM PYTHON SOURCE LINES 38-52 .. code-block:: Python topo_kwargs = dict(contour_step=10, step_contour_bold=100) tilupy.cmd.plot_results( "shaltop", "h", params_files, folder_simus, save=True, display_plot=False, figsize=(15 / 2.54, 15 / 2.54), vmin=0.1, vmax=100, topo_kwargs=topo_kwargs, ) .. GENERATED FROM PYTHON SOURCE LINES 53-54 Similarly, you can plot and save the map of maximum thickness with: .. GENERATED FROM PYTHON SOURCE LINES 54-66 .. code-block:: Python tilupy.cmd.plot_results( "shaltop", "h_max", params_files, folder_simus, save=True, display_plot=False, figsize=(15 / 2.54, 15 / 2.54), cmap_intervals=[0.1, 5, 10, 25, 50, 100], topo_kwargs=topo_kwargs, ) .. GENERATED FROM PYTHON SOURCE LINES 67-69 Similarly, you can transform and save results to raster files in a new ``processed`` folder created in each folder where raw simulation results are stored. .. GENERATED FROM PYTHON SOURCE LINES 69-71 .. code-block:: Python tilupy.cmd.to_raster("shaltop", "h_max", params_files, folder_simus, fmt="tif") .. GENERATED FROM PYTHON SOURCE LINES 72-93 :mod:`tilupy.cmd` can be called directly from a command line for quick processing, although less parameters are allowed. Two commands are provided to plot and save results, respectively ``tilupy_plot`` and ``tilupy_to_raster``. For instance in command line: .. code-block:: console tilupy_plot -n h -p *.txt --vmin 0.1 --vmax 100 is equivalent to using in a python script: .. code-block:: python tilupy.cmd.plot_results("shaltop", "h", "*.txt", vmin=0.1, vmax=100) To get more information on ``tilupy_plot`` and ``tilupy_to_raster`` use the ``help`` parameter: .. code-block:: console tilupy_plot -h tilupy_to_raster -h .. _sphx_glr_download_auto_examples_postprocessing_process_results_cmd.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: process_results_cmd.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: process_results_cmd.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: process_results_cmd.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_