pycsamt.seg.ops#
Functions
|
Return (f, y) where y is amplitude or PSD. |
|
Magnitude-squared coherency γ^2. |
|
Estimate 1-sigma uncertainties for the impedance tensor and, optionally, the tipper at a single frequency. |
|
Estimate effective DoF (independent averages) from per-frequency metadata. |
Pack Hermitian NxN into upper-triangular vector. |
|
|
Build Z from ρ, φ, and freq (per component). |
|
Rotate 2x2 impedance per freq: Z' = R Z R^T. |
|
Rotate cross-power matrix: C' = R C Rᵀ (per freq). |
|
Rotate tipper horizontal vector(s): t' = R t. |
|
Synthesize a full Hermitian cross–spectral tensor from an impedance tensor |
|
Evenly spaced time vector [s] from N and Δt. |
|
Diagonal σ estimate for tipper components. |
|
Unpack upper-triangular vector into Hermitian matrix. |
|
Diagonal σ estimate for Z components from spectral blocks. |
|
Component-wise apparent resistivity and phase from Z. |
- pycsamt.seg.ops.rotate_impedance(z, theta_deg)[source]#
Rotate 2x2 impedance per freq: Z’ = R Z R^T.
- Shapes supported:
z: (nfreq, 2, 2) or (2, 2)
theta: scalar or (nfreq,)
- pycsamt.seg.ops.rotate_tipper(t, theta_deg)[source]#
Rotate tipper horizontal vector(s): t’ = R t.
- Accepts:
t: (nfreq, 2) or (nfreq, 1, 2) or (2,)
theta: scalar or (nfreq,)
- pycsamt.seg.ops.z_to_rho_phi(z, freq, *, mu0=1.2566370614359173e-06)[source]#
Component-wise apparent resistivity and phase from Z.
ρ = |Z|^2 / (μ0 ω) ; φ = atan2(Im(Z), Re(Z)) [deg]
- pycsamt.seg.ops.rho_phi_to_z(rho, phi_deg, freq, *, mu0=1.2566370614359173e-06)[source]#
Build Z from ρ, φ, and freq (per component).
- pycsamt.seg.ops.pack_hermitian(C)[source]#
Pack Hermitian NxN into upper-triangular vector.
Output length = N*(N+1)/2, complex dtype preserved.
- pycsamt.seg.ops.unpack_hermitian(v, n)[source]#
Unpack upper-triangular vector into Hermitian matrix.
- pycsamt.seg.ops.rotate_spectra(C, theta_deg)[source]#
Rotate cross-power matrix: C’ = R C Rᵀ (per freq).
- pycsamt.seg.ops.amp_or_psd(x, fs, *, mode='amp')[source]#
Return (f, y) where y is amplitude or PSD.
- pycsamt.seg.ops.synthesize_spectra_from_z(Z, *, S_HH=None, H_psd=None, tipper=None, include_hz=False, chan_order=('HX', 'HY', 'EX', 'EY'), e_noise=None, h_noise=None)[source]#
Synthesize a full Hermitian cross–spectral tensor from an impedance tensor
Z(f)and optional tipper.Given electric–magnetic relation
E = Z H, blocks are:S_EH = Z S_HHS_EE = Z S_HH Z^H
If a horizontal tipper
T(TX, TY) is supplied and HZ is requested, additional blocks are:S_ZH = T S_HH,S_ZZ = T S_HH T^HS_EZ = Z S_HH T^H
If magnetic spectra are not provided, a unit–power model is used (
S_HH = I). The result is explicitly symmetrized to be Hermitian.- Parameters:
Z (ndarray) – Impedance per frequency. Shape
(n, 2, 2)or(2, 2). If 2–D, it is broadcast to one frequency.S_HH (ndarray, optional) – Magnetic spectra per frequency, shape
(n, 2, 2). Must be Hermitian. OverridesH_psdif both are given.H_psd (tuple of ndarray, optional) –
(Pxx, Pyy, Pxy)wherePxx, Pyyare real(n,)andPxyis optional complex(n,). Used to assembleS_HHwhen it is not supplied.tipper (ndarray, optional) – Horizontal tipper as
(n, 1, 2)or(n, 2). Required wheninclude_hzisTrueor when"HZ"is inchan_order.include_hz (bool, default False) – If
True, add HZ and its cross–terms. Requirestipper.chan_order (tuple of str, optional) – Channel order of the output spectra. Defaults to
("HX","HY","EX","EY"). Include"HZ"to place the vertical magnetic channel.e_noise (float or ndarray, optional) – Diagonal noise power added to the electric block
S_EE. Scalar or lengthn.h_noise (float or ndarray, optional) – Diagonal noise power added to the magnetic block
S_HH. Scalar or lengthn.
- Returns:
Sfull (ndarray) – Cross–spectral tensor, shape
(n, m, m), complex, Hermitian.m = len(chan_order).chan_ids (list of str) – Channel names in the order used for
Sfull.
- Raises:
ValueError – If shapes are incompatible, the tipper is missing when HZ is requested, or dimensions do not match.
- Return type:
Notes
Absolute scaling of spectra depends on
S_HH. If neitherS_HHnorH_psdis provided, the unit– power model is used. This is convenient for tests and structure checks, but does not preserve physical power.The function enforces Hermitian symmetry by conjugating off–diagonal blocks and real–ifying the diagonal.
Examples
Minimal, unit–power synthesis:
>>> S, order = synthesize_spectra_from_z(Z_arr)
With magnetic PSDs and tipper, including HZ:
>>> Pxx = np.full(n, 1e-2) >>> Pyy = np.full(n, 1e-2) >>> S, order = synthesize_spectra_from_z( ... Z_arr, ... H_psd=(Pxx, Pyy, None), ... tipper=T_arr, # (n,1,2) or (n,2) ... include_hz=True, ... chan_order=("HX","HY","HZ","EX","EY"), ... )
See also
spectra_from_ZBuilds a
Spectrausing this tensor.Spectra.from_ZClass method wrapper returning a spectra object.
Spectra.to_ZInverse operation (spectra → transfer functions).
References