Skip to content

parseSEG 0.11.0: the API settled before the viewer - #5

Merged
xrfez merged 7 commits into
mainfrom
phase17
Nov 13, 2026
Merged

xrfez merged 7 commits into
mainfrom
phase17

Conversation

@xrfez

@xrfez xrfez commented Nov 13, 2026

Copy link
Copy Markdown
Owner

The open items of the 0.10.0 review, decided by the owner. Breaking, without deprecated forms: nothing depends on parseSEG yet but processSEG, which moves with it.

Breaking

  • readTracesInto: every form takes the log where the failed-row forms take failedRows, before the defaulted row: (f, traces, [samples,] dst, log | failedRows, row = 0). A positional f.readTracesInto(t, dst, 0, log) becomes f.readTracesInto(t, dst, log).
  • SeismicFile.index is read-only: f.index is a lent accessor, so every read works as before but no write compiles. Changes go through the procs that take the file (applySurvey, ensureKeys, the header editor, and the new f.applyGeometry(g)). f.index.applyGeometry(g) and f.index.applySurvey(...) become f.applyGeometry(g) and f.applySurvey(...).
  • Relation runs: an X/O record whose last channel is not the first of a station ends with its last whole station, in every lookup (relation, relations, expectedChannels, relationRuns). Before, the lookups also related the channels after it, on a station past the run's last point, while relationRuns did not. Reading such a record is now a warning.

New

  • writeTrace(w, src, trace, samples, keys, overrides = [], fields) and its tensor form write a trace like its source with the geometry of the keys held in memory: keys joined from survey files or edited, which the mapped headers do not hold. All three standards: SEG-Y and SEG-D through write-back's rules, and SEG-2 strings (locations, station numbers, LINE_ID; new). Values with no slot are reported by close.
  • SPS grid units: GridUnit from H20/H201, SurveyGeometry.gridUnit (with a warning for a file in another unit) and measurementSystem. SEG-Y written with joined geometry now records the unit in the binary header: SEG-D-to-SEG-Y conversions wrote metres whatever the survey; copies and conversions with geometry set it. Coordinates are never rescaled.

Fixed

  • Write-back reported a station part the headers already hold (the source point in espnum) as "not written" when the layout had no sht_point field. It now follows its documented rule: a value is written when the key differs from what the headers hold.

Checked

Local: nim test, testRelease, testV3, asan, docs (59 test files). New tests: twritejoined (all standards); tsurvey (grid units, a run that stops inside a station); tgeomwrite (units in SEG-Y output); tcoreapi (the read-only index).

🤖 Generated with Claude Code

xrfez and others added 7 commits November 13, 2026 17:14
The four log forms were (f, traces, [samples,] dst, row = 0, log): a
required argument after a defaulted one, so a caller had to pass row or
name log. They now take the log where the failed-row forms take
failedRows: (f, traces, [samples,] dst, log | failedRows, row = 0).
Breaking: a positional call f.readTracesInto(t, dst, 0, log) becomes
f.readTracesInto(t, dst, log).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The field is private; `f.index` is a `lent` accessor, so every read
(`f.index.keys[i]`, `f.index.segy.binary`, ...) works as before and no
write compiles for a user. The index changes through the procs that take
the file and keep the keys' revision and layout plan in step:
`applySurvey`, `ensureKeys`, the header editor, and the new
`applyGeometry(f: var SeismicFile, g, overwrite)`. parseSEG's own modules
(join, edit) write through `mindex`, which `import parseSEG` does not
export (tdocs lists it as internal); the tests that corrupt an index on
purpose import it from model/traceindex.

Breaking: `f.index.applyGeometry(g)` and `f.index.applySurvey(...)`
become `f.applyGeometry(g)` and `f.applySurvey(...)`. Test:
tcoreapi index_is_read_only (writes through `f.index` do not compile,
`mindex` is not visible).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An X (or O) record whose last channel is not the first of a station
(channels 1..10 by 4) was read two ways: `relation`, `relations` and
`expectedChannels` related the channels after the last station start
(multi-component: channel 13 too, on a station extrapolated past the
run's last point), while `relationRuns` stopped at the last whole
station (channels 1..12). Every lookup now takes the run's whole
stations only, and reading such a record is a warning (capped per file):
"channel 10 is not the first of a station ...; the run's last station
starts at channel 9".

Tests: tsurvey a_range_that_stops_inside_a_station (multi- and
single-component: the four lookups agree, the warning); the randomized
lookup test now also draws ranges that stop inside a station.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`GridUnit` (`name` from H20, `metres` from H201, NaN when not given),
`gridUnit(spsFile)`, `known` and `measurementSystem` (SEG-Y's code: 1
metres; 2 feet for H201 0.3048 or 0.3048006096, or a name such as
`feet` without a factor; 0 other). `SurveyGeometry.gridUnit` takes the
first file's unit and warns about a later file in another. Coordinates
are never rescaled.

Output: SEG-D converted to SEG-Y with joined geometry wrote the
measurement system as metres whatever the survey; it is now the
survey's unit when known. SEG-Y copies and conversions with geometry
set the binary header's measurement system to the survey's unit (an
info entry when that changes it). In-place `writeGeometry` leaves the
binary header alone (documented).

Morgantown (three files, NAD27 State Plane in US survey feet) reads as
feet, measurement system 2, without warnings. Tests: tsurvey
grid_units_from_the_header (the mapping, N/A, a bad factor, the mixed
warning); tgeomwrite grid_units_reach_the_segy_binary_header (feet copy
and conversion say 2, coordinates unscaled; metres leave 1) and the SEG-D
conversion in feet.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
`writeTrace(w, src, trace, samples, keys, overrides = [], fields)` and its
tensor form write trace `trace` of `src` as the template with the geometry
of `keys` written into its headers first, where it differs from what they
hold: for processed traces whose keys were joined (applySurvey,
applyGeometry) or edited in memory, which the mapped headers do not hold.
All three standards:

- SEG-Y and SEG-D through write-back's planner (one per writer, kept for
  the template file): SEG-Y via the layout (coordinates with a scalar
  chosen per trace, elevations, midpoint, offset, source point, stations
  where a Layout stanza names them); SEG-D THE#1 stations and the Rev 3
  position and source description blocks;
- SEG-2 (new): SOURCE_/RECEIVER_LOCATION (x y, z less DATUM),
  SOURCE_/RECEIVER_STATION_NUMBER, and LINE_ID when the source and
  receiver lines are one.

A value with no slot, or too large for its slot, is not written; `close`'s
log reports each kind once with a count. The writer's loaders now take the
template's header bytes from a buffer (the map, or the patched copy).

Write-back fix found on the way: a station part the headers already hold
(the source point in espnum) was reported "not written" when the layout
had no sht_point/sht_line field, in copyWithGeometry too. The line, point
and index slots now follow the module's rule: written when the key
differs from what the headers hold as the keys read them.

Tests: tests/twritejoined.nim (SEG-Y edited keys round trip with offset
and midpoint, unchanged keys write nothing new, a value without a slot;
SEG-Y converted from SEG-D joined by stations; SEG-D Rev 2 stations and
unwritable coordinates; Rev 3 positions; SEG-2 strings and the one
LINE_ID).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…id unit

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@xrfez
xrfez merged commit 773408d into main Nov 13, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant