コード例 #1
0
def irma_efc_mainland(graph, label, imp_dict):
    """ Irma's imüact and exceedance frequency curve per mainland"""
    if label == 'British':
        all_str = ENGL
    elif label == 'French':
        all_str = FRA
    else:
        all_str = HOL

    imp_ev_info = imp_dict[ENGL[0]]

    # add at_event: events damages for every island
    imp_all = Impact()
    imp_all.frequency = imp_ev_info.frequency
    imp_all.at_event = np.zeros((imp_dict[ENGL[0]].at_event.size,))
    for ev in range(imp_all.at_event.size):
        for isl in all_str:
            imp_all.at_event[ev] += imp_dict[isl].at_event[ev]

    efc_all = imp_all.calc_freq_curve()

    irma_id = imp_ev_info.event_name.index('2017242N16333')
    dam_irma_all = imp_all.at_event[irma_id]
    dam_irma = np.array([dam_irma_all])

    f_rp = interp1d(efc_all.impact, efc_all.return_per)
    rp_irma = np.array([f_rp(dam_irma_all)])

    graph.add_curve(efc_all.return_per, efc_all.impact, '--', color=COLORS[label], label=label)
    graph.axs[graph.curr_ax].scatter(rp_irma, dam_irma, c=COLORS[label])
    graph.axs[graph.curr_ax].set_xscale('log')
    graph.axs[graph.curr_ax].set_yscale('log')

    return graph
コード例 #2
0
    def _map_impact_calc(self, sample_iterrows):
        """
        Map to compute impact for all parameter samples in parrallel

        Parameters
        ----------
        sample_iterrows : pd.DataFrame.iterrows()
            Generator of the parameter samples

        Returns
        -------
         : list
            impact metrics list for all samples containing aai_agg, rp_curve,
            eai_exp (np.array([]) if self.calc_eai_exp=False) and at_event
            (np.array([]) if self.calc_at_event=False).

        """

        # [1] only the rows of the dataframe passed by pd.DataFrame.iterrows()
        exp_samples = sample_iterrows[1][self.unc_vars['exp'].labels].to_dict()
        haz_samples = sample_iterrows[1][self.unc_vars['haz'].labels].to_dict()
        impf_samples = sample_iterrows[1][
            self.unc_vars['impf'].labels].to_dict()

        exp = self.unc_vars['exp'].uncvar_func(**exp_samples)
        haz = self.unc_vars['haz'].uncvar_func(**haz_samples)
        impf = self.unc_vars['impf'].uncvar_func(**impf_samples)

        imp = Impact()

        imp.calc(exposures=exp, impact_funcs=impf, hazard=haz)

        # Extract from climada.impact the chosen metrics
        freq_curve = imp.calc_freq_curve(self.rp).impact

        if self.calc_eai_exp:
            eai_exp = imp.eai_exp
        else:
            eai_exp = np.array([])

        if self.calc_at_event:
            at_event = imp.at_event
        else:
            at_event = np.array([])

        return [imp.aai_agg, freq_curve, eai_exp, at_event, imp.tot_value]
コード例 #3
0
                             input_folder, haz_real)
exp_meshs = fct.load_exp_agr(force_new_hdf5_generation, name_hdf5_file,
                             input_folder, haz_real)
exp_dur = exp_meshs.copy()
exp_dur["if_HL"] = exp_dur[
    "if_HL"] + 3  #change if_HL to match the corresponding imp_id
if plot_img:
    exp_infr.plot_basemap()
    #This takes to long. Do over night!!!
    #exp_agr.plot_basemap()

#%% Impact
imp_infr = Impact()
imp_infr.calc(exp_infr, ifset_hail, haz_real, save_mat=True)
# imp_infr.plot_raster_eai_exposure()
freq_curve_infr = imp_infr.calc_freq_curve()
freq_curve_infr.plot()
plt.show()

imp_agr = Impact()
imp_agr.calc(exp_meshs, ifset_hail, haz_real, save_mat=True)
freq_curve_agr = imp_agr.calc_freq_curve()
freq_curve_agr.plot()
plt.show()

imp_agr_dur = Impact()
imp_agr_dur.calc(exp_dur, ifset_hail, haz_dur, save_mat=True)
freq_curve_agr = imp_agr.calc_freq_curve()
freq_curve_agr.plot()
plt.show()
コード例 #4
0
#%% Exposure
exp_infr_meshs = fct.load_exp_infr(force_new_hdf5_generation, name_hdf5_file,
                                   input_folder, haz_real)
exp_infr_dur = exp_infr_meshs.copy()
exp_infr_dur["if_HL"] = 8  #change if_HL to match the corresponding imp_id
if plot_img:
    exp_infr_meshs.plot_basemap()
    exp_infr_meshs.plot_hexbin()
    exp_infr_meshs.plot_scatter()
    exp_infr_meshs.plot_raster()

#%% Impact
imp_infr_meshs = Impact()
imp_infr_meshs.calc(exp_infr_meshs, ifset_hail, haz_real, save_mat=True)
# imp_infr.plot_raster_eai_exposure()
freq_curve_infr_meshs = imp_infr_meshs.calc_freq_curve()  #[1, 2, 5, 10, 20])
if plot_img:
    freq_curve_infr_meshs.plot()
    imp_infr_meshs.plot_basemap_eai_exposure()
    imp_infr_meshs.plot_hexbin_eai_exposure()
    imp_infr_meshs.plot_scatter_eai_exposure()
    imp_infr_meshs.plot_raster_eai_exposure()

imp_infr_dur = Impact()
imp_infr_dur.calc(exp_infr_dur, ifset_hail, haz_dur, save_mat=True)
# imp_infr.plot_raster_eai_exposure()
freq_curve_infr_dur = imp_infr_dur.calc_freq_curve()
if plot_img:
    freq_curve_infr_dur.plot()
    imp_infr_dur.plot_basemap_eai_exposure()
    imp_infr_dur.plot_hexbin_eai_exposure()
コード例 #5
0
if plot_img:    
    exp_synth_infr_meshs.plot_basemap()
    exp_synth_infr_meshs.plot_hexbin()
    exp_synth_infr_meshs.plot_scatter()
    exp_synth_infr_meshs.plot_raster()
    
    exp_synth_agr_meshs.tag = Tag(file_name = "exp_agr", description="Exposure_description")
    exp_synth_agr_meshs.plot_basemap()
    exp_synth_agr_meshs.plot_hexbin()
    exp_synth_agr_meshs.plot_scatter()
    exp_synth_agr_meshs.plot_raster(raster_res = 0.001)

#%% Impact
imp_synth_infr_meshs = Impact()
imp_synth_infr_meshs.calc(exp_synth_infr_meshs, ifset_hail, haz_synth,save_mat=True)
freq_curve_synth_infr_meshs = imp_synth_infr_meshs.calc_freq_curve()
if plot_img:
    freq_curve_synth_infr_meshs.plot()
    imp_synth_infr_meshs.plot_basemap_eai_exposure()
    imp_synth_infr_meshs.plot_hexbin_eai_exposure()
    imp_synth_infr_meshs.plot_scatter_eai_exposure()
    imp_synth_infr_meshs.plot_raster_eai_exposure(raster_res = 0.001)

imp_synth_agr_meshs = Impact()
imp_synth_agr_meshs.calc(exp_synth_agr_meshs, ifset_hail, haz_synth, save_mat=True)
freq_curve_synth_agr_meshs = imp_synth_agr_meshs.calc_freq_curve()
if plot_img:
    freq_curve_synth_agr_meshs.plot()
    imp_synth_agr_meshs.plot_basemap_eai_exposure()
    imp_synth_agr_meshs.plot_hexbin_eai_exposure()
    imp_synth_agr_meshs.plot_scatter_eai_exposure()
コード例 #6
0
exp_meshs = fct.load_exp_agr(force_new_hdf5_generation, name_hdf5_file,
                             input_folder, haz_real)
exp_dur = exp_meshs.copy()
exp_dur["if_HL"] = exp_dur[
    "if_HL"] + 3  #change if_HL to match the corresponding imp_id
if plot_img:
    exp_meshs.tag = Tag(file_name="exp_agr",
                        description="Exposure_description")
    exp_meshs.plot_basemap()
    exp_meshs.plot_hexbin()
    exp_meshs.plot_scatter()
    exp_meshs.plot_raster(raster_res=0.001)
#%% Impact
imp_agr_meshs = Impact()
imp_agr_meshs.calc(exp_meshs, ifset_hail, haz_real, save_mat=True)
freq_curve_meshs_agr = imp_agr_meshs.calc_freq_curve()
if plot_img:
    freq_curve_meshs_agr.plot()
    imp_agr_meshs.plot_basemap_eai_exposure()
    imp_agr_meshs.plot_hexbin_eai_exposure()
    imp_agr_meshs.plot_scatter_eai_exposure()
    imp_agr_meshs.plot_raster_eai_exposure(raster_res=0.001)

imp_agr_dur = Impact()
imp_agr_dur.calc(exp_dur, ifset_hail, haz_dur, save_mat=True)
freq_curve_dur_agr = imp_agr_dur.calc_freq_curve()
if plot_img:
    freq_curve_dur_agr.plot()
    imp_agr_dur.plot_basemap_eai_exposure()
    imp_agr_dur.plot_hexbin_eai_exposure()
    imp_agr_dur.plot_scatter_eai_exposure()