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

.. only:: html

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

        :ref:`Go to the end <sphx_glr_download_content_examples_01-maps_plot_layer.py>`
        to download the full example code.

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

.. _sphx_glr_content_examples_01-maps_plot_layer.py:


Maps: Parametrized Layer
========================

Build a model of a parametrized layer in a wholespace. If you want to
build a model of a parametrized layer in a halfspace, also use
maps.InjectActiveCell.

The model is

.. code::

    m = [
        'background physical property value',
        'layer physical property value',
        'layer center',
        'layer thickness'
    ]

.. GENERATED FROM PYTHON SOURCE LINES 20-50



.. image-sg:: /content/examples/01-maps/images/sphx_glr_plot_layer_001.png
   :alt: plot layer
   :srcset: /content/examples/01-maps/images/sphx_glr_plot_layer_001.png
   :class: sphx-glr-single-img





.. code-block:: Python


    import discretize
    from SimPEG import maps
    import numpy as np
    import matplotlib.pyplot as plt


    def run(plotIt=True):
        mesh = discretize.TensorMesh([50, 50], x0="CC")  # 2D tensor mesh
        mapping = maps.ParametricLayer(mesh)  # parametric layer in wholespace

        # model
        m = np.hstack(
            np.r_[
                1.0,  # background value
                2.0,  # layer value
                -0.1,  # layer center
                0.2,  # layer thickness
            ]
        )
        rho = mapping * m  # apply the mapping

        if plotIt is True:
            fig, ax = plt.subplots(1, 1, figsize=(4, 6))
            mesh.plot_image(rho, ax=ax)


    if __name__ == "__main__":
        run()
        plt.show()


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

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

**Estimated memory usage:**  8 MB


.. _sphx_glr_download_content_examples_01-maps_plot_layer.py:

.. only:: html

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

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

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

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

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


.. only:: html

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

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