add non-parallel processing and set as default; fix colourbar
This commit is contained in:
parent
7a39d5a07e
commit
f1472bf250
@ -439,22 +439,40 @@ verbose: {verbose}")
|
|||||||
|
|
||||||
PGA = np.zeros(shape=(nx * ny))
|
PGA = np.zeros(shape=(nx * ny))
|
||||||
|
|
||||||
# use dask parallel computing
|
|
||||||
start = timer()
|
|
||||||
pbar = ProgressBar()
|
|
||||||
pbar.register()
|
|
||||||
# iter = range(0,len(distances))
|
|
||||||
iter = indices
|
|
||||||
iml_grid_raw = [] # raw ground motion grids
|
|
||||||
for imt in products:
|
|
||||||
logger.info(f"Estimating {imt}")
|
|
||||||
|
|
||||||
imls = [dask.delayed(compute_IMT_exceedance)(rx_lat[i], rx_lon[i], distances[i].flatten(), fr, p, lambdas,
|
start = timer()
|
||||||
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,
|
use_pp = False
|
||||||
rx_label=i) for i in iter]
|
|
||||||
iml = dask.compute(*imls)
|
if use_pp: # use dask parallel computing
|
||||||
iml_grid_raw.append(list(iml))
|
pbar = ProgressBar()
|
||||||
|
pbar.register()
|
||||||
|
# iter = range(0,len(distances))
|
||||||
|
iter = indices
|
||||||
|
iml_grid_raw = [] # raw ground motion grids
|
||||||
|
for imt in products:
|
||||||
|
logger.info(f"Estimating {imt}")
|
||||||
|
|
||||||
|
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]
|
||||||
|
iml = dask.compute(*imls)
|
||||||
|
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)
|
||||||
|
Loading…
Reference in New Issue
Block a user