Skip to content

Add SRF version 2.0 (vs/den) support#62

Open
AndrewRidden-Harper wants to merge 9 commits into
mainfrom
srf-2p0
Open

Add SRF version 2.0 (vs/den) support#62
AndrewRidden-Harper wants to merge 9 commits into
mainfrom
srf-2p0

Conversation

@AndrewRidden-Harper

Copy link
Copy Markdown
Contributor

Summary

Adds read/write support for SRF version 2.0. The only points-level difference
from v1.0 is two extra per-subfault fields, VS and DEN, on each point's
first data line. v1.0 behaviour is unchanged.

Changes

  • Reader: vs/den columns added (after dt) for v2.0 only; the Rust
    parser is told the version by from_file. v1.0 stays 11 columns.
  • Writer: write_srf writes the real version, and the Rust writer sizes
    data line 1 from the column count, so v2.0 emits vs/den on line 1.
  • SW4-HDF5: write_sw4_hdf5 fills the existing VS/DEN fields for v2.0.

AndrewRidden-Harper and others added 5 commits June 4, 2026 12:27
Make the Rust point parser version-aware via a boolean flag and add
vs/den columns (after dt) to the points dataframe only for version 2.0.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Write the real version string and derive the writer data-line-1 width
from the column count so vs/den are emitted on line 1 for version 2.0.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Populate the existing VS/DEN POINTS fields from the dataframe when the
SRF is version 2.0; v1.0 exports keep them at zero.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces support for version 2.0 of the SRF (Standard Rupture Format) file format, enabling the parsing, writing, and HDF5-exporting of the additional shear-wave velocity (vs) and density (den) fields. Feedback recommends validating the SRF version string during parsing to prevent unsupported versions from defaulting to the 1.0 layout, and adding a defensive check in the Rust parser to prevent potential arithmetic overflow panics when calculating the summary length.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread source_modelling/srf.py
Comment thread source_modelling/srf_parser/src/lib.rs
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@lispandfound

lispandfound commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

At some point I think we want to refactor the rust parser and make it a bit cleaner -- the current code is quite brittle, and the way Claude has minimally extended the code for 2.0 support demonstrates this. However, I think I am satisfied that this code isn't wrong.

Comment thread source_modelling/srf.py Outdated
Comment thread source_modelling/srf.py Outdated
Comment thread source_modelling/srf_parser/src/lib.rs Outdated
AndrewRidden-Harper and others added 3 commits June 10, 2026 15:33
Co-authored-by: Jake Faulkner <jake.faulkner@canterbury.ac.nz>
- Write VS/DEN based on the SRF version, not column presence, so a 2.0
  SRF missing vs/den fails loudly instead of silently writing zeros
- Annotate points_data as np.ndarray, removing the need for ty ignores
  on structured-array field assignments
- Name the per-point quantity counts in the Rust parser
  (NUM_QUANTITIES_V1/V2) instead of bare 11/13 literals

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Real genslip-generated version 2.0 SRFs contain comment lines (starting
with '#') between the version line and the PLANE header. Skip them, and
add a test reading a real 2601-point genslip SRF (shipped gzipped in
tests/data) with spot checks transcribed from its first, middle, and
last point blocks.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.

2 participants