2.15.1.2. pycsamt.transformers.jedi#
Classes
|
Convert a Zonge |
|
Convert a Jones |
- class pycsamt.transformers.jedi.AVGtoEDI[source]
Bases:
TransformerMixinConvert a Zonge
AVGsource to anEDICollection.This transformer orchestrates extraction of transfer functions from a Zonge
AVGobject (or file path), finalizes the neutral payload (TFBundle), and emits EDI objects. The result is always anEDICollection, even for single-site inputs.The pipeline is:
Parse TFs from the AVG using
to_tensor. WhenZis not present, fall back to(rho, phase).Finalize each bundle using
TransformerMixin: validate the station name, order and de-duplicate frequencies, and fill missing parts if enabled by the global config.Materialize
EDIFileobjects and attach site metadata (e.g., coordinates) if available fromavg.topo.frame.
Notes
Station naming obeys the global policy from
pycsamt.core.config.Frequency sorting and de-duplication follow
freq_orderandfreq_tol.If only
(rho, phase)are present,Zcan be reconstructed whencompute_z_from_resis enabled.If
avg.topoexposes a DataFrame-likeframewith columnsstation,latitude,longitudeand optionallyelevation, a>HEADsection is updated.
See also
pycsamt.core._transformers.TransformerMixinProvides finalization steps and overridable hooks.
pycsamt.core.base.TFBundleNeutral, backend-agnostic payload.
pycsamt.seg.edi.EDIFileConcrete EDI object.
pycsamt.seg.collection.EDICollectionCollection wrapper for multiple EDI files.
Examples
>>> from pycsamt.core.transformers import AVGtoEDI >>> # path or AVG object are both accepted >>> # out = AVGtoEDI().transform(\"/path/to/data.avg\")
- compute_z_from_res(b)[source]
Reconstruct
Zfrom apparent resistivity and phase.If a bundle lacks
Zbut holds(rho, phase)and the global config enablescompute_z_from_res, this method builds a complex tensor whose magnitude and angle satisfy the standard MT relations:|Z| = sqrt( μ0 * ω * ρa )phaseis interpreted as milliradians and converted to radians before formingZ = |Z|(cos φ + i sin φ).
- Parameters:
b (TFBundle) – Input bundle with
rhoandphaseset.- Returns:
The same bundle with
zpopulated.- Return type:
Notes
Ensure phase units are consistent. Zonge workflows often store milliradians; the implementation converts by dividing by
1000. If units differ, override this method.References
[AVGtoEDI-compute-z-from-res-1]Simpson, F. & Bahr, K. (2005). Practical MT.
[AVGtoEDI-compute-z-from-res-2]Egbert, G. D. (1997). Robust MT processing.
- extract(source)[source]
Pull the first
TFBundlefrom an AVG object or path.- Parameters:
source (Any) –
AVGinstance or path to an.avgfile.- Returns:
The first available bundle (typically first station).
- Return type:
- Raises:
ValueError – If no transfer functions could be obtained.
Notes
Multi-station inputs are handled by
transform(), which iterates and converts all sites to an EDI collection.
- emit_edi(bundle)[source]
Materialize an
EDIFilefrom a finalized bundle.Populates
Zfields (_freq,_z,_z_err). IfZis missing but(rho, phase)are present, uses the backend method to set resistivity and phase. If tipper data exist, populates tipper arrays and derived attributes.- Parameters:
bundle (TFBundle) – Finalized transfer-function payload.
- Returns:
A concrete EDI object.
- Return type:
Notes
Errors during optional computations are silenced to keep the transformation robust on imperfect field data.
- post_emit(edi_obj, source, bundle)[source]
Attach station metadata and optional location to the EDI.
This step applies the global station naming policy and, if
avg.topo.frameis present, injects coordinates into the>HEADsection.- Parameters:
- Returns:
The updated EDI object.
- Return type:
Notes
When a matching row is found in
topo.frame(based on thestationcolumn), latitude, longitude and elevation are copied if available.
- transform(source, *, name=None, station_id=None)[source]
Convert an AVG source to an
EDICollection.Handles both objects and file paths. All stations found in the source are extracted, finalized, converted to EDI, and collected.
- Parameters:
- Returns:
A collection of
EDIFileobjects, one per site.- Return type:
EDICollection
Examples
>>> from pycsamt.core.transformers import AVGtoEDI >>> # out = AVGtoEDI().transform(\"/path/site.avg\")
- class pycsamt.transformers.jedi.JtoEDI[source]
Bases:
TransformerMixinConvert a Jones
Jsource to EDI or an EDI collection.This transformer ingests a
JFileinstance or a path to a.jfile, extracts transfer functions (Z, tipper, or fallbackrho/phase), finalizes a neutral payload (TFBundle), and emits concreteEDIFileobjects. When given aJCollection, it produces anEDICollection.The pipeline mirrors the AVG workflow:
Extract TF arrays and metadata from the J structure, tolerating variant attribute names often found in legacy files.
Finalize each bundle using the mixin logic: ensure a valid station name, order and de-duplicate frequencies, and fill missing TF parts if configured.
Emit EDI and optionally attach site coordinates if a header-like structure is present on the J side.
Notes
Naming, frequency sorting, and de-duplication follow the global configuration in
pycsamt.core.config.If only
(rho, phase)are present,Zcan be reconstructed when allowed bycompute_z_from_res(via the mixin hook).A
Headorheadobject onJFilewith attributeslat,long, andelevis used to populate the EDI>HEADsection when available.
See also
pycsamt.core._transformers.TransformerMixinFinalization steps and overridable hooks.
pycsamt.core.transformers.AVGtoEDICompanion converter for Zonge AVG.
pycsamt.core.base.TFBundleNeutral payload used across backends.
Examples
>>> from pycsamt.core.transformers import JtoEDI >>> # Single file → EDIFile >>> # edi = JtoEDI().transform(\"/path/site.j\") >>> # Collection → EDICollection >>> # out = JtoEDI().transform(j_collection)
References
[JtoEDI-1]Simpson, F. & Bahr, K. (2005). Practical MT.
[JtoEDI-2]Egbert, G. D. (1997). Robust MT processing.
- extract(source)[source]
Extract a
TFBundlefrom a J file or object.- Parameters:
source (Any) –
JFileinstance or a path to a.jfile.- Returns:
Bundle with TF arrays and basic site info.
- Return type:
- Raises:
ValueError – If no usable transfer functions are present.
Notes
This method does not reorder or de-duplicate; those steps are applied in the finalization phase.
- emit_edi(bundle)[source]
Create an
EDIFilefrom a finalized bundle.Populates impedance arrays when present. If
Zis absent but(rho, phase)are available, the backend call is used to set resistivity/phase onto the EDI structure. Tipper data are also populated when provided.- Parameters:
bundle (TFBundle) – Finalized transfer-function payload.
- Returns:
Concrete EDI object ready for downstream use.
- Return type:
Notes
Optional computations are guarded; failures are ignored to remain robust on imperfect field data.
- post_emit(edi_obj, source, bundle)[source]
Attach naming and optional coordinates to the EDI.
Applies the global station naming policy and, when the J object exposes a
Head/headwithlat,long, andelev, updates the EDI header accordingly.
- transform(source, *, name=None, station_id=None)[source]
Convert a J source to EDI or an EDI collection.
A
JCollectionyields anEDICollectionwith one EDI per member. A singleJFile(or path) yields a singleEDIFile.- Parameters:
- Returns:
EDI materialization corresponding to the input form.
- Return type:
EDIFile or EDICollection
Examples
>>> from pycsamt.core.transformers import JtoEDI >>> # Single file >>> # edi = JtoEDI().transform(\"/data/site.j\") >>> # Collection >>> # out = JtoEDI().transform(j_collection)