pycsamt.agents.inv2d_agent#
pycsamt.agents.inv2d_agent#
Inv2DAgent — U-Net based 2-D MT profile inversion.
Wraps EMInverter2D:
Assembles a 2-D pseudosection image from the observed Sites (station × frequency × impedance component) as the U-Net input.
Generates a matching synthetic 2-D training dataset by tiling 1-D forward models into profile-shaped arrays.
Trains the U-Net and produces a resistivity section output: (n_depth × n_stations) in log₁₀ Ω·m.
Visualises the result with
plot_inversion_result_2d().
The U-Net treats the whole profile at once, so it naturally captures lateral continuity — a key advantage over station-by-station 1-D inversion.
Requires PyTorch or TensorFlow.
Classes
|
2-D MT profile inversion using a U-Net convolutional architecture. |
- class pycsamt.agents.inv2d_agent.Inv2DAgent(*, api_key=None, model=None, llm_provider='claude', n_depth=40, n_freqs=32, n_components=4, arch='unet', n_train_profiles=200, n_stations_per_profile=20, epochs=30)[source]#
Bases:
BaseAgent2-D MT profile inversion using a U-Net convolutional architecture.
- Parameters:
api_key (str)
model (str)
llm_provider (str)
n_depth (int) – Number of depth cells in the output section (default 40).
n_freqs (int) – Number of input frequencies (default 32).
n_components (int) – Number of impedance components in input (default 4: Re/Im × xy/yx).
arch (str) – U-Net variant (default
"unet").n_train_profiles (int) – Number of synthetic 2-D profiles for training (default 200).
n_stations_per_profile (int) – Stations per synthetic profile (default 20).
epochs (int) – Training epochs (default 30).
keys (Output data)
----------
path (sites /)
output_dir (str, optional)
period_range ([T_min, T_max], optional)
keys
----------------
ρ (pred_section ndarray (n_depth × n_stations) — log₁₀)
(km) (depths_km ndarray — depth axis)
list[str] (station_names)
float (rms_global)
EMInverter2D (inverter)
dict (figure_paths)
dict
- SYSTEM_PROMPT: str = 'You are an expert in 2-D MT inversion using deep learning (U-Net architecture).\nGiven a 2-D AI inversion result, write 4-5 sentences that:\n1. Describe the input pseudosection geometry (stations × frequencies).\n2. Interpret the dominant structural features in the resistivity section.\n3. Assess lateral continuity and compare to classical smoothness-constrained results.\n4. Identify artefacts or stations with poor convergence.\n5. Recommend follow-up (regularisation, 3-D verification, drilling targets).\nReply in plain scientific English.\n'#
Override in subclasses to give the LLM its domain expertise.
- execute(input_data)[source]#
Run this agent on input_data and return an
AgentResult.Subclasses must implement this method. The contract:
Reset
self._last_cost = 0.0at the top.Record wall-clock time with
t0 = time.time().Return
AgentResult(elapsed_seconds=time.time()-t0, cost_estimate_usd=self._last_cost, ...).
- Parameters:
- Return type: