add non-parallel processing and set as default; fix colourbar
This commit is contained in:
		@@ -439,8 +439,12 @@ verbose: {verbose}")
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        PGA = np.zeros(shape=(nx * ny))
 | 
					        PGA = np.zeros(shape=(nx * ny))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        # use dask parallel computing
 | 
					
 | 
				
			||||||
        start = timer()
 | 
					        start = timer()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        use_pp = False
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        if use_pp:         # use dask parallel computing
 | 
				
			||||||
            pbar = ProgressBar()
 | 
					            pbar = ProgressBar()
 | 
				
			||||||
            pbar.register()
 | 
					            pbar.register()
 | 
				
			||||||
            # iter = range(0,len(distances))
 | 
					            # iter = range(0,len(distances))
 | 
				
			||||||
@@ -452,9 +456,23 @@ 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,
 | 
					                                                            log_level=logging.DEBUG, imt=imt, IMT_min=0.0, IMT_max=2.0,
 | 
				
			||||||
                                                         rx_label=i) for i in iter]
 | 
					                                                            rx_label=i, 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))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        else:
 | 
				
			||||||
 | 
					            iml_grid_raw = []
 | 
				
			||||||
 | 
					            iter = indices
 | 
				
			||||||
 | 
					            for imt in products:
 | 
				
			||||||
 | 
					                iml = []
 | 
				
			||||||
 | 
					                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)
 | 
				
			||||||
 | 
					                    iml.append(iml_i)
 | 
				
			||||||
 | 
					                    logger.info(f"Estimated {imt} at rx {i} is {iml_i}")
 | 
				
			||||||
 | 
					                iml_grid_raw.append(iml)
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
        end = timer()
 | 
					        end = timer()
 | 
				
			||||||
        logger.info(f"Ground motion exceedance computation time: {round(end - start, 1)} seconds")
 | 
					        logger.info(f"Ground motion exceedance computation time: {round(end - start, 1)} seconds")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -530,7 +548,7 @@ verbose: {verbose}")
 | 
				
			|||||||
            tick_positions = np.linspace(vmin, vmax, num_ticks)
 | 
					            tick_positions = np.linspace(vmin, vmax, num_ticks)
 | 
				
			||||||
            ax.set_yticks(tick_positions)
 | 
					            ax.set_yticks(tick_positions)
 | 
				
			||||||
            ax.set_yticklabels([f"{tick:.2f}" for tick in tick_positions])  # format tick labels
 | 
					            ax.set_yticklabels([f"{tick:.2f}" for tick in tick_positions])  # format tick labels
 | 
				
			||||||
            ax.set_title(imt, pad=15)
 | 
					            ax.set_title(products[j], pad=15)
 | 
				
			||||||
            fig.subplots_adjust(left=0.25, right=0.75, bottom=0.05, top=0.95)  # Adjust Layout
 | 
					            fig.subplots_adjust(left=0.25, right=0.75, bottom=0.05, top=0.95)  # Adjust Layout
 | 
				
			||||||
            fig.savefig("colorbar_" + str(j) + ".svg", bbox_inches='tight')
 | 
					            fig.savefig("colorbar_" + str(j) + ".svg", bbox_inches='tight')
 | 
				
			||||||
            plt.close(fig)
 | 
					            plt.close(fig)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user