pycsamt.zonge.meas#
pycsamt.zonge.meas
Lightweight, robust containers for measurement columns that appear in Zonge AVG tables. These components follow the new table-centric design (inherit from AVGComponentBase), so they can be fed with a tidy DataFrame and later serialize as small CSV blocks if desired.
Exports#
CompMeas : validator/normaliser for component labels (‘ExHy’, …)
Amps : transmitter current amplitude handler (A)
Both classes keep context columns (‘station’, ‘freq’, ‘comp’) when available, which helps downstream grouping and reshaping.
Classes
- class pycsamt.zonge.meas.CompMeas(data=None, meta=None, *, name=None, verbose=0)[source]#
Bases:
AVGComponentBaseEnumeration/validator for classical CSAMT component labels.
The class guarantees a canonical
compcolumn with allowed values (case-sensitive):{'ExHy','ExHx','EyHy','EyHx'}. A few common case variants are accepted and normalized.Typical usage#
>>> cm = CompMeas.from_avg((df, meta)) >>> cm.unique ['ExHy'] # for a scalar survey with one component
- read(source, meta=None)[source]#
Ensure a normalised
compcolumn exists.If missing, default to ‘ExHy’ (legacy kind-1 style).
If present, normalise values and validate membership.
- Parameters:
data (pd.DataFrame | None)
meta (MutableMapping[str, Any] | None)
name (str | None)
- class pycsamt.zonge.meas.Amps(data=None, meta=None, *, name=None)[source]#
Bases:
AVGComponentBaseTransmitter current amplitude container (unit: A).
The class normalises the
ampscolumn to numeric, tracks a few useful stats, and can (optionally) export itself as a small CSV block. Context columns are preserved.Examples
>>> amps = Amps.from_avg((df, meta)) >>> amps.stats.mean 12.7 >>> ds = amps.to_xarray() # optional grid for convenience
- read(source, meta=None)[source]#
Parse source and populate the
ampscolumn as float.Non-numeric entries (‘*’, blanks) become NaN. Context columns (station/freq/comp) are kept when present.
- class pycsamt.zonge.meas.Frequency(data=None, meta=None, *, name=None)[source]#
Bases:
AVGComponentBaseFrequency axis manager (Hz) for AVG tables.
Goals#
Read from legacy and modern frames (column aliases handled)
Enforce positivity (> 0 Hz) while tolerating missing markers
Offer stable unique grids across stations/components
Provide a compact to_xarray() for downstream use
Notes
Legacy decimals like ‘.5’ are parsed correctly.
Missing values (‘*’, ‘’, None) become NaN and are ignored in summaries. Non-positive numeric entries raise FrequencyError.
- read(source, meta=None, **kws)[source]#
Load frequency values from a tidy frame or a flat vector.
If source is a DataFrame, we try to keep station / comp when present. Otherwise we inject conservative defaults: station=NaN, comp=’ExHy’.
- write()[source]#
Emit a compact CSV block with the contextual columns that we manage (station, freq, comp), suitable for round-tripping.
- unique(*, sort=True, dropna=True, rtol=1e-06, atol=1e-12)[source]#
Unique global frequency grid with tolerance deduplication.