pycsamt.agents.inversion_comparison#

pycsamt.agents.inversion_comparison#

InversionComparisonAgent — Side-by-side comparison of two inversion results.

Compares any two resistivity sections — e.g. AI-predicted vs Occam2D, before/after regularisation change, or two different stations profiles — and produces:

  • A difference section (A − B) in log₁₀(Ω·m).

  • Pearson correlation coefficient ρ between the two sections.

  • RMSE between log₁₀ρ values.

  • An LLM narrative describing which model fits better and where the two differ geologically.

Classes

InversionComparisonAgent(*[, api_key, ...])

Compare two resistivity inversion results.

class pycsamt.agents.inversion_comparison.InversionComparisonAgent(*, api_key=None, model=None, llm_provider='claude')[source]#

Bases: BaseAgent

Compare two resistivity inversion results.

Each result is either an AgentResult from an inversion agent, or a plain dict with keys pred_rho and depths_km.

Parameters:
  • api_key (str)

  • model (str)

  • llm_provider (str)

  • keys (Output data)

  • ----------

  • result_a (AgentResult or dict) – First model. Must contain "pred_rho" (n_stations × n_layers) or "predictions" dict {station: log₁₀ρ array}.

  • result_b (AgentResult or dict) – Second model. Same structure as result_a.

  • label_a (str — name for result_a (default "Model A"))

  • label_b (str — name for result_b (default "Model B"))

  • depths_km (ndarray, optional — shared depth axis (km))

  • station_names (list[str], optional)

  • output_dir (str, optional)

  • keys

  • ----------------

  • sections (correlation float — Pearson ρ between log₁₀ρ)

  • log₁₀(Ω·m) (rmse float — RMSE in)

  • (n_layers (difference ndarray)

  • B (n_stations) — A −)

  • str (label_b)

  • str

  • dict (figure_paths)

  • dict

SYSTEM_PROMPT: str = 'You are an expert in MT inversion model evaluation and comparison.\nGiven two inversion results, write 4-5 sentences that:\n1. State the overall similarity (correlation, RMSE) between the two models.\n2. Identify depth ranges or stations where the two models disagree most.\n3. Discuss which model is more physically plausible and why.\n4. Recommend which result to use for geological interpretation.\n5. Suggest additional constraints (e.g. borehole, gravity) to discriminate them.\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.0 at the top.

  • Record wall-clock time with t0 = time.time().

  • Return AgentResult(elapsed_seconds=time.time()-t0, cost_estimate_usd=self._last_cost, ...).

Parameters:

input_data (dict[str, Any])

Return type:

AgentResult