diff --git a/src/seismic_hazard_forecasting.py b/src/seismic_hazard_forecasting.py index f4e66c7..24880b5 100644 --- a/src/seismic_hazard_forecasting.py +++ b/src/seismic_hazard_forecasting.py @@ -81,6 +81,7 @@ def main(catalog_file, mc_file, pdf_file, m_file, m_select, mag_label, mc, m_max m_range = [None] else: m_range = read_mat_m(m_file) + m_max = m_range[-1] # take m_max from the m_file if verbose: logger.setLevel(logging.DEBUG) @@ -320,8 +321,8 @@ verbose: {verbose}") lambdas = [None] if custom_rate != None and forecast_select: logger.info(f"Using activity rate specified by user: {custom_rate} per {time_unit}") - lambdas = [custom_rate] - lambdas_perc = [1] + lambdas = np.array([custom_rate], dtype='d') + lambdas_perc = np.array([1], dtype='d') elif rate_select: logger.info(f"Activity rate modeling selected") @@ -377,8 +378,11 @@ verbose: {verbose}") # validate m_max against the grond motion model models_anthro_limited = ['Lasocki2013', 'Atkinson2015', 'ConvertitoEtAl2012Geysers'] # these models require that m_max<=4.5 - if m_max > 4.5 and model in models_anthro_limited: - msg = f"Selected ground motion model {model} is only valid up to a maximum magnitude of 4.5. Please try again with a lower maximum magnitude." + if m_max > 4.5 and model in models_anthro_limited: + if m_file is None: + msg = f"The selected ground motion model {model} is only valid for magnitudes up to 4.5. Please select a lower maximum magnitude." + else: + msg = f"The selected ground motion model {model} is only valid for magnitudes up to 4.5, but the provided magnitude file includes values up to {m_max}. Please adjust the magnitude range in the file accordingly." logger.error(msg) raise Exception(msg) @@ -462,7 +466,7 @@ verbose: {verbose}") 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, log_level=logging.DEBUG, imt=imt, IMT_min=0.0, IMT_max=2.0, rx_label=i, - rtol=0.1, use_cython=False) for i in iter] + rtol=0.1, use_cython=True) for i in iter] iml = dask.compute(*imls) iml_grid_raw.append(list(iml)) @@ -474,7 +478,7 @@ verbose: {verbose}") for i in iter: iml_i = 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, imt=imt, IMT_min = 0.0, - IMT_max = 2.0, rx_label = i, rtol = 0.1, use_cython=False) + IMT_max = 2.0, rx_label = i, rtol = 0.1, use_cython=True) iml.append(iml_i) logger.info(f"Estimated {imt} at rx {i} is {iml_i}") iml_grid_raw.append(iml)