2.13.2.4. pycsamt.stratagem.qc#

stratagem.qc#

Quality-control and frequency-filtering classes for Stratagem AMT surveys.

QualityController

Station-level QC: builds a per-station report (SNR, fraction of good frequencies, phase-tensor skew) and flags stations that fall below configurable thresholds. Optionally enriches the report with hardware-level stack counts from a StratagemRawReader.

FrequencyFilter

Frequency-level editing: removes incoherent, low-SNR, or out-of-band frequency bins. When a StratagemRawReader is supplied, hardware-measured zero-stack rows are also masked before any statistical criteria are applied.

Both classes delegate their core algorithms to pycsamt.emtools.qc, pycsamt.emtools.frequency, and pycsamt.emtools.remove_noise — they add only the Stratagem-specific wiring (hardware mask alignment, station-index mapping, result persistence).

Classes

FrequencyFilter(*[, fmin, fmax, snr_thresh, ...])

Remove bad frequency bins from Stratagem AMT data.

QualityController(*[, min_frac_ok, ...])

Station-level quality-control report for Stratagem AMT surveys.

class pycsamt.stratagem.qc.FrequencyFilter(*, fmin=None, fmax=None, snr_thresh=2.5, min_frac=0.4, use_hardware_mask=True, verbose=0)[source]

Bases: PyCSAMTObject

Remove bad frequency bins from Stratagem AMT data.

Combines three filtering strategies that are applied in order:

  1. Hardware mask (optional) — zero-stack rows from raw Stratagem files are masked before any statistical analysis. Requires a fitted StratagemRawReader.

  2. Band selection — frequencies outside [fmin, fmax] are dropped.

  3. Incoherent-frequency mask — frequencies that fail the SNR threshold across more than (1 - min_frac) of stations are masked.

All masking is performed in-place on the EDIFile.Z.z arrays of the supplied objects. Use copy=True in fit() to avoid mutating the originals.

Parameters:
  • fmin (float, optional) – Lower frequency bound (Hz). Default: no lower bound.

  • fmax (float, optional) – Upper frequency bound (Hz). Default: no upper bound.

  • snr_thresh (float, default 2.5) – Per-station SNR threshold for incoherent-frequency masking.

  • min_frac (float, default 0.4) – Minimum fraction of stations that must pass snr_thresh for a frequency to be retained.

  • use_hardware_mask (bool, default True) – When a raw_reader is given to fit(), apply the hardware SNR mask.

  • verbose (int, default 0)

Variables:
  • edi_objects (list of EDIFile) – Filtered EDI objects (in-place modified unless copy=True).

  • n_masked_hw (int) – Number of (station, frequency) pairs masked by hardware SNR.

  • n_masked_stat (int) – Number masked by the statistical incoherence criterion.

  • n_dropped_band (int) – Number of frequency rows removed by band selection.

Examples

>>> filt = FrequencyFilter(fmin=10.0, fmax=10000.0)
>>> filt.fit(inj.edi_objects_, raw_reader=rdr)
FrequencyFilter(fmin=10.0, fmax=10000.0, ...)
>>> paths = filt.out("2/2EDIF")
fit(edi_objects, raw_reader=None, *, copy=False)[source]

Apply frequency filters.

Parameters:
  • edi_objects (list of EDIFile)

  • raw_reader (StratagemRawReader, optional) – Provides hardware SNR masks aligned to station order.

  • copy (bool, default False) – When True, deep-copies the Z data of each EDIFile before masking so the originals are not mutated.

Return type:

self

out(savepath=None, *, overwrite=False)[source]

Write filtered EDI files to disk or return objects.

Parameters:
  • savepath (path-like, optional) – Output directory. When None, returns the list of filtered EDIFile objects instead of writing to disk.

  • overwrite (bool, default False)

Return type:

list of EDIFile (when savepath is None) or list of Path

class pycsamt.stratagem.qc.QualityController(*, min_frac_ok=0.6, min_snr_med=2.0, max_skew_med=6.0, include_skew=True, verbose=0)[source]

Bases: PyCSAMTObject, MetadataMixin

Station-level quality-control report for Stratagem AMT surveys.

Wraps build_qc_table() and qc_flags() with optional hardware-level enrichment from a StratagemRawReader.

Parameters:
  • min_frac_ok (float, default 0.6) – Minimum fraction of valid (non-NaN) impedance rows; stations below this are flagged low_coverage.

  • min_snr_med (float, default 2.0) – Minimum median SNR; stations below this are flagged low_snr.

  • max_skew_med (float, default 6.0) – Maximum median absolute phase-tensor skew angle (°); stations exceeding this are flagged high_skew.

  • include_skew (bool, default True) – Include phase-tensor skew in the report. Requires a valid impedance tensor.

  • verbose (int, default 0)

Variables:
  • report (pandas.DataFrame) – Per-station QC metrics. Columns: station, n_freq, n_ok, frac_ok, snr_med, pmin, pmax, and (when include_skew=True) skew_med, skew_iqr. When a StratagemRawReader is supplied to fit(), three additional columns are appended: hw_freqs, hw_usable_freqs, hw_coverage.

  • flags (pandas.DataFrame) – Per-station flag strings in the flags column.

Examples

>>> from pycsamt.stratagem import EDIBatch, CoordinateInjector
>>> from pycsamt.stratagem.qc import QualityController
>>> batch = EDIBatch("2/2EDI").fit()
>>> inj = CoordinateInjector(epsg=32649).fit(batch, "2.csv")
>>> qc = QualityController().fit(inj.edi_objects_)
>>> qc.report_.head()
>>> qc.summary()
fit(edi_objects, raw_reader=None)[source]

Build the QC report.

Parameters:
  • edi_objects (list of EDIFile) – Stations to assess. Typically from edi_objects_ or edi_objects_.

  • raw_reader (StratagemRawReader, optional) – When supplied, hardware stack counts and SNR masks are joined into report_ as extra columns hw_freqs, hw_usable_freqs, and hw_coverage.

Return type:

self

summary()[source]

Return a compact text summary of the QC results.

Return type:

str

flagged_stations()[source]

Return station names with at least one QC flag.

Return type:

list of str