pycsamt.agents.occam2d_agent#

pycsamt.agents.occam2d_agent#

Occam2DAgent — Write a complete Occam2D inversion input file set.

Produces four files in the output directory:

OccamDataFile.dat

MT response data in Occam2D format. Written by write().

Occam2DMesh

2-D FD mesh derived from the data geometry. Written by write().

Occam2DModel

Mesh-cell → inversion-parameter mapping. Written by write().

OccamStartup

Starting-model and inversion parameters file. Written by write().

The agent also validates the written files and returns a brief data summary so the user can verify the output before running Occam2D.

Classes

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

Generate a complete Occam2D inversion input file set.

class pycsamt.agents.occam2d_agent.Occam2DAgent(*, api_key=None, model=None, llm_provider='claude', modes=None, error_floor=0.05, target_rms=1.0)[source]#

Bases: BaseAgent

Generate a complete Occam2D inversion input file set.

Parameters:
  • api_key (str)

  • model (str)

  • llm_provider (str)

  • modes (list of str, optional — overrides constructor default) – Occam2D mode codes. Common choices: ["ZXXR","ZXXI","ZXYR","ZXYI","ZYXR","ZYXI","ZYYR","ZYYI"] (all Z), ["RhoZXY","PhsZXY","RhoZYX","PhsZYX"] (ρa/φ off-diagonal). Default: None → OccamData auto-selects from available data.

  • error_floor (float) – Minimum relative error floor applied to all data (default 0.05 = 5 %).

  • target_rms (float) – Target RMS for the startup file (default 1.0).

  • keys (Output data)

  • ----------

  • path (sites /)

  • output_dir (str)

  • period_range ([T_min, T_max], optional)

  • modes

  • title (str, optional)

  • keys

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

  • OccamDataFile.dat (data_path Path —)

  • Occam2DMesh (mesh_path Path —)

  • Occam2DModel (model_path Path —)

  • OccamStartup (startup_path Path —)

  • int (n_data)

  • int

  • int

  • str (output_dir)

Examples

>>> agent  = Occam2DAgent()
>>> result = agent.execute({
...     "path":       "/data/L22PLT",
...     "output_dir": "/out/occam2d",
... })
>>> print(result["data_path"])
/out/occam2d/OccamDataFile.dat
SYSTEM_PROMPT: str = 'You are an expert in 2-D MT inversion setup using Occam2D.\nGiven the data file statistics and mesh parameters, write 3–4 sentences that:\n1. Confirm the data file contains the expected stations and period bands.\n2. Comment on the mesh geometry (cell sizes, depth extent, padding).\n3. Recommend regularisation parameters (roughness penalty, target RMS).\n4. Note any data gaps or stations that should be excluded.\nReply in plain 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