Merged
Conversation
AndrewRidden-Harper
approved these changes
Apr 8, 2025
claudio525
approved these changes
Apr 8, 2025
joelridden
approved these changes
Apr 8, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR adds a fallback check to the fault connectivity checker. This fallback check is designed to make it easier to construct faults with very small segments.
What Does the Fault Connectivity Check Do?
Faults are a series of connected planes. The planes should be connected along-strike and in a line, that is if
plane_1points toplane_2andplane_2points toplane_3(along-strike), then the fault containing planes 1, 2, and 3 should be instantiatedFault([plane_1, plane_2, plane_3]). In a perfect world faults from all sources including the National Seismic Hazard Model, community fault model, and custom geometries would be specified like this. Unfortunately the world is far from perfect and instead faults are called with an arbitrary order of planes likeFault([plane_2, plane_1, plane_3]). So we must sort sort them ourselves.How Does the Sorting Work?
The sorting works by building a graph with an edge between indices
iandjof the input list if the rightmost top corner ofplane_iis close to the leftmost top corner ofplane_j. For the above fault with planes passed as a list[plane_2, plane_1, plane_3]the graph constructed would look like1 --> 0 --> 2. The sorting is then a topological sort applied to this graph to get the sorted list of planes[plane_1, plane_2, plane_3]. Notably, we also check before this stage that the graph is a line. If the graph is not connected, or contains cycles, then that tells us the fault planes given do not make a fault consistent with the assumptions of theFaultclass. We raise aValueErrorin these cases.What is the Problem?
There are three ways a fault can be invalid:
That last problem is artificial. The close to check we do when sorting the faults needs to have some leeway to admit faults that have rounded corners or other numerical imprecision. This in turn means that sometimes fault planes are erroneously believed to point into more than one plane downstream. For instance,
which might get the graph
1 -> [2, 3], 2 -> 3. We then throw aValueErrorto reject this fault. A simple fix is adjusting the close to check to be more careful about which planes are considering pointing into each other, but then that causes more faults to be rejected of the first type. The NSHM is full of such faults with short segments unfortunately so the tension between type-1 and type-3 rejections is very painful.The New Solution
Instead of relaxing the close to check for the upteenth time, I have made a modification to the line sorting algorithm. It now checks if the faults form a line, and if they don't it performs a transitive reduction and tries again. If it still fails the second time, an error is thrown. In the earlier example case, The graph starting
1 -> [2, 3], 2 -> 3is reduced to1 -> 2, 2 -> 3and then the fault is then successfully constructed on the second pass. I don't believe this will introduce any errors where we accept invalid faults, but just in case I've added a warning so that the user knows to check the fault just in-case.