Update src/seismic_hazard_forecasting.py

This commit is contained in:
2025-08-22 14:46:21 +02:00
parent de0677a07c
commit a878f47636

View File

@@ -174,30 +174,30 @@ def compute_IMT_exceedance(rx_lat, rx_lon, r, fr, p, lambdas, D, percentages_D,
if np.sign(lower_bound_value) == np.sign(upper_bound_value):
msg = "Function values at the interval endpoints must differ in sign for fsolve to work. Expand the interval or use a different model."
#logger.error(msg)
logger.error(msg)
gm_est = np.nan
return gm_est
# raise ValueError(msg)
return None
# Find root of function
start = timer()
try:
method='brenth'
#logger.debug("Now trying Scipy " + method)
output = root_scalar(exceedance_root_function, bracket=[IMT_min, IMT_max], rtol=rtol, method=method)
gm_est = output.root
logger.debug("Now trying Scipy " + method)
#output = root_scalar(exceedance_root_function, bracket=[IMT_min, IMT_max], rtol=rtol, method=method)
#gm_est = output.root
gm_est = np.nan
except Exception as error:
#logger.error(f"An exception occurred: {error}")
#logger.info("Set ground motion value to nan")
logger.error(f"An exception occurred: {error}")
logger.info("Set ground motion value to nan")
gm_est = np.nan
end = timer()
#logger.info(f"Ground motion estimation computation time: {round(end - start,1)} seconds")
#logger.info(f"Estimated {imt}: {gm_est}")
logger.info(f"Ground motion estimation computation time: {round(end - start,1)} seconds")
logger.info(f"Estimated {imt}: {gm_est}")
return gm_est