yy_start = 106 yy_end = 116 idx_band = 1 exp = Exposures() ssp_file = EXP_POP_PTH +'baseYr_total_2000.tif' exp.set_from_raster(ssp_file, transform=DST_META['transform'], height=DST_META['height'], width=DST_META['width'], resampling=Resampling.average) exp.value *= 25 # sum of the grids after upscaling if np.any(exp.value<0) == True: raise ValueError exp.value_unit = 'N people per pixel' exp.ref_year = 2000 exp[INDICATOR_CENTR+HAZ_TYPE] = np.arange(len(exp), dtype=int) exp[INDICATOR_IF+HAZ_TYPE] = np.ones(len(exp), dtype=int) exp.check() for year in YEAR: imp_model = [] # initite a list fro all models in one year imp_save = None for hydro, gcm in [(hydro, gcm) for hydro in HYDRO_MODEL for gcm in GCM_MODEL]: haz_file = HAZARD_PTH +'flddph_' +hydro +'_' +gcm +'_' +RCP +'_flopros_gev_picontrol_2006_2300_0.1.nc' haz_frac = HAZARD_PTH +'fldfrc_' +hydro +'_' +gcm +'_' +RCP +'_flopros_gev_picontrol_2006_2300_0.1.nc'
avg_value_ackerbau = value_ackerbau / exp_hail_agr[exp_hail_agr["region_id"] == 221].shape[0] a = exp_hail_agr[exp_hail_agr["region_id"] == 201].assign(value=avg_value_obst) b = exp_hail_agr[exp_hail_agr["region_id"] == 202].assign( value=avg_value_rebbau) c = exp_hail_agr[exp_hail_agr["region_id"] == 221].assign( value=avg_value_ackerbau) exp_hail_agr = pd.concat([a, b, c]).sort_index() exp_hail_agr = Exposures(exp_hail_agr) exp_hail_agr.loc[exp_hail_agr["region_id"] == 201, "if_"] = int(3) exp_hail_agr.loc[exp_hail_agr["region_id"] == 202, "if_"] = int(2) exp_hail_agr.loc[exp_hail_agr["region_id"] == 221, "if_"] = int(4) exp_hail_agr = exp_hail_agr.rename(columns={'if_': 'if_HL'}) exp_hail_agr.check() exp_hail_agr.head() exp_hail_agr.value_unit = "CHF" exp_hail_agr.write_hdf5(input_folder + "/exp_agr_no_centr.hdf5") test = exp_hail_agr[exp_hail_agr["value"] > 0] plt.scatter(test[test["region_id"].isin([221, 222, 223])]["longitude"], test[test["region_id"].isin([221, 222, 223])]["latitude"]) plt.scatter(test[test["region_id"] == 201]["longitude"], test[test["region_id"] == 201]["latitude"]) plt.scatter(test[test["region_id"] == 202]["longitude"], test[test["region_id"] == 202]["latitude"]) plt.legend(labels=["Acker - Futterbau", "Obstbau", "Rebbau"])