pycsamt.agents.static_shift#

pycsamt.agents.static_shift#

StaticShiftAgent — Detect and correct galvanic static shift.

Wraps pycsamt.emtools.ss:

Supported methods: "ama" (default), "loess", "refmedian", "bilateral".

Classes

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

Detect and correct galvanic static shift in MT/AMT data.

class pycsamt.agents.static_shift.StaticShiftAgent(*, api_key=None, model=None, llm_provider='claude', method='ama', half_window=3, pband=None, inplace=False)[source]#

Bases: BaseAgent

Detect and correct galvanic static shift in MT/AMT data.

Parameters:
  • api_key (str)

  • model (str)

  • llm_provider (str)

  • method (str, optional — overrides constructor default) – Correction algorithm. Default "ama" (adaptive moving average).

  • half_window (int) – Spatial half-window for AMA / LOESS smoothing.

  • pband ((T_min, T_max) or None) – Period band used to estimate shift factors.

  • inplace (bool) – Modify the input Sites in-place. Default False (returns a copy).

  • keys (Output data)

  • ----------

  • path (sites /)

  • method

  • output_dir (str, optional)

  • keys

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

  • removed (corrected_sites Sites with static shift)

  • {station (shift_factors dict)

  • before (rho_before ndarray (n_freq × n_sta) — log₁₀ ρa)

  • after (rho_after ndarray — log₁₀ ρa)

  • magnitude (delta_stats dict — min/max/mean shift)

  • objects (figures dict — matplotlib Figure)

  • paths (figure_paths dict — saved file)

Examples

>>> agent  = StaticShiftAgent(method="ama")
>>> result = agent.execute({"path": "/data/L22PLT",
...                         "output_dir": "/out/ss"})
>>> result["delta_stats"]
{'mean': 0.18, 'max': 0.42, 'n_shifted': 7}
SYSTEM_PROMPT: str = 'You are an expert in galvanic distortion and static-shift correction for magnetotelluric data.\nGiven a static-shift correction summary, write 3–4 sentences that:\n1. State whether significant static shift was detected.\n2. Identify stations with the largest corrections and their magnitude.\n3. Assess whether the correction method was appropriate for this dataset.\n4. Recommend any follow-up action (e.g., additional spatial filtering).\nReply in plain English. No bullet points or 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