.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "_examples/00_grids/plot_grid1.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__examples_00_grids_plot_grid1.py: Creating and handling meshes ============================ Grids for CRTomo can be created in multiple ways. We now support two ways: * using the :py:meth:`crtomo.crt_grid.create_surface_grid` function * using the command line command :py:mod:`cr_trig_create` This example only shows the usage of the former approach. .. note:: The CRTomo documentation is inconsistent in the use of the terms `mesh` and `grid`. Usually, a grid refers to a mesh with regularly spaced node locations in x and z direction. CRTomo also supports triangular meshes, which are still referred to as *grids* throughout the code and documentation. .. GENERATED FROM PYTHON SOURCE LINES 24-25 The top level crtomo import suffices for most tasks .. GENERATED FROM PYTHON SOURCE LINES 25-27 .. code-block:: Python import crtomo .. GENERATED FROM PYTHON SOURCE LINES 28-29 Create a simple surface grid with this wrapper .. GENERATED FROM PYTHON SOURCE LINES 29-42 .. code-block:: Python grid = crtomo.crt_grid.create_surface_grid( nr_electrodes=10, spacing=1.5, ) grid.plot_grid() # number the electrodes (useful for numerical studies) grid.plot_grid(plot_electrode_numbers=True) # save this grid to disc grid.save_elem_file('elem.dat') grid.save_elec_file('elec.dat') .. rst-class:: sphx-glr-horizontal * .. image-sg:: /_examples/00_grids/images/sphx_glr_plot_grid1_001.png :alt: plot grid1 :srcset: /_examples/00_grids/images/sphx_glr_plot_grid1_001.png :class: sphx-glr-multi-img * .. image-sg:: /_examples/00_grids/images/sphx_glr_plot_grid1_002.png :alt: plot grid1 :srcset: /_examples/00_grids/images/sphx_glr_plot_grid1_002.png :class: sphx-glr-multi-img .. rst-class:: sphx-glr-script-out .. code-block:: none This grid was sorted using CutMcK. The nodes were resorted! Triangular grid found .. GENERATED FROM PYTHON SOURCE LINES 43-44 The mesh can be read from disk: .. GENERATED FROM PYTHON SOURCE LINES 44-48 .. code-block:: Python grid1 = crtomo.crt_grid('elem.dat', 'elec.dat') print(grid1) grid1.plot_grid() .. image-sg:: /_examples/00_grids/images/sphx_glr_plot_grid1_003.png :alt: plot grid1 :srcset: /_examples/00_grids/images/sphx_glr_plot_grid1_003.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none This grid was sorted using CutMcK. The nodes were resorted! Triangular grid found CRMod/CTRomo grid instance number of elements: 1332 number of nodes: 722 number of electrodes: 10 grid dimsensions: X: -3.375 16.875 Z: -6.75 0.0 .. GENERATED FROM PYTHON SOURCE LINES 49-50 Create a grid with layering .. GENERATED FROM PYTHON SOURCE LINES 50-57 .. code-block:: Python grid = crtomo.crt_grid.create_surface_grid( nr_electrodes=10, spacing=1.5, lines=[0.5, 1], ) print(grid) grid.plot_grid() .. image-sg:: /_examples/00_grids/images/sphx_glr_plot_grid1_004.png :alt: plot grid1 :srcset: /_examples/00_grids/images/sphx_glr_plot_grid1_004.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none [[-3.375 -1. 11. ] [-3.375 -0.5 11. ]] [[16.875 -0.5 11. ] [16.875 -1. 11. ]] This grid was sorted using CutMcK. The nodes were resorted! Triangular grid found CRMod/CTRomo grid instance number of elements: 1428 number of nodes: 770 number of electrodes: 10 grid dimsensions: X: -3.375 16.875 Z: -6.75 0.0 .. _sphx_glr_download__examples_00_grids_plot_grid1.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_grid1.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_grid1.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_grid1.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_