Merge pull request 'enable cython' (!19) from ftong-patch-cython into master
Reviewed-on: #19 Reviewed-by: asia <asia@noreply.example.org>
This commit is contained in:
		@@ -81,6 +81,7 @@ def main(catalog_file, mc_file, pdf_file, m_file, m_select, mag_label, mc, m_max
 | 
				
			|||||||
        m_range = [None]
 | 
					        m_range = [None]
 | 
				
			||||||
    else:
 | 
					    else:
 | 
				
			||||||
        m_range = read_mat_m(m_file)
 | 
					        m_range = read_mat_m(m_file)
 | 
				
			||||||
 | 
					        m_max = m_range[-1] # take m_max from the m_file
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if verbose:
 | 
					    if verbose:
 | 
				
			||||||
        logger.setLevel(logging.DEBUG)
 | 
					        logger.setLevel(logging.DEBUG)
 | 
				
			||||||
@@ -320,8 +321,8 @@ verbose: {verbose}")
 | 
				
			|||||||
    lambdas = [None]
 | 
					    lambdas = [None]
 | 
				
			||||||
    if custom_rate != None and forecast_select:
 | 
					    if custom_rate != None and forecast_select:
 | 
				
			||||||
        logger.info(f"Using activity rate specified by user: {custom_rate} per {time_unit}")
 | 
					        logger.info(f"Using activity rate specified by user: {custom_rate} per {time_unit}")
 | 
				
			||||||
        lambdas = [custom_rate]
 | 
					        lambdas = np.array([custom_rate], dtype='d')
 | 
				
			||||||
        lambdas_perc = [1]
 | 
					        lambdas_perc = np.array([1], dtype='d')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    elif rate_select:
 | 
					    elif rate_select:
 | 
				
			||||||
        logger.info(f"Activity rate modeling selected")
 | 
					        logger.info(f"Activity rate modeling selected")
 | 
				
			||||||
@@ -378,7 +379,10 @@ verbose: {verbose}")
 | 
				
			|||||||
        # validate m_max against the grond motion model
 | 
					        # validate m_max against the grond motion model
 | 
				
			||||||
        models_anthro_limited = ['Lasocki2013', 'Atkinson2015', 'ConvertitoEtAl2012Geysers'] # these models require that m_max<=4.5
 | 
					        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:
 | 
					        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_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)
 | 
					            logger.error(msg)
 | 
				
			||||||
            raise Exception(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,
 | 
					                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=2.0, rx_label=i,
 | 
					                                                            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 = dask.compute(*imls)
 | 
				
			||||||
                iml_grid_raw.append(list(iml))
 | 
					                iml_grid_raw.append(list(iml))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -474,7 +478,7 @@ verbose: {verbose}")
 | 
				
			|||||||
                for i in iter:
 | 
					                for i in iter:
 | 
				
			||||||
                    iml_i = compute_IMT_exceedance(rx_lat[i], rx_lon[i], distances[i].flatten(), fr, p, lambdas, forecast_len, 
 | 
					                    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,
 | 
					                                                    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)
 | 
					                    iml.append(iml_i)
 | 
				
			||||||
                    logger.info(f"Estimated {imt} at rx {i} is {iml_i}")
 | 
					                    logger.info(f"Estimated {imt} at rx {i} is {iml_i}")
 | 
				
			||||||
                iml_grid_raw.append(iml)
 | 
					                iml_grid_raw.append(iml)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user