.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "_examples/02_simple_inversion/plot_01_inversion_settings.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_02_simple_inversion_plot_01_inversion_settings.py: .. _example_crmod_crtomo_cfg: Setting modeling and inversion settings ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ This example discusses details of settings various settings for modeling or inversion using the single-frequency tdManager .. GENERATED FROM PYTHON SOURCE LINES 14-17 we create an empty tdMan instance, which lacks a model and measurement configurations in order to run a forward modeling and subsequent inversion. However, we still can set inversion settings .. GENERATED FROM PYTHON SOURCE LINES 17-26 .. code-block:: Python import crtomo grid = crtomo.crt_grid.create_surface_grid( nr_electrodes=20, spacing=1, char_lengths=[0.3, 1, 1, 1] ) # create the tdManager instance used for the inversion tdm = crtomo.tdMan(grid=grid) .. 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 27-32 Forward modeling settings are stored in tdm.crmod_cfg. This object is an extended dict, containing the settings for each modeling setting. Documentation :py:class:`crtomo.cfg.crmod_config` This class wraps the file-based CRMod configuration file crmod.cfg, which is described here: :ref:`description_crmod_cfg` .. GENERATED FROM PYTHON SOURCE LINES 32-34 .. code-block:: Python print('Type:', type(tdm.crmod_cfg)) .. rst-class:: sphx-glr-script-out .. code-block:: none Type: .. GENERATED FROM PYTHON SOURCE LINES 35-36 Access the settings just as with a normal dict: .. GENERATED FROM PYTHON SOURCE LINES 36-38 .. code-block:: Python print(tdm.crmod_cfg.keys()) .. rst-class:: sphx-glr-script-out .. code-block:: none dict_keys(['mswitch', 'elem', 'elec', 'rho', 'config', 'write_pots', 'pot_file', 'write_volts', 'volt_file', 'write_sens', 'sens_file', 'another_dataset', '2D', 'fictitious_sink', 'sink_node', 'boundary_values', 'boundary_file']) .. GENERATED FROM PYTHON SOURCE LINES 39-40 Note that printing it will print all keys and current settings .. GENERATED FROM PYTHON SOURCE LINES 40-42 .. code-block:: Python print(tdm.crmod_cfg) .. rst-class:: sphx-glr-script-out .. code-block:: none ***FILES*** ! mswitch ../grid/elem.dat ! elem ../grid/elec.dat ! elec ../rho/rho.dat ! rho ../config/config.dat ! config F ! write_pots ../mod/pot/pot.dat ! pot_file T ! write_volts ../mod/volt.dat ! volt_file F ! write_sens ../mod/sens/sens.dat ! sens_file F ! another_dataset 1 ! 2D F ! fictitious_sink 1660 ! sink_node F ! boundary_values boundary.dat ! boundary_file .. GENERATED FROM PYTHON SOURCE LINES 43-44 Examples for setting parameters .. GENERATED FROM PYTHON SOURCE LINES 44-47 .. code-block:: Python tdm.crmod_cfg['write_pots'] = True tdm.crmod_cfg['2D'] = True .. GENERATED FROM PYTHON SOURCE LINES 48-50 CRTomo (inversion) settings are stored in tdm.crtomo_cfg Documentation :py:class:`crtomo.cfg.crtomo_config` .. GENERATED FROM PYTHON SOURCE LINES 50-52 .. code-block:: Python print('Type:', type(tdm.crtomo_cfg)) .. rst-class:: sphx-glr-script-out .. code-block:: none Type: .. GENERATED FROM PYTHON SOURCE LINES 53-54 Access the settings just as with a normal dict: .. GENERATED FROM PYTHON SOURCE LINES 54-56 .. code-block:: Python print(tdm.crtomo_cfg.keys()) .. rst-class:: sphx-glr-script-out .. code-block:: none dict_keys(['mswitch', 'elem', 'elec', 'volt', 'inv_dir', 'prior_model', 'diff_inv', 'iseed_var', 'cells_x', 'cells_z', 'ani_x', 'ani_z', 'max_it', 'dc_inv', 'robust_inv', 'fpi_inv', 'mag_rel', 'mag_abs', 'pha_a1', 'pha_b', 'pha_rel', 'pha_abs', 'hom_bg', 'hom_mag', 'hom_pha', 'another_ds', 'd2_5', 'fic_sink', 'fic_sink_node', 'boundaries', 'boundaries_file', 'mswitch2', 'lambda']) .. GENERATED FROM PYTHON SOURCE LINES 57-58 Note that printing it will print all keys and current settings .. GENERATED FROM PYTHON SOURCE LINES 58-60 .. code-block:: Python print(tdm.crtomo_cfg) .. rst-class:: sphx-glr-script-out .. code-block:: none 1 ! mswitch ../grid/elem.dat ! elem ../grid/elec.dat ! elec ../mod/volt.dat ! volt ../inv ! inv_dir F ! difference inversion? ! diff_inv ! prior_model iseed variance ! iseed_var 0 ! # cells in x-direction ! cells_x 0 ! # cells in z-direction ! cells_z 1.000 ! smoothing parameter in x-direction ! ani_x 1.000 ! smoothing parameter in z-direction ! ani_z 20 ! max. nr of iterations ! max_it F ! DC inversion? ! dc_inv T ! robust inversion? ! robust_inv F ! final phase improvement? ! fpi_inv 5 ! mag_rel 1e-3 ! mag_abs 0 ! pha_a1 0 ! pha_b 0 ! pha_rel 0 ! pha_abs F ! hom_bg 10.00 ! hom_mag 0.00 ! hom_pha F ! another_ds 1 ! d2_5 F ! fic_sink 10000 ! fic_sink_node F ! boundaries boundary.dat ! boundaries_file 1 ! mswitch2 lambda ! lambda .. GENERATED FROM PYTHON SOURCE LINES 61-62 Settings of the mswitch can be set in a simple way .. GENERATED FROM PYTHON SOURCE LINES 62-63 .. code-block:: Python tdm.crtomo_cfg.set_mswitch('res_m', True) .. _sphx_glr_download__examples_02_simple_inversion_plot_01_inversion_settings.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_01_inversion_settings.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_01_inversion_settings.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_01_inversion_settings.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_