def plot_event(name, ifset_hail, haz_real, haz_dur, exp_infr, exp_meshs, exp_dur, plot_img): print("Event Analysis for {}".format(name)) ev_id = haz_real.get_event_id(event_name=name) meshs_intensity = haz_real.intensity[ev_id].todense().astype(int) meshs_intensity_no_0 = np.array( meshs_intensity[meshs_intensity != 0]).ravel() #remove outliers meshs_intensity_no_0 = np.delete(meshs_intensity_no_0, np.where(meshs_intensity_no_0 == 244)) dur_intensity = haz_dur.intensity[ev_id].todense().astype(int) dur_intensity_no_0 = np.array(dur_intensity[dur_intensity != 0]).ravel() fig, axs = plt.subplots(1, 2, sharey=False, tight_layout=False) fig.suptitle("Histogramm event {}".format(name)) axs[0].hist(meshs_intensity_no_0, bins=25) axs[1].hist(dur_intensity_no_0) axs[0].set(xlabel="meshs [mm]", ylabel="frequency") axs[1].set(xlabel="duration [min]", ylabel="frequency") axs[0].locator_params(axis="y", integer=True) axs[1].locator_params(axis="y", integer=True) fig.subplots_adjust(wspace=0.35) plt.show() haz_real.plot_intensity(event=ev_id) plt.show() haz_real_ev = haz_real.select(event_names=[name]) haz_dur_ev = haz_dur.select(event_names=[name]) imp_agr_real_ev = Impact() imp_agr_dur_ev = Impact() imp_infr_real_ev = Impact() imp_agr_real_ev.calc(exp_meshs, ifset_hail, haz_real_ev, save_mat=True) imp_agr_dur_ev.calc(exp_dur, ifset_hail, haz_dur_ev, save_mat=True) imp_infr_real_ev.calc(exp_infr, ifset_hail, haz_real_ev, save_mat=True) print("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX") print( "Meshs on agr at event {}: at_event: {} mio; aai_agg: {} mio; eai_exp: {} mio" .format(name, imp_agr_real_ev.at_event / 1e6, imp_agr_real_ev.aai_agg / 1e6, imp_agr_real_ev.eai_exp / 1e6)) print( "Duration on agr at event {}: at_event: {} mio; aai_agg: {} mio; eai_exp: {} mio" .format(name, imp_agr_dur_ev.at_event / 1e6, imp_agr_dur_ev.aai_agg / 1e6, imp_agr_dur_ev.eai_exp / 1e6)) print( "Meshs on infr at event {}: at_event: {} mio; aai_agg: {} mio; eai_exp: {} mio" .format(name, imp_infr_real_ev.at_event / 1e6, imp_infr_real_ev.aai_agg / 1e6, imp_infr_real_ev.eai_exp / 1e6)) print("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX") if plot_img: imp_agr_real_ev.plot_basemap_impact_exposure() imp_agr_real_ev.plot_hexbin_impact_exposure() imp_agr_dur_ev.plot_basemap_impact_exposure() imp_agr_dur_ev.plot_hexbin_impact_exposure()
imp_agr = Impact() imp_agr.calc(exp_meshs, ifset_hail, haz_real, save_mat=True) freq_curve_agr = imp_agr.calc_freq_curve() if plot_img: freq_curve_agr.plot() imp_agr_dur = Impact() imp_agr_dur.calc(exp_dur, ifset_hail, haz_dur, save_mat=True) freq_curve_agr_dur = imp_agr.calc_freq_curve() if plot_img: freq_curve_agr_dur.plot() if plot_img: for ev_name in ev_list: imp_infr.plot_basemap_impact_exposure(event_id=haz_real.get_event_id( event_name=ev_name)[0]) imp_agr.plot_basemap_impact_exposure(event_id=haz_real.get_event_id( event_name=ev_name)[0]) imp_agr_dur.plot_basemap_impact_exposure( event_id=haz_real.get_event_id(event_name=ev_name)[0]) imp_infr.plot_hexbin_impact_exposure(event_id=haz_real.get_event_id( event_name=ev_name)[0]) imp_agr.plot_hexbin_impact_exposure(event_id=haz_real.get_event_id( event_name=ev_name)[0]) imp_agr_dur.plot_basemap_impact_exposure( event_id=haz_real.get_event_id(event_name=ev_name)[0]) print( "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX") print("I'm done with the script")