pycsamt.agents.inversion_prep#

pycsamt.agents.inversion_prep#

InversionPrepAgent — Prepare Occam2D / ModEM data files.

Phase 2 stub: validates the Sites object and writes inversion-ready data files in the requested format. Full Occam2D write support uses pycsamt’s existing model writers; ModEM is planned for Phase 3.

Classes

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

Prepare MT data files for 2-D / 3-D inversion codes.

class pycsamt.agents.inversion_prep.InversionPrepAgent(*, api_key=None, model=None, llm_provider='claude', code='occam2d', error_floor=0.05)[source]#

Bases: BaseAgent

Prepare MT data files for 2-D / 3-D inversion codes.

Currently supported output formats#

  • "occam2d" — Occam2D DataFile format

  • "modem" — ModEM3D data file (Phase 3)

Input keys#

sites / path : Sites or str code : str — "occam2d" (default) or "modem" period_range : [T_min, T_max], optional component : str — "xy", "yx", or "both" error_floor : float — minimum relative error floor (default 0.05) output_dir : str

Output data keys#

data_file_path str — path to the written data file n_periods int n_stations int code str

SYSTEM_PROMPT: str = 'You are an expert MT inversion specialist.\nGiven a dataset summary and chosen inversion code, recommend:\n1. Appropriate period band and error floor.\n2. Mesh geometry (cell sizes, padding, depth extent).\n3. Regularisation starting values.\n4. Any pre-processing steps still needed before inversion.\nReply in 4–5 sentences, 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

Parameters:
  • api_key (str | None)

  • model (str | None)

  • llm_provider (str)

  • code (str)

  • error_floor (float)