2.13.2.6. pycsamt.stratagem.survey#
stratagem.survey#
End-to-end Stratagem AMT survey processing pipeline.
StratagemSurvey replaces the legacy watex-based
stratagem_edi_process_script.py with a single composable class that
covers the full post-acquisition workflow:
WinGLink EDI directory
↓ EDIBatch load & natural-sort
↓ CoordinateInjector inject GPS coords from CSV / XLS / XLSX
↓ QualityController per-station QC report (optional)
↓ StaticShiftCorrector AMA static-shift removal
↓ FrequencyFilter band select + incoherent-freq masking
↓ NoiseRemover powerline notch + Hampel + smoothing
↓ export() write corrected EDIs
↓ rename() standardise filenames (T2.000.edi …)
Every processing step is optional and chainable. The pipeline stores intermediate objects as attributes so individual results are always accessible.
Usage example#
Replicate the old stratagem_edi_process_script.py in four lines:
>>> from pycsamt.stratagem import StratagemSurvey
>>> sv = StratagemSurvey(
... edi_dir="2/2EDI",
... coord_file="2.csv",
... raw_dir="原始数据/2HX",
... epsg=32649,
... ).fit()
>>> sv.remove_static_shift().remove_noises().drop_frequencies(fmin=10.0)
>>> sv.export("2/2EDIP").rename(basename="T2.", dst_path="2/renamedEDIs")
Module Attributes
|
a WinGLink export directory (uses Stratagem's own natural 3-digit sort), or anything the conventional |
Classes
|
End-to-end Stratagem AMT survey processing pipeline. |
- class pycsamt.stratagem.survey.StratagemSurvey(edi_dir, coord_file, *, raw_dir=None, epsg=32649, utm_zone='49N', coordinate_system='utm', order='auto', drop_stations=None, easting_col=None, northing_col=None, elev_col='elev', station_col='stations', read_kwargs=None, verbose=0)[source]
Bases:
PyCSAMTObject,MetadataMixinEnd-to-end Stratagem AMT survey processing pipeline.
- Parameters:
edi_dir (path-like, Sites, or sequence of EDIFile) – Directory of WinGLink-exported EDI files (uses Stratagem’s own natural 3-digit sort via
EDIBatch), or an already-loadedSites/EDICollection/ list ofEDIFile— normalised throughensure_sites(), the same entry point the rest ofpycsamt.emtoolsuses. In the latter casebatch_staysNone(there’s no directory to report) and ordering is whatever the source already has.coord_file (path-like) – GPS coordinate table (CSV / XLS / XLSX).
raw_dir (path-like, optional) – Directory of raw Stratagem hardware files (
X*.NNN, …). When supplied, hardware SNR masks are used in QC and frequency filtering.epsg (int, default 32649) – EPSG code of the projected CRS of coord_file. Use
32649(UTM Zone 49N WGS84) for the standard south-China survey area.utm_zone (str, default
'49N') – UTM zone string forproject_point_utm2llwhen epsg is not sufficient.coordinate_system (str, default
'utm')order (str, default
'auto') – Station-to-GPS row ordering forStationLocator.drop_stations (list of int, optional) – 0-based indices into the loaded
EDIBatchto exclude before coordinate injection — e.g. a calibration/test shot that isn’t a real profile position and has no matching row in coord_file.easting_col (str, optional) – Column names in coord_file for the projected E-W / N-S coordinates. Forwarded to
fit(). Required whenever coord_file has more than two numeric columns besides elev_col — auto-detection raises rather than guessing in that case (seepycsamt.stratagem.gis_correct).northing_col (str, optional) – Column names in coord_file for the projected E-W / N-S coordinates. Forwarded to
fit(). Required whenever coord_file has more than two numeric columns besides elev_col — auto-detection raises rather than guessing in that case (seepycsamt.stratagem.gis_correct).elev_col (str, default
'elev')station_col (str, default
'stations')read_kwargs (dict, optional) – Extra keyword arguments forwarded to the coord_file reader.
verbose (int, default 0)
- Variables:
batch (EDIBatch or None) – Loaded EDI collection when edi_dir was a directory path;
Nonewhen edi_dir was already aSites/list of EDIFile.raw_reader (StratagemRawReader or None) – Hardware file reader (None when raw_dir not supplied).
injector (CoordinateInjector) – Coordinate-injected EDI wrapper.
qc (QualityController or None) – QC report (populated after
run_qc()).edi_objects (list of EDIFile) – Current working set of EDI objects. Modified in-place by each processing step.
Examples
Full pipeline, one fluent expression:
>>> sv = ( ... StratagemSurvey( ... edi_dir="2/2EDI", ... coord_file="2.csv", ... raw_dir="原始数据/2HX", ... epsg=32649, ... ) ... .fit() ... .run_qc() ... .remove_static_shift() ... .drop_frequencies(fmin=10.0) ... .remove_noises() ... .export("2/2EDIP") ... .rename(basename="T2.", dst_path="2/renamedEDIs") ... ) >>> print(sv.qc_.summary())
- fit()[source]
Load EDIs, optional raw files, and inject GPS coordinates.
This is the only mandatory step. All processing methods (
remove_static_shift(),drop_frequencies(), etc.) must be called afterfit().- Return type:
self
- run_qc(*, min_frac_ok=0.6, min_snr_med=2.0, max_skew_med=6.0, include_skew=True)[source]
Run the station-level QC report.
Results stored in
qc_. Does not modifyZdata.
- remove_static_shift(*, sort_by='lon', half_window=3, weights='tri', pband=None, max_skew=6.0)[source]
Apply AMA static-shift correction.
Important
Call this before
drop_frequencies()to ensure the full frequency range is available for spatial averaging.
- drop_frequencies(*, fmin=None, fmax=None, snr_thresh=2.5, min_frac=0.4, use_hardware_mask=True)[source]
Filter frequency bands and mask incoherent bins.
- Parameters:
fmin (float, optional) – Frequency band limits in Hz.
fmax (float, optional) – Frequency band limits in Hz.
snr_thresh (float) – Per-station SNR threshold for incoherence masking.
min_frac (float) – Minimum fraction of stations that must pass snr_thresh.
use_hardware_mask (bool) – Apply hardware SNR mask when raw files were loaded.
- Return type:
self
- remove_noises(*, mains_hz=50.0, n_harm=30, tol_hz=0.08, notch_mode='interp', hampel_win=3, hampel_nsig=3.0, smooth=False, smooth_win=3)[source]
Apply powerline notch + Hampel outlier + optional smoothing.
- export(savepath, *, dataid_prefix=None, overwrite=False)[source]
Write the current
edi_objects_to savepath.
- rename(basename, dst_path, *, zero_pad=3, trailer='', overwrite=False, source=None)[source]
Rename EDI files with a standardised basename.
- Parameters:
basename (str) – Filename prefix, e.g.
'T2.'→T2.000.edi.dst_path (path-like) – Output directory for renamed files.
zero_pad (int, default 3)
trailer (str, default
'')overwrite (bool, default False)
source (path-like, optional) – Source directory or list. Defaults to the directory written by the most recent
export()call; falls back to the currentedi_objects_.
- Return type:
self
- property coordinate_frame[source]
DataFrame of WGS84 coordinates (requires
fit()).
- property sites_: Sites[source]
Current
edi_objects_wrapped as aSites.A fresh view built on every access, so it always reflects the current pipeline state (post-QC, post-static-shift, etc.). This is the interop point with the conventional
pycsamt.emtools/pycsamt.sitestack — e.g. usesv.sites_.write(outdir)for the generic{station}.ediwriter instead of Stratagem’s ownexport()/rename()(which additionally handle DATAID prefixing and Stratagem’s zero-padded naming convention).Examples
>>> sv.sites_.write("out_dir", exist_ok=True)