Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces the capability to export Standard Rupture Format (SRF) data into a specialized HDF5 format tailored for the SW4 seismic simulation software. This enhancement streamlines the workflow for users who need to prepare SRF inputs for SW4, providing a direct and efficient conversion method within the existing SRF handling utilities. The implementation includes precise data structuring and comprehensive testing to ensure data integrity and compatibility with the target software. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request adds functionality to write SRF data into SW4's HDF5 format. The implementation is largely correct and well-tested. However, I've identified a critical bug in handling array inputs for shear wave velocity and density which would cause a runtime error. Additionally, the new test case has a potential cross-platform compatibility issue and a minor maintainability concern. I have provided specific suggestions to address these points.
There was a problem hiding this comment.
Pull request overview
Adds an SW4-compatible SRF→HDF5 writer so SRF content can be consumed by SW4 without relying on the slower Python srf2hdf5.py conversion path.
Changes:
- Introduces
SrfFile.write_sw4_hdf5()to emit SW4’s expected HDF5 structure (VERSION,PLANE,POINTS, and optionalSR1). - Adds SW4-specific NumPy structured dtypes (
SW4_PLANE_DTYPE,SW4_POINTS_DTYPE) used for binary-compatible layout. - Adds a unit test validating round-trip preservation of header/points and slip-time-function data when writing SW4 HDF5.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
source_modelling/srf.py |
Adds SW4 HDF5 writer + SW4 structured dtypes; imports h5py. |
tests/test_srf.py |
Adds coverage for write_sw4_hdf5() output structure and values. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
np.float32() fails on arrays, but the docstring allows np.ndarray. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
ty type checker is finding 38 issues related to existing code not changed in this PR. Should they be fixed in a separate PR? |
|
Do we have a format specification of SW4 HDF5? |
|
@sungeunbae The format is specified in the SW4 User Guide (Section 12.7, page 105). Do you think we should add the PDF to the repo? |
Co-authored-by: Jake Faulkner <jake.faulkner@canterbury.ac.nz>
Co-authored-by: Jake Faulkner <jake.faulkner@canterbury.ac.nz>
Co-authored-by: Jake Faulkner <jake.faulkner@canterbury.ac.nz>
Co-authored-by: Jake Faulkner <jake.faulkner@canterbury.ac.nz>
Co-authored-by: Jake Faulkner <jake.faulkner@canterbury.ac.nz>
Co-authored-by: Jake Faulkner <jake.faulkner@canterbury.ac.nz>
|
Thanks for the PR comments. I've addressed them all as you suggested |
This pull request adds support for writing SRF data in the format needed by SW4.
SW4 provides srf2hdf5.py to convert text-based SRFs to the SW4 format. However, this Python script is much slower than Jake's Rust SRF parser, so we do not simply adopt srf2hdf5.py. However, we do use our own forked version of srf2hdf5.py, which was slightly modified to handle our Version 1 SRF files, to also convert an example Version 1 SRF file provided by SW4, examples/rupture/rtest.srf. You can do this comparison yourself by cloning our fork of SW4 (which was only created for this check), checking out the branch write-v1-srf, and running the script tools/verify_sw4_hdf5.py.