pycsamt.zonge.resphase#
Scalar apparent-field estimates: Resistivity and Phase.
Both classes inherit from TensorBase so their values can
be rearranged into 2×2 tensor-like grids per frequency (and per
station), according to the component label found in the table
(e.g., ExHy goes to slot (0, 1)).
They accept modern CSAVGW-like tables and common legacy aliases (AMTAVG/MTEdit). Minimal metadata (units) is preserved and written back in a compact CSV block.
Usage#
>>> r = Resistivity.from_avg((df, meta))
>>> Z, f, st = r.to_tensor(var="rho", align="union")
>>> ds = r.to_xarray()
>>> p = Phase.from_avg((df, meta))
>>> p.convert_unit("deg")
>>> Zφ, f, st = p.to_tensor(var="phase")
Classes
|
Impedance phase (\(\varphi\)) per component. |
|
Apparent resistivity (\(\rho_a\)) per component. |
- class pycsamt.zonge.resphase.Resistivity(data=None, meta=None, *, name=None, verbose=False)[source]#
Bases:
TensorBaseApparent resistivity (\(\rho_a\)) per component.
This is a scalar variable (one number per row), but the class inherits the tensor-alignment logic so values land in the appropriate \(2\times 2\) slot given by
comp.Recognized source columns (legacy + modern)#
ARes.mag(modern)Resistivity(legacy tables)rho/Rho/ares.mag(variants)
Canonical internal column:
'rho'.- ivar VAR_NAME:
Canonical column in :pyattr:`frame` (
"rho").- vartype VAR_NAME:
str
- ivar ALIASES:
Ordered alias list used during
read().- vartype ALIASES:
tuple[str, …]
- ivar UNIT_ATTR:
Dataset attribute used for units (
"Unit.Rho").- vartype UNIT_ATTR:
str
- read(source, meta=None, **kws)[source]#
Parse source and produce a compact frame with
station, freq, comp, rho. Coordinates are injected conservatively when absent (station=NaN,comp='ExHy').
- class pycsamt.zonge.resphase.Phase(data=None, meta=None, *, name=None, verbose=False)[source]#
Bases:
TensorBaseImpedance phase (\(\varphi\)) per component.
This class manages the impedance phase data, inheriting from
TensorBaseto allow its scalar values to be aligned into a \(2 \times 2\) tensor-like grid based on the component label.Notes
Values are typically reported in milliradians in modern CSAVGW tables (
Unit.Phase='mrad'). Use theconvert_unit()method to switch to degrees when desired.The internal canonical column name for phase data is
phase.Recognized source columns:
Z.phz(modern)Phase(legacy)phase,ZPHZ(common variants)
- Variables:
- Parameters:
Examples
>>> from pycsamt.zonge import Phase >>> import pandas as pd >>> data = {"freq": [1024], "phase": [1000]} >>> p = Phase() >>> p.read(pd.DataFrame(data)) >>> p.frame['phase'].iloc[0] 1000.0 >>> p.convert_unit("deg") >>> p.frame['phase'].iloc[0] 57.2957...
See also
ResistivityManages apparent resistivity data.
TensorBaseThe base class providing
- read(source, meta=None, **kws)[source]#
Parse source and produce a compact frame with
station, freq, comp, phase. Coordinates are injected conservatively when absent (station=NaN,comp='ExHy').Unit.Phasedefaults to'mrad'.
- write(*, float_fmt='%.6g', na_rep='')[source]#
Serialise to a compact CSV block with a meta preamble carrying
Unit.Phaseand a UTC timestamp.
- to_xarray(*, coords=('station', 'freq', 'comp'), attrs=None)[source]#
Convert to an
xarray.Datasetwith one data variable (phase). Attributes include a stable unit hint underUnit.Phase.
- convert_unit(target='mrad')[source]#
Convert the phase values in place between \(\mathrm{mrad}\) and \(\mathrm{deg}\) and update
Unit.Phasein :pyattr:`meta`.\[1~\mathrm{mrad} = \frac{180}{\pi \cdot 1000}~\mathrm{deg}\]- Parameters:
target (str)
- Return type:
None