pycsamt.agents.modem_agent#
pycsamt.agents.modem_agent#
ModEmAgent — Write a ModEM3D inversion data file.
Wraps ModEmData:
from_edi()— build data object from any EDI source.write()— write the ModEM-format data file.
The ModEM data file format stores MT impedances in the standardised ModEM3D block format that the ModEM Fortran binary reads directly.
Classes
|
Write a ModEM3D MT data file from EDI sources. |
- class pycsamt.agents.modem_agent.ModEmAgent(*, api_key=None, model=None, llm_provider='claude', component_types=None, error_floor=0.05)[source]#
Bases:
BaseAgentWrite a ModEM3D MT data file from EDI sources.
- Parameters:
api_key (str)
model (str)
llm_provider (str)
component_types (list, optional) – Impedance components to include. E.g.
["Full_Impedance", "Full_Vertical_Components"]. Default:None→ ModEmData auto-selects.error_floor (float, optional) – Minimum relative error floor (default 0.05 = 5 %).
keys (Output data)
----------
path (sites /)
output_dir (str)
period_range ([T_min, T_max], optional)
component_types
error_floor
keys
----------------
file (ctrl_path Path or None — inversion-control)
m0.rho) (model_path Path or None — starting model (m0.ws /)
runs) (cov_path Path or None — covariance file (3-D)
file
int (n_periods)
int
str (output_dir)
Examples
>>> agent = ModEmAgent() >>> result = agent.execute({ ... "path": "/data/WILLY_DATA", ... "output_dir": "/out/modem", ... }) >>> print(result["data_path"]) /out/modem/ModEM_Data.dat
- SYSTEM_PROMPT: str = 'You are an expert in 3-D MT inversion setup using ModEM3D.\nGiven a ModEM data file summary, write 3–4 sentences that:\n1. Confirm the data contains the expected stations, periods, and components.\n2. Recommend an initial model (background resistivity, layer structure).\n3. Suggest suitable covariance parameters (smoothing length, roughness).\n4. Flag any data issues that could cause convergence problems.\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.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: