From 0ef41d72f67c5b8711c0f7e34f5406e23a993b3b Mon Sep 17 00:00:00 2001 From: ftong <95+ftong@noreply.example.org> Date: Mon, 22 Jun 2026 19:06:19 +0200 Subject: [PATCH] Update src/seismic_hazard_forecasting.py fix orientation issue attempt 1 --- src/seismic_hazard_forecasting.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/seismic_hazard_forecasting.py b/src/seismic_hazard_forecasting.py index 7cc3d0a..c3b0426 100644 --- a/src/seismic_hazard_forecasting.py +++ b/src/seismic_hazard_forecasting.py @@ -699,18 +699,22 @@ verbose: {verbose}") fxy = xy_kde[0] logger.debug(f"Normalization check; sum of all f(x,y) values = {np.sum(fxy)}") - xx, yy = np.meshgrid(x_range, y_range, indexing='ij') # grid points + xx, yy = np.meshgrid(x_range, y_range) # grid points # set every grid point to be a receiver + grid_shape = xx.shape x_rx = xx.flatten() y_rx = yy.flatten() + num_points = x_rx.size + distances = np.zeros(shape=(num_points, grid_shape[0], grid_shape[1])) + # compute distance matrix for each receiver - distances = np.zeros(shape=(nx * ny, nx, ny)) + #distances = np.zeros(shape=(nx * ny, nx, ny)) rx_lat = np.zeros(nx * ny) rx_lon = np.zeros(nx * ny) - for i in range(nx * ny): + for i in range(num_points): # Compute the squared distances directly using NumPy's vectorized operations squared_distances = (xx - x_rx[i]) ** 2 + (yy - y_rx[i]) ** 2 distances[i] = np.sqrt(squared_distances) @@ -726,7 +730,7 @@ verbose: {verbose}") if exclude_low_fxy: indices = list(np.where(fxy.flatten() > thresh_fxy)[0]) else: - indices = range(0, len(distances)) + indices = np.arange(num_points) if use_AOI: # Filter out receivers outside the AOI; Find indices where values are OUTSIDE the AOI @@ -836,9 +840,6 @@ verbose: {verbose}") iml_grid_hd[iml_grid_hd == 0.0] = np.nan # change zeroes back to nan - # correct orientation is AOI is used - if use_AOI: - iml_grid_hd = np.rot90(iml_grid_hd, k=-1) #vmin_hd = min(x for x in iml_grid_hd.flatten() if not isnan(x)) vmax_hd = max(x for x in iml_grid_hd.flatten() if not isnan(x))