Gegularization decouplings 1ΒΆ

import crtomo
import numpy as np
from shapely.geometry import Polygon

Define the electrode positions and boundaries See Creating meshes with the mesh_gen object for more information.

electrodes = np.array((
    (0, 0),
    (1, 0),
    (2, 0),
    (3, 0),
    (4, 0),
    (5, 0),
    (6, 0),
))
boundaries = np.array((
    (-1, 0, 12),
    (0, 0, 12),
    (1, 0, 12),
    (2, 0, 12),
    (3, 0, 12),
    (4, 0, 12),
    (5, 0, 12),
    (6, 0, 12),
    (7, 0, 12),
    (7, -2, 11),
    (-1, -2, 11),
))

Additionally, we define one extra line (x0, y0, x1, y1):

extra_lines = [
    [-0, -0.20, 3, -0.45],
]

# Throws error: TODO
# poly1 = Polygon((
#    (0, 0.0),
#    (5, -0.75),
#    (5, -3),
#    (0, -3),
#    #(-2, 0),
# ))
poly1 = Polygon((
    (0, -0.20),
    (3, -0.45),
    (3, -2),
    (-1, -2),
))

"""
mesh_d = crtomo.mesh_gen.gen_mesh(
    boundaries,
    electrodes,
    # vertical line shoudl not start on horizontal line
    # additional_lines=extra_lines,
    # polygons=[poly1],
    char_lengths=[0.25, 0.5, 0.5, 0.5],
)
"""

Generate the mesh

mesh_d, _ = crtomo.mesh_gen.gen_mesh_with_polygons(
    boundaries,
    electrodes,
    # vertical line should not start on horizontal line
    # additional_lines=extra_lines,
    polygons=[poly1],
    char_lengths=[0.15, 0.25, 0.25, 0.25],

)

print(mesh_d)
mesh_d.plot_grid()
plot 12 decouplings 1
fix_extra_lines
Second fix
fix_extra_lines
Second fix
Calling the mesh generation routines...
   done
This grid was sorted using CutMcK. The nodes were resorted!
Triangular grid found
CRMod/CTRomo grid instance
number of elements: 898
number of nodes: 501
number of electrodes: 7
mesh dimensions:
X: -1.0 7.0
Z: -2.0 0.0
plot 12 decouplings 1
Deleting configurations:
[]
tdm.crtomo_cfg['robust_inv'] = 'F'
tdm.add_to_decouplings(decouplings)

tdm.invert(cores=4, catch_output=True)
Attempting inversion in directory: /tmp/tmpouvx_cm_
Using binary: /home/runner/.virtualenvs/crtomo/bin/CRTomo
Calling CRTomo
Inversion attempt finished
Attempting to import the results
Reading inversion results
is robust False
Info: res_m.diag not found: /tmp/tmpouvx_cm_/inv/res_m.diag
/home/runner/work/crtomo_tools/crtomo_tools/examples/02_simple_inversion
Info: ata.diag not found: /tmp/tmpouvx_cm_/inv/ata.diag
/home/runner/work/crtomo_tools/crtomo_tools/examples/02_simple_inversion
Statistics of last iteration:
iteration                4
main_iteration           4
it_type              DC/IP
type                  main
dataRMS               2.17
magRMS                2.17
phaRMS                 NaN
lambda               91.99
roughness            5.433
cgsteps                8.0
nrdata               209.0
steplength           0.001
stepsize          0.000582
l1ratio                NaN
Name: 19, dtype: object
plot 12 decouplings 1

Gallery generated by Sphinx-Gallery