pycsamt.seg.mtemap#
Classes
|
Lightweight view of EMAP/MT component IDs. |
Thin facade that lets a host class load an |
|
|
Minimal header container for |
- class pycsamt.seg.mtemap.MTEMAP(mt_or_emap_section_list=None, verbose=0, logger=None, **kwargs)[source]#
Bases:
EDIComponentBaseMinimal header container for
>=MTSECTand>=EMAPSECTblocks.The class stores option key-values from the section header. It keeps measurement IDs as strings to avoid loss of formatting (e.g.
"251.025"). Count fields are parsed as integers where possible.Notes
If
SECTIDis missing or looks numeric, the value from>HEAD/DATAIDis used as a fallback.Presence of
NDIPOLEorTYPEmarks the block as EMAP when writing.NFREQin the header should match the number of items in the following>FREQblock [1].The class does not validate that the referenced measurement IDs exist. That is handled elsewhere.
- Variables:
sectid (str or None) – Section identifier. May be replaced by
DATAIDwhen numeric or missing.nfreq (int or None) – Number of frequencies expected in the section.
maxblks (int or None) – Optional maximum count of data blocks.
ey (ex,) – Electric measurement IDs. May be absent.
ry (rx,) – Reference measurement IDs. May be absent.
ndipole (int or None) – EMAP dipole count. Presence implies EMAP.
type (str or None) – Optional EMAP type tag.
chksum (int or None) – Optional checksum reported by some writers.
start_data_lines_num (int or None) – Index in the source file where data blocks start.
temp_sectid (str or None) – Internal cache of
DATAIDused for fallback.
- Parameters:
See also
EMAPComponentsSmall container exposing only component IDs.
EMAPMixinThin facade to build an
MTEMAPfrom a file.
References
Examples
Parse a header from an EDI file and write it back:
from pycsamt.seg.mtemap import MTEMAP m = MTEMAP.from_file("site.edi") lines = m.write() print("".join(lines))
- KEY_ORDER: list[str] = ['sectid', 'nfreq', 'maxblks', 'hx', 'hy', 'hz', 'ex', 'ey', 'rx', 'ry', 'ndipole', 'type', 'chksum']#
- classmethod from_file(edi_path)[source]#
Build an instance from an EDI path. The file is first validated, then the header lines between the section tag and the next block are parsed.
- Parameters:
edi_path (str) – Path to a readable EDI file.
- Returns:
Parsed header object.
- Return type:
- Raises:
FileNotFoundError – If the path does not point to a file.
EdIDataError – If no
>=MTSECTor>=EMAPSECTis found.
Notes
The method also caches
DATAIDfrom>HEADand uses it to replace a numeric or missingSECTID. This helps with writers that output numeric section labels.Examples
>>> m = MTEMAP.from_file("site.edi") >>> m.sectid 'SITE_A'
- read(mt_or_emap_section_list=None)[source]#
Parse key-value tokens into attributes.
- Parameters:
mt_or_emap_section_list (list of str, optional) – Items like
["NFREQ=60", "HX=251.025"]. If omitted, the list passed at construction is used.- Returns:
The instance itself, for chaining.
- Return type:
Notes
Unknown keys are ignored. Values are normalized by stripping quotes and whitespace. Integer fields are parsed with a best-effort cast.
- write(nfreq=None)[source]#
Serialize the header to text lines.
- Parameters:
nfreq (int, optional) – Override for
NFREQin the output.- Returns:
Lines including the opening section tag.
- Return type:
Notes
If either
NDIPOLEorTYPEis present the opening tag is>=EMAPSECT. Otherwise>=MTSECTis used. For EMAP, the fieldsEX,EYandHZare omitted by convention.
- class pycsamt.seg.mtemap.EMAPComponents(*args, verbose=0, logger=None, **kws)[source]#
Bases:
EDIComponentBaseLightweight view of EMAP/MT component IDs.
The container exposes only component identifiers and does not include section counts or metadata. It is useful when you need the mapping from channel type to measurement ID without other header details.
- Variables:
- Parameters:
Notes
The class does not normalize or validate that the IDs exist in the
>=DEFINEMEASblock. It simply carries the strings.See also
MTEMAPFull section header with counts and flags.
Examples
Create from an existing
MTEMAP:m = MTEMAP.from_file("site.edi") comp = EMAPComponents.from_mtemap(m) comp.as_dict()
- class pycsamt.seg.mtemap.EMAPMixin[source]#
Bases:
objectThin facade that lets a host class load an
MTEMAPwith a consistent API.Attach this mixin to any class that should expose a
from_fileconstructor returning anMTEMAP. The mixin does not keep state; it only forwards the call.See also
MTEMAP.from_fileThe underlying constructor that performs parsing.
Examples
Add the mixin and use it on a host type:
class Host(EMAPMixin): pass hdr = Host.from_file("site.edi") assert hdr.nfreq is not None