2.9.1.10. pycsamt.seg.other#
Classes
|
Reader/writer for generic |
|
Convenience helpers for OTHER sections. |
|
Header container for |
- class pycsamt.seg.other.OtherSECT(*args, verbose=0, logger=None, **kws)[source]
Bases:
EDIComponentBaseHeader container for
>=OTHERSECTblocks.This lightweight container parses the header that opens an Other Data Section as defined by the SEG-EDI spec. It collects canonical options, any extra key/value pairs, and the ordered list of measurement IDs that may follow the options list.
- Parameters:
- Variables:
sectid (str or None) – Section identifier. Often mirrors
DATAID.nchan (int or None) – Number of channels in this section.
nfreq (int or None) – Number of frequencies, if provided.
maxblks (int or None) – Upper bound on the number of data blocks.
ndipole (int or None) – EMAP-style dipole count, if present.
type (str or None) – Free-form type tag found in the wild (e.g.
FREE).extra (dict) – Any unrecognized header keys are stored here.
meas_ids (list of str) – Measurement IDs listed under the header.
start_data_lines_num (int or None) – Absolute line index where the first
>BLOCKbegins.
Notes
Unknown header keys are preserved in
extraso round-tripping does not lose information. Measurement IDs are appended in the order they appear in the file.Examples
>>> hdr = OtherSECT.from_file("site.edi") >>> hdr.sectid 'B1' >>> hdr.meas_ids[:2] ['HX', 'HY'] >>> lines = hdr.write() >>> print("".join(lines).splitlines()[0]) >=OTHERSECT
See also
OtherIORead and write generic
>BLOCKdata.OtherMixinConvenience helpers for host classes.
References
[OtherSECT-1]SEG EDI Standard (MT/EMAP), 1987. MTNet archive.
- class pycsamt.seg.other.OtherIO(*args, verbose=0, logger=None, **kws)[source]
Bases:
EDIComponentBaseReader/writer for generic
>BLOCKdata under OTHERSECT.The class iterates over consecutive
>KEYdata blocks that follow an>=OTHERSECTheader, and stores each as a small record. Numeric rows are collected into_OtherBlock.values. Non-numeric rows are kept in_OtherBlock.raw_linesto preserve content that cannot be parsed as floats.- Parameters:
- Variables:
blocks (list of _OtherBlock) – Parsed data blocks in file order.
- from_file(path, start_line=None, verbose=0, logger=None)[source]
Parse all
>BLOCKentries. Ifstart_lineisNone, the reader seeks the first>OTHERor the line after>=OTHERSECT. RaisesEdIDataErrorwhen no blocks are found.
Notes
Typing strategy. Option values are parsed with a best-effort rule: integers first, then floats, else kept as strings. Numeric table rows are formatted using
FLOAT_FMTand wrapped usingPER_LINE.Examples
>>> hdr = OtherSECT.from_file("site.edi") >>> io = OtherIO.from_file("site.edi", start_line=hdr.start_data_lines_num) >>> [b.keyword for b in io.blocks] ['>COH', '>ANNO'] >>> out = io.write() >>> print(out[0].strip().split()[0]) >COH
See also
OtherSECTHeader that precedes the data blocks.
OtherMixinHelper methods for host classes.
References
[OtherIO-1]SEG EDI Standard (MT/EMAP), 1987. MTNet archive.
- blocks: list[_OtherBlock]
- classmethod from_file(edi_path, start_line=None, *, verbose=0, logger=None)[source]
- class pycsamt.seg.other.OtherMixin[source]
Bases:
objectConvenience helpers for OTHER sections.
This mixin supplies two small facade methods that delegate to
OtherSECTandOtherIO. It lets a host class add simpleread_*helpers without duplicating plumbing.- read_other_blocks(edi_fn, verbose=0, logger=None)[source]
Return an
OtherIObuilt from the same file. The header is read first to locate the data blocks.
Examples
>>> class Host(OtherMixin): ... >>> hdr = Host.read_other_header("site.edi") >>> io = Host.read_other_blocks("site.edi") >>> len(io.blocks) >= 0 True
References
[OtherMixin-1]SEG EDI Standard (MT/EMAP), 1987. MTNet archive.
- classmethod read_other_header(edi_fn, *, verbose=0, logger=None)[source]