pycsamt.agents.inv3d_agent#
pycsamt.agents.inv3d_agent#
Inv3DAgent — Graph-convolutional 3-D MT spatial inversion.
Wraps GCNInverter3D:
Represents the survey network as a spatial graph whose edges connect stations within a configurable radius. Spectral GCN message-passing propagates information between neighbouring stations so the resulting 3-D resistivity volume is spatially coherent — artefacts from station-by-station 1-D inversion are suppressed.
Trains on synthetic 3-D profiles assembled by tiling independent 1-D forward models across a virtual station grid, then predicts on the observed
Sitesdataset.Outputs log₁₀ρ per depth layer and log₁₀h per interface for every station, giving a full layered earth model that can be gridded into a 3-D resistivity volume.
Optionally runs MC-dropout uncertainty (
n_mcstochastic passes) to produce depth-resolved confidence maps alongside the main prediction.
Requires PyTorch or TensorFlow.
Architecture#
GCNNet — spectral graph convolutional network
(Kipf & Welling 2017). No external graph library is required.
References
Classes
|
3-D MT profile inversion using a graph-convolutional network (GCN). |
- class pycsamt.agents.inv3d_agent.Inv3DAgent(*, api_key=None, model=None, llm_provider='claude', n_layers=5, n_freqs=32, n_train_profiles=150, epochs=30, radius=5000.0, hidden=(256, 128, 64), dropout=0.1, n_mc=20)[source]#
Bases:
BaseAgent3-D MT profile inversion using a graph-convolutional network (GCN).
- Parameters:
api_key (str)
model (str)
llm_provider (str)
n_layers (int) – Number of depth layers per station (default 5).
n_freqs (int) – Number of frequencies used for feature extraction (default 32).
n_train_profiles (int) – Number of synthetic 3-D training profiles (default 150).
epochs (int) – Training epochs (default 30).
radius (float) – Maximum inter-station edge distance in metres for the adjacency graph (default 5 000 m). Stations farther apart than radius are disconnected in the graph.
hidden (tuple of int) – GCN hidden-layer sizes (default (256, 128, 64)).
dropout (float) – Dropout probability (default 0.1); also used for MC uncertainty.
n_mc (int) – Number of Monte-Carlo dropout passes for uncertainty estimation. Set to 0 to skip uncertainty (faster, default 20).
keys (Output data)
----------
path (sites /)
coords (ndarray (n_stations, 2), optional — station (x, y) in metres.) – Auto-extracted from EDI lat/lon when absent.
adjacency (ndarray (n_stations, n_stations), optional — pre-computed) – normalised adjacency; overrides radius when supplied.
output_dir (str, optional)
period_range ([T_min, T_max], optional)
keys
----------------
(n_sta (adjacency ndarray)
log₁₀ρ (n_layers) —)
(n_sta
(metres) (n_layers-1) — log₁₀h)
(n_sta
std (n_layers) or None — MC-dropout)
(km) (depths_km ndarray — depth axis at station midpoints)
list[str] (station_names)
(n_sta
metres (2) —)
(n_sta
n_sta)
float (rms_global)
GCNInverter3D (inverter)
dict (figure_paths)
dict
Examples
>>> agent = Inv3DAgent(n_layers=5, epochs=20, n_mc=10) >>> result = agent.execute({ ... "path": "/data/WILLY_EDIs", ... "output_dir": "/out/inv3d", ... }) >>> result["rms_global"] 0.28
- SYSTEM_PROMPT: str = 'You are an expert in 3-D MT inversion using graph-convolutional deep learning.\nGiven a GCN-based 3-D inversion result, write 4-5 sentences that:\n1. Describe the survey geometry (station count, spatial extent, adjacency radius).\n2. Interpret the dominant 3-D resistivity structures and their spatial continuity.\n3. Assess prediction quality (RMS, depth range) relative to station spacing.\n4. Compare the GCN spatial result to independent 1-D predictions where possible.\n5. Recommend geological follow-up and areas with highest uncertainty.\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: