.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "_examples/01_modelling/plot_00_sensitivity.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_01_modelling_plot_00_sensitivity.py: Plotting sensitivities ^^^^^^^^^^^^^^^^^^^^^^ Sensitivity distributions can be easily plotted using the tdMan class: .. GENERATED FROM PYTHON SOURCE LINES 10-11 imports .. GENERATED FROM PYTHON SOURCE LINES 11-16 .. code-block:: Python import numpy as np import crtomo # is only used for reda.CreateEnterDirectory import reda .. GENERATED FROM PYTHON SOURCE LINES 25-26 create and save a FEM-grid .. GENERATED FROM PYTHON SOURCE LINES 26-52 .. code-block:: Python grid = crtomo.crt_grid.create_surface_grid( nr_electrodes=8, spacing=1, # char_lengths=0.05, char_lengths=[0.05, 0.1, 0.1, 0.1], depth=8, left=5, right=5, internal_lines=[ [4, -1, 6, -1], [4, -2, 6, -2], [4, -1, 4, -2], [6, -1, 6, -2], [0, -1, 3, -1], [0, -2, 3, -2], [0, -1, 0, -2], [3, -1, 3, -2], ], ) fig, ax = grid.plot_grid() with reda.CreateEnterDirectory('output_plot_00_sensitivity'): grid.save_elem_file('elem.dat') grid.save_elec_file('elec.dat') .. image-sg:: /_examples/01_modelling/images/sphx_glr_plot_00_sensitivity_001.png :alt: plot 00 sensitivity :srcset: /_examples/01_modelling/images/sphx_glr_plot_00_sensitivity_001.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 .. GENERATED FROM PYTHON SOURCE LINES 59-60 create the measurement configuration .. GENERATED FROM PYTHON SOURCE LINES 60-64 .. code-block:: Python configs = np.array(( (1, 2, 7, 6), )) .. GENERATED FROM PYTHON SOURCE LINES 65-66 for different background, plot the sensitivities .. GENERATED FROM PYTHON SOURCE LINES 66-107 .. code-block:: Python for bg in (1, 10, 100, 1000): td = crtomo.tdMan(grid=grid) td.configs.add_to_configs(configs) pid_mag, pid_pha = td.add_homogeneous_model(bg, 0) from shapely.geometry import Polygon # noqa:402 poly = Polygon([ [4, -1], [6, -1], [6, -2], [4, -2], ]) td.parman.modify_polygon(pid_mag, poly, 1) poly = Polygon([ [0, -1], [3, -1], [3, -2], [0, -2], ]) td.parman.modify_polygon(pid_pha, poly, -150) td.model(sensitivities=True, silent=True) # plot both mag and pha sensitivities fig, ax = td.plot_sensitivity(config_nr=0) with reda.CreateEnterDirectory('output_plot_00_sensitivity'): fig.savefig( 'sensitivity_bg_{}.jpg'.format(bg), dpi=300, bbox_inches='tight' ) # create another plot that only shows the magnitude sensitivity fig, ax = td.plot_sensitivity(config_nr=0, mag_only=True) with reda.CreateEnterDirectory('output_plot_00_sensitivity'): fig.savefig( 'sensitivity_magonly_bg_{}.jpg'.format(bg), dpi=300, bbox_inches='tight' ) .. rst-class:: sphx-glr-horizontal * .. image-sg:: /_examples/01_modelling/images/sphx_glr_plot_00_sensitivity_002.png :alt: Magnitude Sensitivity, Phase Sensitivity :srcset: /_examples/01_modelling/images/sphx_glr_plot_00_sensitivity_002.png :class: sphx-glr-single-img * .. image-sg:: /_examples/01_modelling/images/sphx_glr_plot_00_sensitivity_003.png :alt: Magnitude Sensitivity :srcset: /_examples/01_modelling/images/sphx_glr_plot_00_sensitivity_003.png :class: sphx-glr-single-img * .. image-sg:: /_examples/01_modelling/images/sphx_glr_plot_00_sensitivity_004.png :alt: Magnitude Sensitivity, Phase Sensitivity :srcset: /_examples/01_modelling/images/sphx_glr_plot_00_sensitivity_004.png :class: sphx-glr-single-img * .. image-sg:: /_examples/01_modelling/images/sphx_glr_plot_00_sensitivity_005.png :alt: Magnitude Sensitivity :srcset: /_examples/01_modelling/images/sphx_glr_plot_00_sensitivity_005.png :class: sphx-glr-single-img * .. image-sg:: /_examples/01_modelling/images/sphx_glr_plot_00_sensitivity_006.png :alt: Magnitude Sensitivity, Phase Sensitivity :srcset: /_examples/01_modelling/images/sphx_glr_plot_00_sensitivity_006.png :class: sphx-glr-single-img * .. image-sg:: /_examples/01_modelling/images/sphx_glr_plot_00_sensitivity_007.png :alt: Magnitude Sensitivity :srcset: /_examples/01_modelling/images/sphx_glr_plot_00_sensitivity_007.png :class: sphx-glr-single-img * .. image-sg:: /_examples/01_modelling/images/sphx_glr_plot_00_sensitivity_008.png :alt: Magnitude Sensitivity, Phase Sensitivity :srcset: /_examples/01_modelling/images/sphx_glr_plot_00_sensitivity_008.png :class: sphx-glr-single-img * .. image-sg:: /_examples/01_modelling/images/sphx_glr_plot_00_sensitivity_009.png :alt: Magnitude Sensitivity :srcset: /_examples/01_modelling/images/sphx_glr_plot_00_sensitivity_009.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none reading sensitivities reading sensitivities reading sensitivities reading sensitivities .. rst-class:: sphx-glr-timing **Total running time of the script:** (1 minutes 0.335 seconds) .. _sphx_glr_download__examples_01_modelling_plot_00_sensitivity.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_00_sensitivity.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_00_sensitivity.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_00_sensitivity.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_