2.13.2.4. pycsamt.stratagem.qc#
stratagem.qc#
Quality-control and frequency-filtering classes for Stratagem AMT surveys.
QualityControllerStation-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.FrequencyFilterFrequency-level editing: removes incoherent, low-SNR, or out-of-band frequency bins. When a
StratagemRawReaderis 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
|
Remove bad frequency bins from Stratagem AMT data. |
|
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:
PyCSAMTObjectRemove bad frequency bins from Stratagem AMT data.
Combines three filtering strategies that are applied in order:
Hardware mask (optional) — zero-stack rows from raw Stratagem files are masked before any statistical analysis. Requires a fitted
StratagemRawReader.Band selection — frequencies outside
[fmin, fmax]are dropped.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.zarrays of the supplied objects. Usecopy=Trueinfit()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_threshfor a frequency to be retained.use_hardware_mask (bool, default True) – When a
raw_readeris given tofit(), 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:
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.
- 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,MetadataMixinStation-level quality-control report for Stratagem AMT surveys.
Wraps
build_qc_table()andqc_flags()with optional hardware-level enrichment from aStratagemRawReader.- 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 (wheninclude_skew=True)skew_med,skew_iqr. When aStratagemRawReaderis supplied tofit(), three additional columns are appended:hw_freqs,hw_usable_freqs,hw_coverage.flags (pandas.DataFrame) – Per-station flag strings in the
flagscolumn.
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_oredi_objects_.raw_reader (StratagemRawReader, optional) – When supplied, hardware stack counts and SNR masks are joined into
report_as extra columnshw_freqs,hw_usable_freqs, andhw_coverage.
- Return type:
self