pycsamt.forward.config2d#
Configuration for pyCSAMT 2-D MT forward modelling.
ForwardConfig2D is the configuration object for
MT2DForward. It records every parameter
needed to build a Grid2D and run the
finite-difference solver, and can be exported to Python, JSON, or YAML.
Quick start#
from pycsamt.forward.config2d import ForwardConfig2D
# Write an annotated source-of-truth file
ForwardConfig2D.write_template("my_2d.yml")
# Edit my_2d.yml …
# Load, validate, build grid, run solver
cfg = ForwardConfig2D.from_file("my_2d.yml")
cfg.validate()
grid = cfg.to_grid()
from pycsamt.forward.em2d import MT2DForward
resp = MT2DForward(cfg.freq_grid(), grid).run()
Classes
|
Collect settings for a 2-D MT finite-difference forward run. |
- class pycsamt.forward.config2d.ForwardConfig2D(freq_min=0.001, freq_max=1000.0, n_freqs=20, nx=40, nz=30, x_max=10000.0, z_max=6000.0, n_pad=8, pad_factor=1.3, bg_rho=100.0, model_type='halfspace', anomaly_rho=5.0, anomaly_x_lo=2000.0, anomaly_x_hi=6000.0, anomaly_z_lo=300.0, anomaly_z_hi=1500.0, n_stations=10, station_x_max=None, verbose=True)[source]#
Bases:
objectCollect settings for a 2-D MT finite-difference forward run.
The configuration covers four areas: frequency grid, FD grid geometry, starting earth model, and station layout.
- Parameters:
freq_min (float) – Frequency range [Hz].
freq_max (float) – Frequency range [Hz].
n_freqs (int) – Number of logarithmically spaced frequencies.
nx (int) – Core cell counts (x, z).
nz (int) – Core cell counts (x, z).
x_max (float) – Core region extents [m].
z_max (float) – Core region extents [m].
n_pad (int) – Padding cells per side.
pad_factor (float) – Padding growth factor.
bg_rho (float) – Background resistivity [Ω·m].
model_type ({'halfspace', 'anomaly', 'random'}) – Grid constructor to use.
anomaly_rho (float) – Anomaly resistivity [Ω·m] (model_type=’anomaly’ only).
anomaly_x_lo (float) – Horizontal anomaly bounds [m].
anomaly_x_hi (float) – Horizontal anomaly bounds [m].
anomaly_z_lo (float) – Depth anomaly bounds [m].
anomaly_z_hi (float) – Depth anomaly bounds [m].
n_stations (int) – Number of equally spaced surface stations.
station_x_max (float or None) – Right-most station position [m].
verbose (bool)
Examples
Default halfspace:
>>> cfg = ForwardConfig2D() >>> cfg.model_type 'halfspace' >>> cfg.validate()
Template round-trip:
>>> import tempfile, os >>> with tempfile.NamedTemporaryFile(suffix='.yml', delete=False) as f: ... path = f.name >>> _ = ForwardConfig2D.write_template(path) >>> cfg2 = ForwardConfig2D.from_file(path) >>> os.unlink(path)
- validate()[source]#
Raise
ValueErroron invalid parameter values.- Return type:
None
- to_template(path='forward_config_2d.py', *, fmt=None)[source]#
Write to an annotated source-of-truth file.
- classmethod write_template(path='forward_config_2d.py', *, fmt=None)[source]#
Generate a documented source-of-truth file with default values.
- Parameters:
path (path-like)
fmt ({"py", "json", "yml", "yaml"}, optional)
- Return type:
- classmethod from_file(path, *, strict=True)[source]#
Load from a generated source-of-truth file.
- Parameters:
path (path-like)
strict (bool)
- Return type: