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")
>>> , f, st = p.to_tensor(var="phase")

Classes

Phase([data, meta, name, verbose])

Impedance phase (\(\varphi\)) per component.

Resistivity([data, meta, name, verbose])

Apparent resistivity (\(\rho_a\)) per component.

class pycsamt.zonge.resphase.Resistivity(data=None, meta=None, *, name=None, verbose=False)[source]#

Bases: TensorBase

Apparent 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

VAR_NAME: str = 'rho'#
UNIT_ATTR: str = 'Unit.Rho'#
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').

Parameters:
Return type:

None

write(*, float_fmt='%.6g', na_rep='')[source]#

Serialise to a compact CSV block with a small meta preamble (units + timestamp).

Parameters:
  • float_fmt (str)

  • na_rep (str)

Return type:

Sequence[str]

to_xarray(*, coords=('station', 'freq', 'comp'), attrs=None)[source]#

Convert to an xarray.Dataset with one data variable (rho). Attributes include a stable unit hint under Unit.Rho.

Parameters:
Parameters:
class pycsamt.zonge.resphase.Phase(data=None, meta=None, *, name=None, verbose=False)[source]#

Bases: TensorBase

Impedance phase (\(\varphi\)) per component.

This class manages the impedance phase data, inheriting from TensorBase to 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 the convert_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:
  • VAR_NAME (str) – The canonical column name used in the internal frame ("phase").

  • UNIT_ATTR (str) – The dataset attribute key used for storing units ("Unit.Phase").

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

Resistivity

Manages apparent resistivity data.

TensorBase

The base class providing

VAR_NAME: str = 'phase'#
UNIT_ATTR: str = 'Unit.Phase'#
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.Phase defaults to 'mrad'.

Parameters:
Return type:

None

write(*, float_fmt='%.6g', na_rep='')[source]#

Serialise to a compact CSV block with a meta preamble carrying Unit.Phase and a UTC timestamp.

Parameters:
  • float_fmt (str)

  • na_rep (str)

Return type:

Sequence[str]

to_xarray(*, coords=('station', 'freq', 'comp'), attrs=None)[source]#

Convert to an xarray.Dataset with one data variable (phase). Attributes include a stable unit hint under Unit.Phase.

Parameters:
convert_unit(target='mrad')[source]#

Convert the phase values in place between \(\mathrm{mrad}\) and \(\mathrm{deg}\) and update Unit.Phase in :pyattr:`meta`.

\[1~\mathrm{mrad} = \frac{180}{\pi \cdot 1000}~\mathrm{deg}\]
Parameters:

target (str)

Return type:

None