2.9.1.16. pycsamt.seg.time_series#
Classes
|
Reader and writer for |
|
Minimal container for the |
|
Container for |
|
Convenience mixin that exposes two helpers so host classes can read time-series content without depending on concrete implementations. |
- class pycsamt.seg.time_series.TSect(*args, verbose=0, logger=None, **kws)[source]
Bases:
EDIComponentBaseMinimal container for the
>=TSERIESSECTheader block. It parses the section header and the ordered list of measurement IDs that follow the header. The class keeps a pointer to where the first>TSERIESdata block starts so downstream readers can jump straight to the data.- Parameters:
- Variables:
sectid (str or None) – Section identifier. If absent in file it remains
None.nchan (int or None) – Number of channels declared in the header.
nmeas (int or None) – Number of measurements declared in the header.
npts (int or None) – Number of samples per trace if provided.
maxblks (int or None) – Hint for the maximum number of data blocks.
dt (float or None) – Sampling interval in seconds when present.
meas_ids (list of str) – Ordered list of measurement IDs collected from the header tail. One ID per line.
extra (dict) – Any non standard key–value options preserved as strings.
start_data_lines_num (int or None) – Absolute line index where the first
>TSERIESblock begins. Useful for fast data scans.
- from_file(edi_path)[source]
Parse a single
>=TSERIESSECTfrom an EDI file. The method validates the file structure withvalidation.IsEdi._assert_edi()before parsing.
- write()[source]
Serialize the section back to EDI lines including the measurement ID list.
Notes
Parsing is tolerant. Unknown keys are stored in
extra. Blank lines and comment lines beginning with//are ignored. If multiple time-series sections exist, callfrom_file()on the desired file view or use a higher level iterator to locate the right header first.Examples
>>> sect = TSect.from_file("sound.edi") >>> sect.nchan, sect.dt (3, 0.01) >>> print("IDs:", sect.meas_ids[:2]) IDs: ['HX', 'HY']
See also
TSIOReader and writer for
>TSERIESdata blocks.validation.IsEdiLightweight EDI file validator used during reading.
References
[TSect-1]SEG EDI MT/EMAP standard (1987). MTNet. https://www.mtnet.info/docs/seg_mt_emap_1987.pdf
- class pycsamt.seg.time_series.TSIO(*args, verbose=0, logger=None, **kws)[source]
Bases:
EDIComponentBaseReader and writer for
>TSERIESdata blocks. Each data block line starts with a flexible option list (e.g.ID=HX NPTS=4 DT=0.25) followed by a// Nhint and then one or more lines of numeric samples.- Parameters:
- Variables:
blocks (list of _TSBlock) –
Parsed time-series blocks in file order. Every block exposes:
options: dict of parsed header options.nvals_hint: int or None from the//count.values: list[float] of samples.id: str or None (alias ofoptions['id']).npts: int or None (alias ofoptions['npts']).dt: float or None (alias ofoptions['dt']).
- from_file(edi_path, start_line=None, \*, verbose=0, logger=None)[source]
Parse all
>TSERIESblocks starting atstart_line. Ifstart_lineisNonethe first block is located automatically. The method assumes the file already passedvalidation.IsEdi._assert_edi()upstream.
- write(per_line=None, float_fmt=None)[source]
Serialize every block.
per_linecontrols how many samples are printed per line.float_fmtcontrols the numeric format (e.g."{: .6E}").
Notes
Header options are typed heuristically. Integer-like tokens become integers. Otherwise they are parsed as floats when possible, and finally left as strings. The common aliases
id,nptsanddtare mirrored onto block fields for convenience.Examples
>>> sect = TSect.from_file("sound.edi") >>> io = TSIO.from_file("sound.edi", start_line=sect.start_data_lines_num) >>> len(io.blocks) 2 >>> io.blocks[0].id, io.blocks[0].dt ('HX', 0.25) >>> lines = io.write(per_line=5, float_fmt="{: .3E}") >>> print("".join(lines).splitlines()[0]) >TSERIES ID=HX NPTS=4 DT=0.25 // 4
See also
TSectHeader reader for
>=TSERIESSECT.SpectraIOSimilar reader for
>SPECTRAblocks.
References
[TSIO-1]SEG EDI MT/EMAP standard (1987). MTNet. https://www.mtnet.info/docs/seg_mt_emap_1987.pdf
- blocks: list[_TSBlock]
- classmethod from_file(edi_path, start_line=None, *, verbose=0, logger=None)[source]
- class pycsamt.seg.time_series.TimeSeriesMixin[source]
Bases:
objectConvenience mixin that exposes two helpers so host classes can read time-series content without depending on concrete implementations.
- read_tseries_header(edi_fn, \*, verbose=0, logger=None)[source]
Return a
TSectparsed fromedi_fn. The result holds the header fields and the position of the first data block.
- read_tseries_blocks(edi_fn, \*, verbose=0, logger=None)[source]
Return a
TSIObuilt from the same file. The method internally callsTSectto find the first>TSERIESand then streams all blocks.
Notes
Use this mixin in higher level readers or project classes to offer a thin, stable API. The methods only read data and do not modify files on disk.
Examples
>>> class Reader(TimeSeriesMixin): ... pass >>> hdr = Reader.read_tseries_header("sound.edi") >>> ts = Reader.read_tseries_blocks("sound.edi") >>> hdr.nchan, len(ts.blocks) (2, 3)
References
[TimeSeriesMixin-1]SEG EDI MT/EMAP standard (1987). MTNet. https://www.mtnet.info/docs/seg_mt_emap_1987.pdf
- classmethod read_tseries_header(edi_fn, *, verbose=0, logger=None)[source]