.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "content/examples/01-maps/plot_mesh2mesh.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_content_examples_01-maps_plot_mesh2mesh.py: Maps: Mesh2Mesh =============== This mapping allows you to go from one mesh to another. .. GENERATED FROM PYTHON SOURCE LINES 7-42 .. image-sg:: /content/examples/01-maps/images/sphx_glr_plot_mesh2mesh_001.png :alt: Fine Mesh (Original), Course Mesh, Fine Mesh (Interpolated) :srcset: /content/examples/01-maps/images/sphx_glr_plot_mesh2mesh_001.png :class: sphx-glr-single-img .. code-block:: Python import discretize from simpeg import maps, utils import matplotlib.pyplot as plt def run(plotIt=True): M = discretize.TensorMesh([100, 100]) h1 = utils.unpack_widths([(6, 7, -1.5), (6, 10), (6, 7, 1.5)]) h1 = h1 / h1.sum() M2 = discretize.TensorMesh([h1, h1]) V = utils.model_builder.create_random_model(M.vnC, seed=79, its=50) v = utils.mkvc(V) modh = maps.Mesh2Mesh([M, M2]) modH = maps.Mesh2Mesh([M2, M]) H = modH * v h = modh * H if not plotIt: return ax = plt.subplot(131) M.plot_image(v, ax=ax) ax.set_title("Fine Mesh (Original)") ax = plt.subplot(132) M2.plot_image(H, clim=[0, 1], ax=ax) ax.set_title("Course Mesh") ax = plt.subplot(133) M.plot_image(h, clim=[0, 1], ax=ax) ax.set_title("Fine Mesh (Interpolated)") if __name__ == "__main__": run() plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.390 seconds) **Estimated memory usage:** 10 MB .. _sphx_glr_download_content_examples_01-maps_plot_mesh2mesh.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_mesh2mesh.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_mesh2mesh.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_