pycsamt.agents.interpretation#

pycsamt.agents.interpretation#

InterpretationAgent — Translate a resistivity model into geology.

This agent is primarily LLM-driven: it takes the resistivity model output (from inversion or forward modelling) plus optional geological context and uses the LLM to write a formation-level interpretation. It also maps standard resistivity ranges to lithology classes (after Keller 1988 / Palacky 1987) as a rule-based fallback when no LLM key is available.

Functions

resistivity_to_lithology(rho)

Return a likely lithological description for a resistivity value (Ω·m).

Classes

InterpretationAgent(*[, api_key, model, ...])

Interpret a resistivity model in terms of geological formations.

class pycsamt.agents.interpretation.InterpretationAgent(*, api_key=None, model=None, llm_provider='claude', context='')[source]#

Bases: BaseAgent

Interpret a resistivity model in terms of geological formations.

Parameters:
  • api_key (str)

  • model (dict or LayeredModel)

  • llm_provider (str)

  • context (str, optional — overrides constructor default) – Optional geological context passed to the LLM (e.g. "Semi-arid Precambrian terrain, looking for aquifers").

  • keys (Output data)

  • ----------

  • model{"resistivities": [...], "thicknesses": [...]}

  • rms (float, optional)

  • context

  • path (sites /)

  • output_dir (str, optional)

  • keys

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

  • dict (layer_interpretations list of)

  • str (dominant_lithology)

  • str

  • list[float] (formation_depths_m)

SYSTEM_PROMPT: str = 'You are an expert hydrogeologist and applied geophysicist specialising in electrical resistivity interpretation.\nGiven a 1-D or 2-D resistivity model from MT/AMT inversion, write a geological interpretation that:\n1. Identifies the likely lithological units (e.g. weathered zone, basement,\n   aquifer, clay layer) based on resistivity ranges.\n2. Estimates formation depths and thicknesses.\n3. Discusses implications for groundwater, mineral exploration, or hazard\n   assessment depending on the survey context.\n4. States uncertainties and what additional data would reduce them.\nReply in plain scientific English, 5–8 sentences. No bullet points.\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