pycsamt.agents.loader#

pycsamt.agents.loader#

MTLoaderAgent — Load MT/AMT/CSAMT data into a pycsamt Sites object.

Accepts any input supported by ensure_sites():

  • A single EDI file path.

  • A directory of EDI / AVG / J files.

  • A list of file paths.

  • An existing Sites or EDICollection.

After loading the agent runs a per-station quality scan and returns:

  • data["sites"] — the Sites object.

  • data["station_names"] — ordered list of station names.

  • data["n_stations"] — total station count.

  • data["quality_table"]pandas.DataFrame with per-station scores.

  • data["summary_stats"] — dict of survey-level statistics.

The quality table columns:

Column

Meaning

station

Station name

has_z

Whether the Z impedance tensor is present

has_tipper

Whether the Tipper block is present

has_coords

Whether lat / lon coordinates are available

n_freq

Number of frequencies with finite Z

t_min_s

Shortest available period (s)

t_max_s

Longest available period (s)

snr_proxy

Median |Zxy| / std(|Zxy|) across frequencies (proxy)

qc_score

Integer 0–100 composite quality score

Classes

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

Load MT data from any pycsamt-supported format and assess quality.

class pycsamt.agents.loader.MTLoaderAgent(*, api_key=None, model=None, llm_provider='claude', recursive=True, on_dup='replace')[source]#

Bases: BaseAgent

Load MT data from any pycsamt-supported format and assess quality.

Parameters:
  • api_key (str or None)

  • model (str)

  • llm_provider (str)

  • recursive (bool) – When loading a directory, recurse into sub-directories.

  • on_dup (str) – Duplicate-station handling: "replace" (default) or "skip".

Examples

>>> agent = MTLoaderAgent()
>>> result = agent.execute({"path": "/data/AMT/WILLY_DATA/L22PLT"})
>>> result.status
'success'
>>> result["n_stations"]
25
>>> result["quality_table"].head()
     station  has_z  ...  qc_score
0  22-22BF    True  ...        88
SYSTEM_PROMPT: str = 'You are an expert MT/AMT/CSAMT data quality analyst.\nGiven a per-station data quality summary, write 2–3 concise sentences that:\n1. State the overall data quality.\n2. Flag any stations or frequency ranges that need attention.\n3. Recommend the next processing step.\nReply in plain English no bullet points, no markdown.\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