Update src/seismic_hazard_forecasting.py

This commit is contained in:
2025-08-22 14:24:58 +02:00
parent cfd1d42e05
commit a67ca1980c

View File

@@ -162,19 +162,19 @@ def compute_IMT_exceedance(rx_lat, rx_lon, r, fr, p, lambdas, D, percentages_D,
upper_bound_value = exceedance_root_function(IMT_max)
return None
logger.info(f"Receiver: {str(rx_label)}")
logger.info(f"Function value at {imt} = {str(IMT_min)} : {lower_bound_value}")
logger.info(f"Function value at {imt} = {str(IMT_mid)} : {mid_point_value}")
logger.info(f"Function value at {imt} = {str(IMT_max)} : {upper_bound_value}")
#logger.info(f"Receiver: {str(rx_label)}")
#logger.info(f"Function value at {imt} = {str(IMT_min)} : {lower_bound_value}")
#logger.info(f"Function value at {imt} = {str(IMT_mid)} : {mid_point_value}")
#logger.info(f"Function value at {imt} = {str(IMT_max)} : {upper_bound_value}")
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)
@@ -185,18 +185,18 @@ def compute_IMT_exceedance(rx_lat, rx_lon, r, fr, p, lambdas, D, percentages_D,
try:
method='brenth'
logger.debug("Now trying Scipy " + method)
#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
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