pycsamt.seg.other#

Classes

OtherIO(*args[, verbose, logger])

Reader/writer for generic >BLOCK data under OTHERSECT.

OtherMixin()

Convenience helpers for OTHER sections.

OtherSECT(*args[, verbose, logger])

Header container for >=OTHERSECT blocks.

class pycsamt.seg.other.OtherSECT(*args, verbose=0, logger=None, **kws)[source]#

Bases: EDIComponentBase

Header container for >=OTHERSECT blocks.

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:
  • *args (Any) – Unused positional arguments. Present for MRO safety.

  • verbose (int or bool, optional) – Verbosity level. Propagated by EDIComponentBase.

  • logger (object, optional) – Logger instance. If None, a null logger is used.

  • **kws – Field overrides to pre-populate attributes.

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 >BLOCK begins.

from_file(path)[source]#

Parse the first >=OTHERSECT in an EDI file. The file is validated by IsEdi.

Parameters:

edi_path (str)

Return type:

OtherSECT

write()[source]#

Serialize the header back to EDI text lines.

Return type:

list[str]

Notes

Unknown header keys are preserved in extra so 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

OtherIO

Read and write generic >BLOCK data.

OtherMixin

Convenience helpers for host classes.

References

KEY_ORDER: list[str] = ['sectid', 'nchan', 'nfreq', 'maxblks', 'ndipole', 'type']#
classmethod from_file(edi_path)[source]#
Parameters:

edi_path (str)

Return type:

OtherSECT

write()[source]#
Return type:

list[str]

class pycsamt.seg.other.OtherIO(*args, verbose=0, logger=None, **kws)[source]#

Bases: EDIComponentBase

Reader/writer for generic >BLOCK data under OTHERSECT.

The class iterates over consecutive >KEY data blocks that follow an >=OTHERSECT header, and stores each as a small record. Numeric rows are collected into _OtherBlock.values. Non-numeric rows are kept in _OtherBlock.raw_lines to preserve content that cannot be parsed as floats.

Parameters:
  • *args (Any) – Unused positional arguments. Present for MRO safety.

  • verbose (int or bool, optional) – Verbosity level. Propagated by EDIComponentBase.

  • logger (object, optional) – Logger instance. If None, a null logger is used.

  • **kws – Field overrides to pre-populate attributes.

Variables:

blocks (list of _OtherBlock) – Parsed data blocks in file order.

from_file(path, start_line=None, verbose=0, logger=None)[source]#

Parse all >BLOCK entries. If start_line is None, the reader seeks the first >OTHER or the line after >=OTHERSECT. Raises EdIDataError when no blocks are found.

Parameters:
Return type:

OtherIO

write()[source]#

Serialize the parsed blocks to EDI text lines.

Return type:

list[str]

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_FMT and wrapped using PER_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

OtherSECT

Header that precedes the data blocks.

OtherMixin

Helper methods for host classes.

References

blocks: list[_OtherBlock]#
classmethod from_file(edi_path, start_line=None, *, verbose=0, logger=None)[source]#
Parameters:
Return type:

OtherIO

write()[source]#
Return type:

list[str]

class pycsamt.seg.other.OtherMixin[source]#

Bases: object

Convenience helpers for OTHER sections.

This mixin supplies two small facade methods that delegate to OtherSECT and OtherIO. It lets a host class add simple read_* helpers without duplicating plumbing.

read_other_header(edi_fn, verbose=0, logger=None)[source]#

Return a parsed OtherSECT from edi_fn.

Parameters:
Return type:

OtherSECT

read_other_blocks(edi_fn, verbose=0, logger=None)[source]#

Return an OtherIO built from the same file. The header is read first to locate the data blocks.

Parameters:
Return type:

OtherIO

Examples

>>> class Host(OtherMixin): ...
>>> hdr = Host.read_other_header("site.edi")
>>> io = Host.read_other_blocks("site.edi")
>>> len(io.blocks) >= 0
True

See also

OtherSECT, OtherIO

References

classmethod read_other_header(edi_fn, *, verbose=0, logger=None)[source]#
Parameters:
Return type:

OtherSECT

classmethod read_other_blocks(edi_fn, *, verbose=0, logger=None)[source]#
Parameters:
Return type:

OtherIO