Update src/seismic_hazard_forecasting.py

This commit is contained in:
2026-06-22 22:58:10 +02:00
parent 3d4f9138d7
commit 337457d49c
+10 -11
View File
@@ -767,7 +767,7 @@ verbose: {verbose}")
imls = [dask.delayed(compute_IMT_exceedance)(rx_lat[i], rx_lon[i], distances[i].flatten(), fr, p, lambdas, imls = [dask.delayed(compute_IMT_exceedance)(rx_lat[i], rx_lon[i], distances[i].flatten(), fr, p, lambdas,
forecast_len, lambdas_perc, m_range, m_pdf, m_cdf, model, forecast_len, lambdas_perc, m_range, m_pdf, m_cdf, model,
log_level=logging.DEBUG, imt=imt, IMT_min=0.0, IMT_max=IMT_max, rx_label=i, log_level=logging.DEBUG, imt=imt, IMT_min=0.0, IMT_max=IMT_max, rx_label=i,
rtol=0.1, use_cython=True) for i in iter] rtol=0.1, use_cython=False) for i in iter]
iml = dask.compute(*imls) iml = dask.compute(*imls)
iml_grid_raw.append(list(iml)) iml_grid_raw.append(list(iml))
@@ -837,19 +837,18 @@ verbose: {verbose}")
for j in range(0, len(products)): for j in range(0, len(products)):
vmin = min(x for x in iml_grid_prep[j] if x is not np.nan) vmin = min(x for x in iml_grid_prep[j] if x is not np.nan)
vmax = max(x for x in iml_grid_prep[j] if x is not np.nan) vmax = max(x for x in iml_grid_prep[j] if x is not np.nan)
iml_grid[j] = np.reshape(iml_grid_prep[j], (nx, ny)).astype( iml_grid[j] = np.reshape(iml_grid_prep[j], (nx, ny)).astype(dtype=np.float64) # this reduces values to 8 decimal places
dtype=np.float64) # this reduces values to 8 decimal places
iml_grid_tmp = np.nan_to_num(iml_grid[j]) # change nans to zeroes iml_grid_tmp = np.nan_to_num(iml_grid[j]) # change nans to zeroes
# upscale the grid, trim, and interpolate if there are at least 10 grid values with range greater than 0.1 # upscale the grid, trim, and interpolate if there are at least 10 grid values with range greater than 0.1
if np.count_nonzero(iml_grid_tmp) >= 10 and vmax-vmin > 0.1: #if np.count_nonzero(iml_grid_tmp) >= 10 and vmax-vmin > 0.1:
up_factor = 1 # up_factor = 1
iml_grid_hd = resize(iml_grid_tmp, (up_factor * len(iml_grid_tmp), up_factor * len(iml_grid_tmp)), # iml_grid_hd = resize(iml_grid_tmp, (up_factor * len(iml_grid_tmp), up_factor * len(iml_grid_tmp)),
mode='reflect', anti_aliasing=False) # mode='reflect', anti_aliasing=False)
trim_thresh = vmin # trim_thresh = vmin
iml_grid_hd[iml_grid_hd < trim_thresh] = np.nan # iml_grid_hd[iml_grid_hd < trim_thresh] = np.nan
else: #else:
iml_grid_hd = iml_grid_tmp iml_grid_hd = iml_grid_tmp
iml_grid_hd[iml_grid_hd == 0.0] = np.nan # change zeroes back to nan iml_grid_hd[iml_grid_hd == 0.0] = np.nan # change zeroes back to nan