Skip to content

Add get_x_l_ratio() method to BaseSurface for PFDHA applications#11201

Merged
micheles merged 6 commits intogem:masterfrom
vup1120:master
Feb 13, 2026
Merged

Add get_x_l_ratio() method to BaseSurface for PFDHA applications#11201
micheles merged 6 commits intogem:masterfrom
vup1120:master

Conversation

@vup1120
Copy link
Copy Markdown
Contributor

@vup1120 vup1120 commented Feb 9, 2026

This PR adds support for computing normalized along-strike position (x/L) for Probabilistic Fault Displacement Hazard Assessment (PFDHA) applications.

It includes:

  1. _get_surface_trace():
    Private helper method that extracts the surface trace (top edge) as a 2D array of geographic coordinates with NaN
    handling for KiteSurface compatibility.
  2. get_x_l_ratio(mesh): It computes the normalized along-strike position (x/L) for each point in the mesh relative to the surface trace
  3. Testing suite added to base_surface_test.py

Notes:

  1. Point-to-polyline projection algorithm finds the nearest trace segment
    for each site using vectorized distance calculations
  2. Returns tuple (x_over_L, L_km) where x_over_L is a numpy array with
    values in [0, 1] and L_km is the total trace length in kilometers
  3. All x/L values are clamped to [0, 1] before return

Comment thread openquake/hazardlib/geo/surface/base.py Outdated
trace[1:, 0], trace[1:, 1]
)
L_km = float(numpy.sum(seg_lengths_km))
if L_km <= 0.0:
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.

How can this be negative?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I removed this and only keep the if L_proj == 0.0 check ( at #284). It was if L_proj <= 0.0 before, but it actually won't be negative, so I modified it now to "== 0.0"

@micheles micheles added this to the Engine 3.25.0 milestone Feb 10, 2026
Copy link
Copy Markdown
Member

@mmpagani mmpagani left a comment

Choose a reason for hiding this comment

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

Thanks @vup1120. The PR looks good to me but you need to fix the conflict in the changelog

Comment thread openquake/hazardlib/geo/surface/base.py Outdated
dep = numpy.min(top_edge.depths)
return dep

def _get_surface_trace(self):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I would call this _get_tor(self)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

All Fixed 🙂

@micheles micheles merged commit 7b9f180 into gem:master Feb 13, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants