2.6.3.1. pycsamt.emtf.converters.edi#

Explicit conversion between SEG EDI and the format-neutral EMTF model.

This module is deliberately an adapter. It does not make EDIFile the scientific core and it does not move rotation mathematics into parsing. The bridge preserves the historical pyCSAMT Z.z_err convention while representing EDI *.VAR blocks explicitly as EMTF complex variances.

Functions

edi_to_emtf(source, *[, prefer_spectra, ...])

Convert a historical SEG EDI object/path into EMTF.

emtf_to_edi(document, *[, on_loss])

Convert EMTF into an in-memory historical EDIFile.

write_edi(obj, target, *[, on_loss, ...])

Write an EMTF or EDIFile to an exact filesystem target.

Exceptions

DataLossWarning

Warning emitted when an EDI conversion cannot preserve information.

EMTFEDIConversionError

Raised when an EDI conversion would be scientifically invalid.

exception pycsamt.emtf.converters.edi.DataLossWarning[source]

Bases: UserWarning

Warning emitted when an EDI conversion cannot preserve information.

exception pycsamt.emtf.converters.edi.EMTFEDIConversionError[source]

Bases: ValueError

Raised when an EDI conversion would be scientifically invalid.

pycsamt.emtf.converters.edi.edi_to_emtf(source, *, prefer_spectra=True, spectra_nfreq_policy='raise', spectra_missing_policy='raise', spectra_avgt_policy='raise')[source]

Convert a historical SEG EDI object/path into EMTF.

EDI SPECTRA are preferred when present because they retain enough cross-power information to recover the full inverse-signal and residual covariance matrices. Set prefer_spectra=False to force the historical impedance/tipper blocks.

Notes

pyCSAMT historically stores Z.z_err = sqrt(EDI complex variance). The non-SPECTRA path therefore reconstructs EMTF VAR as z_err**2 exactly, preserving the EDI file’s complex-variance convention without redefining the public Z.z_err API. The standard error of a real or imaginary component, when needed statistically, is sqrt(VAR / 2).

Parameters:
  • source (Any)

  • prefer_spectra (bool)

  • spectra_nfreq_policy (str)

  • spectra_missing_policy (str)

  • spectra_avgt_policy (str)

Return type:

EMTF

pycsamt.emtf.converters.edi.emtf_to_edi(document, *, on_loss='warn')[source]

Convert EMTF into an in-memory historical EDIFile.

The standard EDI representation used here stores impedance/tipper and component variances. Rich covariance matrices, arbitrary TF types, and several EMTF metadata blocks have no lossless destination; on_loss controls whether those reductions warn, raise, or are explicitly ignored.

Parameters:
Return type:

Any

pycsamt.emtf.converters.edi.write_edi(obj, target, *, on_loss='warn', preserve_zero=True, stamp_headers=False, force_tipper=None, **kwargs)[source]

Write an EMTF or EDIFile to an exact filesystem target.

Existing EDIFile.write() behavior remains unchanged by default. This neutral adapter opts into preserve_zero=True so finite physical zeros are not turned into the EDI missing-value sentinel during format conversion; NaN/Inf values are still serialized as the sentinel.

Parameters:
Return type:

Path