pycsamt.jones.utils#
Lightweight parsing utilities for A.G. Jones J‑format files.
This module exposes small, focused helpers used by higher‑level
components (e.g., j.py, components.py) to lex and parse
J files. It does not assemble site objects; it only handles
normalization, tokenization, and row conversion with robust error
messages.
Functions
|
Return True if |
|
Return True if |
|
Yield |
|
Yield lines from a path, file‑like, or a sequence of strings. |
|
Yield |
|
Parse a data‑type line like |
|
Parse an information line |
|
Parse the number of rows to follow. |
|
Parse a single data row for |
|
Parse a station line (alnum up to 6 chars). |
|
Yield only non‑comment lines (keep blanks for block logic). |
Classes
|
Decoded data‑type descriptor. |
|
A normalized row from an R/S or TF block. |
- exception pycsamt.jones.utils.JParseError#
Bases:
PycsamtErrorRaised when a J‑file token cannot be parsed.
The message tries to include the line number and a short hint about the expected syntax to aid debugging.
- class pycsamt.jones.utils.DataType(kind, comp, units, tensor_hint=None)[source]#
Bases:
objectDecoded data‑type descriptor.
- Variables:
- Parameters:
- class pycsamt.jones.utils.ParsedRow(period, freq, values, flags)[source]#
Bases:
objectA normalized row from an R/S or TF block.
- Variables:
period (float) – Period in seconds (always positive).
freq (float) – Frequency in Hz (
1/period). If input stored frequency,freqequals that value andperiodis inverted.values (Mapping[str, float]) – Other numeric columns by name.
flags (Mapping[str, bool]) – Flags such as
stored_as_freqorrejected.
- Parameters:
- pycsamt.jones.utils.iter_lines(obj, *, encoding='utf-8', keepends=False)[source]#
Yield lines from a path, file‑like, or a sequence of strings.
- Parameters:
- Yields:
str – One line at a time.
- Return type:
- pycsamt.jones.utils.parse_info(line, *, lineno=None)[source]#
Parse an information line
>KEY = value.Returns the canonical attribute name and the raw value string.
- pycsamt.jones.utils.parse_station(line, *, lineno=None)[source]#
Parse a station line (alnum up to 6 chars).
- pycsamt.jones.utils.parse_datatype_units(line, *, lineno=None)[source]#
Parse a data‑type line like
ZXY SIorRTE.The result contains the kind, component, optional units, and a
tensor_hintfor TE/TM modes.
- pycsamt.jones.utils.parse_npoints(line, *, lineno=None)[source]#
Parse the number of rows to follow.
- pycsamt.jones.utils.parse_row(kind, line, *, lineno=None)[source]#
Parse a single data row for
kind.Handles R/S (rho‑phi) and complex TF kinds (Z/Q/C/T). Returns a
ParsedRowwith period/frequency normalized and rejection flags applied according to the spec.
- pycsamt.jones.utils.strip_nondata(lines)[source]#
Yield only non‑comment lines (keep blanks for block logic).
This keeps structure intact while removing comment noise.