pycsamt.agents.qc#
pycsamt.agents.qc#
DataQCAgent — MT data quality control and frequency editing.
Wraps pycsamt.emtools.qc:
build_qc_table()— per-station metricsqc_flags()— pass / fail flagsfrequency_confidence_table()— per-frequency scoresplot_frequency_confidence_psection()— section figureplot_confidence_profile()— profile figurestation_confidence_table()— per-station confidence
Output figures use PYCSAMT_SECTION so they are
consistent with all other pycsamt plots.
Classes
|
Run data quality control on a MT/AMT dataset. |
- class pycsamt.agents.qc.DataQCAgent(*, api_key=None, model=None, llm_provider='claude', method='composite', min_frac_ok=0.6, min_snr_med=2.0, max_skew_med=6.0)[source]#
Bases:
BaseAgentRun data quality control on a MT/AMT dataset.
- Parameters:
api_key (str) – LLM configuration (optional).
model (str) – LLM configuration (optional).
llm_provider (str) – LLM configuration (optional).
method (str) – Confidence scoring method:
"composite"(default),"presence","snr", or"spatial".min_frac_ok (float) – Minimum fraction of OK frequencies for a station to pass (0–1).
min_snr_med (float) – Minimum median SNR for a station to pass.
max_skew_med (float) – Maximum median |β| skewness for a station to pass.
keys (Output data)
----------
sites (Sites or
path: str) – EDI data to assess.output_dir (str, optional) – Where to save QC figures.
period_range ([T_min, T_max], optional) – Restrict QC to this period window.
keys
----------------
metrics (qc_table pandas DataFrame — per-station)
station (flags pandas DataFrame — pass / fail per)
scores (confidence_table pandas DataFrame — per-station confidence)
confidence (freq_conf_table pandas DataFrame — per-frequency)
int (n_flagged)
list[str] (flagged_stations)
objects (figures dict — matplotlib Figure)
set) (figure_paths dict — saved file paths (when output_dir)
Examples
>>> agent = DataQCAgent() >>> result = agent.execute({"path": "/data/L22PLT", ... "output_dir": "/out/qc"}) >>> result["n_flagged"] 2 >>> result["figures"]["confidence_section"] <Figure …>
- SYSTEM_PROMPT: str = 'You are an expert MT/AMT/CSAMT data quality analyst for pycsamt v2.\nGiven a survey QC summary, write 3–4 sentences that:\n1. State the overall data quality (good / moderate / poor).\n2. Identify specific stations or frequency bands that need attention.\n3. Explain the likely cause (instrument noise, EM interference, near-field).\n4. Recommend the most important next processing step.\nReply in plain English. No bullet points, no markdown headings.\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: