pycsamt.inversion.backends.simpeg#
SimPEG backend for physics-based EM inversion.
SimPEG is optional and imported only when this backend is selected. The backend wraps SimPEG’s natural-source electromagnetic API for MT, AMT, and CSAMT inversion. It supports 1-D soundings, stitched station-by-station 2-D profiles, and a 3-D primary-secondary natural-source path when the installed SimPEG version exposes the required classes.
The model parameter is log conductivity on SimPEG mesh cells. PyCSAMT converts
user-facing layered resistivity starting models into log-conductivity cells,
runs the inversion, and converts recovered models back to resistivity-oriented
InversionResult payloads.
Classes
|
Run optional SimPEG natural-source EM inversions. |
- class pycsamt.inversion.backends.simpeg.SimPEGBackend(config)[source]#
Bases:
BaseInversionBackendRun optional SimPEG natural-source EM inversions.
SimPEGBackendadapts PyCSAMT’s inversion configuration objects to SimPEG’s natural-source electromagnetic machinery. It is intended for users who want a physics-backed inversion engine while keeping the samepycsamt.inversion.workflow.InversionWorkflowandpycsamt.inversion.results.InversionResultAPI used by the built-in and external backends.The backend supports MT, AMT, and CSAMT. One-dimensional runs use
Simulation1DElectricField. Two-dimensional runs are stitched station-by-station 1-D inversions, not full 2-D SimPEG EM inversion. Three- dimensional runs useSimulation3DPrimarySecondarywith plane-wave natural- source survey objects when available in the installed SimPEG version.- Parameters:
config (pycsamt.inversion.config.InversionConfig) – Inversion configuration. Important fields are
method,dimension,data,starting_model,reference_model,regularization,max_iter,tol,error_floor,phase_error,backend_options,workdir, andmetadata.- Variables:
Notes
The inversion model is log conductivity, \(m = \log(\sigma)\), on SimPEG mesh cells. Starting and recovered models exposed through PyCSAMT are resistivity oriented. For 1-D output, recovered cell conductivities are compressed back into a layered
pycsamt.inversion.model.StartingModel. For 3-D output, the result storesrho_3das linear resistivity.backend_optionscan contain:meshcontrolsOptions consumed by
pycsamt.inversion.mesh.build_1d_tensor_mesh()andpycsamt.inversion.mesh.build_3d_tensor_mesh(), such as core cell widths, padding, depth extent, and station padding.max_iter_lsMaximum line-search iterations passed to
optimization.InexactGaussNewton.beta0,estimate_beta,beta0_ratioInitial trade-off and beta-estimation controls.
target_chifactTarget misfit directive chi factor.
cooling_factorandcooling_rateBeta schedule directive controls.
sigma_primaryBackground conductivity for 3-D primary-secondary simulation.
reference_modelCell-sized reference model. Positive values are treated as resistivity and converted to log conductivity; otherwise values are assumed already in the SimPEG model domain.
alpha_yOptional y-direction smoothness weight for 3-D regularization.
Examples
Run a 1-D MT sounding directly through the backend:
>>> from pycsamt.inversion.backends.simpeg import SimPEGBackend >>> from pycsamt.inversion.config import InversionConfig >>> cfg = InversionConfig( ... method="mt", ... dimension="1d", ... backend="simpeg", ... data={"freqs": [1.0, 10.0], ... "rho_a": [100.0, 120.0], ... "phase": [45.0, 47.0]}, ... max_iter=8, ... ) >>> result = SimPEGBackend(cfg).run()
Run a stitched 2-D AMT profile through the high-level workflow:
>>> from pycsamt.inversion.workflow import run_inversion >>> result = run_inversion( ... method="amt", ... dimension="2d", ... backend="simpeg", ... data={"freqs": [10.0, 100.0], ... "rho_a": [[80.0, 100.0], [90.0, 110.0]], ... "phase": [[42.0, 45.0], [43.0, 46.0]], ... "station_x": [0.0, 250.0], ... "station_names": ["A01", "A02"]}, ... max_iter=6, ... ) >>> result.metadata["profile_mode"] 'stitched_station_1d'
Configure a small 3-D natural-source run:
>>> from pycsamt.inversion.workflow import run_inversion >>> result = run_inversion( ... method="mt", ... dimension="3d", ... backend="simpeg", ... data={"freqs": [1.0], ... "rho_a": [[100.0], [120.0]], ... "phase": [[45.0], [47.0]], ... "station_x": [0.0, 500.0], ... "station_names": ["M01", "M02"], ... "metadata": {"station_y": [0.0, 250.0]}}, ... backend_options={ ... "sigma_primary": 0.01, ... "beta0": 1.0, ... "target_chifact": 1.0, ... }, ... max_iter=4, ... )
Pass SimPEG directive and optimization controls:
>>> from pycsamt.inversion.workflow import run_inversion >>> result = run_inversion( ... method="csamt", ... dimension="1d", ... backend="simpeg", ... data={"freqs": [1.0, 10.0], "rho_a": [100.0, 120.0]}, ... backend_options={ ... "estimate_beta": True, ... "beta0_ratio": 2.0, ... "cooling_factor": 2.0, ... "cooling_rate": 1, ... "max_iter_ls": 10, ... }, ... )
See also
pycsamt.inversion.workflow.InversionWorkflowHigh-level entry point that instantiates this backend.
pycsamt.inversion.backends.builtin.Builtin1DBackendDependency-light fallback backend.
pycsamt.inversion.backends.pygimli.PyGIMLiBackendOptional pyGIMLi backend for 1-D EM inversions.
pycsamt.inversion.mesh.build_1d_tensor_meshMesh helper used by the 1-D SimPEG path.
pycsamt.inversion.mesh.build_3d_tensor_meshMesh helper used by the 3-D SimPEG path.
pycsamt.inversion.results.InversionResultBackend-neutral result returned by
run().
References
- name = 'simpeg'#
- supports: tuple[tuple[str, str], ...] = (('mt', '1d'), ('mt', '2d'), ('mt', '3d'), ('amt', '1d'), ('amt', '2d'), ('amt', '3d'), ('csamt', '1d'), ('csamt', '2d'), ('csamt', '3d'))#
- run(data=None)[source]#
Run a SimPEG natural-source EM inversion.
- Parameters:
data (mapping, object, sequence, or path-like, optional) – Optional data override for this call. When omitted, the backend uses
self.config.data. Values are coerced throughpycsamt.inversion.data.EMData.- Returns:
Backend-neutral result. For 1-D runs,
modelis a recoveredpycsamt.inversion.model.StartingModel. For stitched 2-D runs,modelis a dictionary containingrho_2dand profile coordinates. For 3-D runs,modelcontainsrho_3dandx_centers,y_centers, andz_centersarrays.- Return type:
- Raises:
ImportError – If SimPEG or discretize is not installed.
ValueError – If data do not contain frequencies plus apparent resistivity and/or phase.
NotImplementedError – If the configured method/dimension pair is unsupported by this backend or by the installed SimPEG natural-source API.
Examples
>>> from pycsamt.inversion.backends.simpeg import SimPEGBackend >>> from pycsamt.inversion.config import InversionConfig >>> cfg = InversionConfig( ... method="mt", ... dimension="1d", ... backend="simpeg", ... data={"freqs": [1.0, 10.0], ... "rho_a": [100.0, 120.0], ... "phase": [45.0, 47.0]}, ... max_iter=8, ... ) >>> result = SimPEGBackend(cfg).run()