Skip to content

Extract geometry from fsp files#41

Merged
lispandfound merged 5 commits intomainfrom
fsp_segment_header
May 7, 2025
Merged

Extract geometry from fsp files#41
lispandfound merged 5 commits intomainfrom
fsp_segment_header

Conversation

@lispandfound
Copy link
Copy Markdown
Contributor

This PR (hopefully) completes the FSP file parsing by allowing you to extract the raw geometry from an FSP file (where that FSP file is in a place that can be represented accurately with NZTM coordinates).

@lispandfound lispandfound requested a review from Copilot May 1, 2025 01:45
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR finalizes the FSP file parser by extracting raw geometry and additional segment properties from FSP files with NZTM coordinate support.

  • Enhanced test coverage in tests/test_fsp.py to validate new segment attributes and plane conversion.
  • Introduced a new dataclass (Segment) and updated parsing logic to collect segment properties including strike, dip, dimensions, and subfaults in source_modelling/fsp.py.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
tests/test_fsp.py Added numpy import and updated test expectations for new geometry fields.
source_modelling/fsp.py Added Segment dataclass and updated parsing logic to extract segment data.
Comments suppressed due to low confidence (1)

tests/test_fsp.py:55

  • Confirm that the updated expected width value of 12.0 aligns with the official FSP file specifications.
assert fsp_file.segments[0].width == pytest.approx(12.0)

@lispandfound
Copy link
Copy Markdown
Contributor Author

lispandfound commented May 1, 2025

Here is an example of the geometry extracted from the FSP file in the darfield source model

image

which is extracted as

darfield = FSPFile.read_from_file('path/to/file.fsp')
planes = [segment.as_plane() for segment in darfield.segments]

@lispandfound lispandfound requested a review from Copilot May 1, 2025 03:37
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds functionality to extract raw geometry from FSP files, completing the FSP file parsing for NZTM coordinate‐based data.

  • Updates tests to assert new geometric properties and conversion to a Plane object.
  • Introduces a new Segment dataclass and extends the _parse_segment_slip function to return both DataFrame data and segment objects.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
tests/test_fsp.py Updates to include new assertions for geometric and segment data.
source_modelling/fsp.py Adds the Segment dataclass, modifies as_plane conversion logic, and updates parsing logic for segment data.
Comments suppressed due to low confidence (1)

source_modelling/fsp.py:110

  • The conditional check in as_plane uses implicit truthiness which may incorrectly raise a ValueError when any numeric attribute (e.g., strike or dip) is 0. Consider using explicit checks against None to allow valid zero values.
if not (self.strike and self.dip and self.length and self.width and isinstance(self.top_centre, np.ndarray)):

@lispandfound lispandfound requested a review from Copilot May 1, 2025 03:40
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR completes the FSP file parsing by extracting raw geometry from FSP files that use NZTM coordinates. Key changes include introducing a new Segment dataclass with associated parsing logic, updating the parsing function (_parse_segment_slip) to return both subfault data and segments, and enhancing tests to assert the accuracy of geometric values and plane conversion.

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
tests/test_fsp.py Added assertions to validate new segment attributes and plane conversion from the FSP file
source_modelling/fsp.py Introduced the Segment dataclass and revised parsing logic to extract segment properties

@lispandfound lispandfound merged commit 9fef08a into main May 7, 2025
6 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.

4 participants