Note
Go to the end to download the full example code.
Setting modeling and inversion settingsΒΆ
This example discusses details of settings various settings for modeling or inversion using the single-frequency tdManager
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
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)
This grid was sorted using CutMcK. The nodes were resorted!
Triangular grid found
Forward modeling settings are stored in tdm.crmod_cfg. This object is an
extended dict, containing the settings for each modeling setting.
Documentation crtomo.cfg.crmod_config
This class wraps the file-based CRMod configuration file crmod.cfg, which is
described here: crmod.cfg
print('Type:', type(tdm.crmod_cfg))
Type: <class 'crtomo.cfg.crmod_config'>
Access the settings just as with a normal dict:
print(tdm.crmod_cfg.keys())
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'])
Note that printing it will print all keys and current settings
print(tdm.crmod_cfg)
***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
Examples for setting parameters
tdm.crmod_cfg['write_pots'] = True
tdm.crmod_cfg['2D'] = True
CRTomo (inversion) settings are stored in tdm.crtomo_cfg
Documentation crtomo.cfg.crtomo_config
print('Type:', type(tdm.crtomo_cfg))
Type: <class 'crtomo.cfg.crtomo_config'>
Access the settings just as with a normal dict:
print(tdm.crtomo_cfg.keys())
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'])
Note that printing it will print all keys and current settings
print(tdm.crtomo_cfg)
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
Settings of the mswitch can be set in a simple way
tdm.crtomo_cfg.set_mswitch('res_m', True)