Parse and serialize a single J-format head triple.
This lightweight component represents one data-block header
consisting of the station line, the data-type line, and the
row count. It provides a consistent constructor and the
read / write round-trip expected by the package.
Parameters:
j_header_list (sequence of str, optional) – Three logical header lines. The sequence may be a clean
triple [station,dtype,n] or a longer slice from a
file; the parser will extract the first valid triple.
verbose (int, default=0) – Verbosity for warnings during parsing.
**kwargs – Accepted for API forwards-compatibility; ignored here.
Variables:
station (str or None) – Upper-cased station identifier. Trailing azimuth tokens
on the same line are supported and ignored here (but see
az_hint).
dtype (DataType or None) – Parsed data-type token (e.g., ZXY, RTE) with
optional normalized units and a TE/TM tensor hint.
n (int or None) – Number of data rows that follow this header.
az_hint (float or None) – Optional azimuth extracted from the station line when
present (e.g., KB0001-30). This is not the same
as site AZIMUTH from the info block.
The station regex accepts common field variants, including
hyphens and underscores, and an optional numeric azimuth
token after the station id. The data-type parser is liberal
with whitespace and recognizes SI (S.I.) and
FIELD units.
Parse and serialize the J-format information block.
This component collects >KEY=VALUE records along with
leading comment lines. It exposes a small set of convenience
properties derived from JSiteProperty.
Parameters:
j_info_list (sequence of str, optional) – A sequence containing the comment and information
records. The parser stops at the first non-info,
non-comment, non-blank line.
verbose (int, default=0) – Verbosity for warnings during parsing.
**kwargs – Accepted for API forwards-compatibility; ignored here.
Variables:
items (dict of (str -> str)) – Mapping of upper-cased keys to unmodified string values.
comments (list of str) – Preserved leading comment lines (starting with #).
site (JSiteProperty) – Lazily parsed view providing normalized latitude,
longitude, azimuth and elevation (see properties below).
latitude (float or None) – Decimal degrees; hemisphere and DMS tolerated.
longitude (float or None) – Decimal degrees in [-180,180).
azimuth (float or None) – Site X-axis azimuth (degrees, true north).
The class provides convenient accessors for station and
site-level properties, and a small banner recorder for the
top provenance line (#WRITTENBY...). It is intended as
the lightest useful representation of a single J header
section.
Parameters:
head (Head, optional) – Existing head to attach. If omitted, an empty
Head is created.
info (Info, optional) – Existing info to attach. If omitted, an empty
Info is created.
verbose (int, default=0) – Verbosity for warnings during parsing.
azimuth (latitude, longitude, elevation,) – Shortcuts to values provided by info. azimuth
falls back to head.az_hint when the info block does
not contain AZIMUTH.
This class does not parse the subsequent data rows. It is
focused on fast, dependency-free header discovery to support
scanning tasks and metadata extraction.
Parse and serialize the top provenance comment line.
This helper targets lines such as:
#WRITTEN BY GEOTOOLS: kb0-s001 10/06/95 RAW RECS
It extracts the producer software name, an optional station
hint, a free-form date token, and an optional trailing note.
The writer defaults the software field to PYSCAMT when
none is provided.
Parameters:
top_lines (sequence of str, optional) – An initial slice of file lines. The constructor scans
these lines and parses the first matching banner.
software (str, optional) – Producer software name (e.g., 'GEOTOOLS'). When
omitted and the banner is not present, the writer uses
'PYSCAMT' as a default.
station (str, optional) – Station identifier hint found in the banner. This does
not replace the station found in the Head.
date (str, optional) – Free-form date token as found in the banner line.
note (str, optional) – Extra text following the date token on the same line.
verbose (int, default=0) – Verbosity for warnings during parsing.
Variables:
software (str or None) – Producer software parsed from the banner or provided by
the user.
station_hint (str or None) – Station token parsed from the banner; may differ from the
station found in the Head.
date (str or None) – Banner date token as text; not parsed into a datetime.
note (str or None) – Trailing free-form text after the date token.
The banner parser is intentionally liberal: it ignores
leading whitespace, is case-insensitive on the WRITTENBY
marker, and preserves the raw text of the trailing note. It
does not validate dates or enforce a specific date format.
Examples
>>> b=Banner().read([... '#WRITTEN BY GEOTOOLS: kb0-s001 10/06/95 RAW RECS'... ])>>> b.software,b.station_hint,b.date('GEOTOOLS', 'kb0-s001', '10/06/95')>>> Banner().write()[0].startswith('#WRITTEN BY PYSCAMT:')True