diff --git a/doc/data.csv b/doc/data.csv index 0efed84d..d65d3b36 100644 --- a/doc/data.csv +++ b/doc/data.csv @@ -10,7 +10,6 @@ BASt emobility statistics,emobility/,unknown,http://www.bast.de/DE/Verkehrstechn BDEW heating profile,heat_load_profile_BDEW.csv,unknown,https://github.com/oemof/demandlib heating profiles for Aarhus,heat_load_profile_DK_AdamJensen.csv,unknown,Adam Jensen MA thesis at Aarhus University George Lavidas wind/wave costs,WindWaveWEC_GLTB.xlsx,unknown,George Lavidas -country codes,Country_codes.csv,CC BY 4.0,Marta Victoria co2 budgets,co2_budget.csv,CC BY 4.0,https://arxiv.org/abs/2004.11009 existing heating potentials,existing_infrastructure/existing_heating_raw.csv,unknown,https://ec.europa.eu/energy/studies/mapping-and-analyses-current-and-future-2020-2030-heatingcooling-fuel-deployment_en?redir=1 IRENA existing VRE capacities,existing_infrastructure/{solar|onwind|offwind}_capcity_IRENA.csv,unknown,https://www.irena.org/Statistics/Download-Data diff --git a/rules/postprocess.smk b/rules/postprocess.smk index e6aa9e6c..d5095358 100644 --- a/rules/postprocess.smk +++ b/rules/postprocess.smk @@ -120,7 +120,6 @@ rule plot_summary: energy=RESULTS + "csvs/energy.csv", balances=RESULTS + "csvs/supply_energy.csv", eurostat=input_eurostat, - country_codes="data/Country_codes.csv", output: costs=RESULTS + "graphs/costs.pdf", energy=RESULTS + "graphs/energy.pdf", diff --git a/rules/solve_myopic.smk b/rules/solve_myopic.smk index be44f325..b0085d7d 100644 --- a/rules/solve_myopic.smk +++ b/rules/solve_myopic.smk @@ -16,7 +16,6 @@ rule add_existing_baseyear: cop_soil_total=RESOURCES + "cop_soil_total_elec_s{simpl}_{clusters}.nc", cop_air_total=RESOURCES + "cop_air_total_elec_s{simpl}_{clusters}.nc", existing_heating="data/existing_infrastructure/existing_heating_raw.csv", - country_codes="data/Country_codes.csv", existing_solar="data/existing_infrastructure/solar_capacity_IRENA.csv", existing_onwind="data/existing_infrastructure/onwind_capacity_IRENA.csv", existing_offwind="data/existing_infrastructure/offwind_capacity_IRENA.csv", diff --git a/scripts/add_brownfield.py b/scripts/add_brownfield.py index 96360509..2f759b5a 100644 --- a/scripts/add_brownfield.py +++ b/scripts/add_brownfield.py @@ -131,7 +131,7 @@ if __name__ == "__main__": simpl="", clusters="37", opts="", - lv=1.0, + ll='v1.0', sector_opts="168H-T-H-B-I-solar+p3-dist1", planning_horizons=2030, ) diff --git a/scripts/add_existing_baseyear.py b/scripts/add_existing_baseyear.py index 89215bad..ea2d5028 100644 --- a/scripts/add_existing_baseyear.py +++ b/scripts/add_existing_baseyear.py @@ -16,9 +16,12 @@ from types import SimpleNamespace import numpy as np import pypsa import xarray as xr +import country_converter as coco from _helpers import override_component_attrs, update_config_with_sector_opts from prepare_sector_network import cluster_heat_buses, define_spatial, prepare_costs +cc = coco.CountryConverter() + spatial = SimpleNamespace() @@ -55,8 +58,6 @@ def add_existing_renewables(df_agg): power plants. """ - cc = pd.read_csv(snakemake.input.country_codes, index_col=0) - carriers = {"solar": "solar", "onwind": "onwind", "offwind": "offwind-ac"} for tech in ["solar", "onwind", "offwind"]: @@ -64,17 +65,7 @@ def add_existing_renewables(df_agg): df = pd.read_csv(snakemake.input[f"existing_{tech}"], index_col=0).fillna(0.0) df.columns = df.columns.astype(int) - - rename_countries = { - "Czechia": "Czech Republic", - "UK": "United Kingdom", - "Bosnia Herzg": "Bosnia Herzegovina", - "North Macedonia": "Macedonia", - } - - df.rename(index=rename_countries, inplace=True) - - df.rename(index=cc["2 letter code (ISO-3166-2)"], inplace=True) + df.index = cc.convert(df.index, to='iso2') # calculate yearly differences df.insert(loc=0, value=0.0, column="1999") @@ -422,9 +413,7 @@ def add_heating_capacities_installed_before_baseyear( # convert GW to MW df *= 1e3 - cc = pd.read_csv(snakemake.input.country_codes, index_col=0) - - df.rename(index=cc["2 letter code (ISO-3166-2)"], inplace=True) + df.index = cc.convert(df.index, to='iso2') # coal and oil boilers are assimilated to oil boilers df["oil boiler"] = df["oil boiler"] + df["coal boiler"] @@ -611,7 +600,7 @@ if __name__ == "__main__": "add_existing_baseyear", simpl="", clusters="45", - lv=1.0, + ll='v1.0', opts="", sector_opts="8760H-T-H-B-I-A-solar+p3-dist1", planning_horizons=2020, diff --git a/scripts/build_retro_cost.py b/scripts/build_retro_cost.py index b5dcbc94..de0ccc16 100644 --- a/scripts/build_retro_cost.py +++ b/scripts/build_retro_cost.py @@ -1038,7 +1038,7 @@ if __name__ == "__main__": "build_retro_cost", simpl="", clusters=48, - lv=1.0, + ll='v1.0', sector_opts="Co2L0-168H-T-H-B-I-solar3-dist1", ) diff --git a/scripts/plot_network.py b/scripts/plot_network.py index 9e5b1864..9c5576f7 100644 --- a/scripts/plot_network.py +++ b/scripts/plot_network.py @@ -917,7 +917,7 @@ if __name__ == "__main__": "plot_network", simpl="", clusters="181", - lv="opt", + ll="vopt", opts="", sector_opts="Co2L0-730H-T-H-B-I-A-solar+p3-linemaxext10", planning_horizons="2050", diff --git a/scripts/plot_summary.py b/scripts/plot_summary.py index 9af1e09e..d7293715 100644 --- a/scripts/plot_summary.py +++ b/scripts/plot_summary.py @@ -345,7 +345,7 @@ def plot_balances(): plt.cla() -def historical_emissions(cts): +def historical_emissions(countries): """ Read historical emissions to add them to the carbon budget plot. """ @@ -380,16 +380,15 @@ def historical_emissions(cts): e["total woL"] = "Total (without LULUCF)" pol = ["CO2"] # ["All greenhouse gases - (CO2 equivalent)"] - cts - if "GB" in cts: - cts.remove("GB") - cts.append("UK") + if "GB" in countries: + countries.remove("GB") + countries.append("UK") year = np.arange(1990, 2018).tolist() idx = pd.IndexSlice co2_totals = ( - df.loc[idx[year, e.values, cts, pol], "emissions"] + df.loc[idx[year, e.values, countries, pol], "emissions"] .unstack("Year") .rename(index=pd.Series(e.index, e.values)) ) @@ -457,14 +456,13 @@ def plot_carbon_budget_distribution(input_eurostat): ax1.set_xlim([1990, snakemake.config["scenario"]["planning_horizons"][-1] + 1]) path_cb = "results/" + snakemake.params.RDIR + "/csvs/" - countries = pd.read_csv(snakemake.input.country_codes, index_col=1) - cts = countries.index.to_list() - e_1990 = co2_emissions_year(cts, input_eurostat, opts, year=1990) + countries = snakemake.confing["countries"] + e_1990 = co2_emissions_year(countries, input_eurostat, opts, year=1990) CO2_CAP = pd.read_csv(path_cb + "carbon_budget_distribution.csv", index_col=0) ax1.plot(e_1990 * CO2_CAP[o], linewidth=3, color="dodgerblue", label=None) - emissions = historical_emissions(cts) + emissions = historical_emissions(countries) ax1.plot(emissions, color="black", linewidth=3, label=None) diff --git a/scripts/prepare_sector_network.py b/scripts/prepare_sector_network.py index 00042d80..af94292b 100644 --- a/scripts/prepare_sector_network.py +++ b/scripts/prepare_sector_network.py @@ -3234,7 +3234,7 @@ if __name__ == "__main__": simpl="", opts="", clusters="37", - lv=1.5, + ll='v1.5', sector_opts="cb40ex0-365H-T-H-B-I-A-solar+p3-dist1", planning_horizons="2020", ) diff --git a/scripts/solve_sector_network.py b/scripts/solve_sector_network.py index a3d3333a..0354dd61 100644 --- a/scripts/solve_sector_network.py +++ b/scripts/solve_sector_network.py @@ -325,7 +325,7 @@ if __name__ == "__main__": simpl="", opts="", clusters="45", - lv=1.0, + ll='v1.0', sector_opts="8760H-T-H-B-I-A-solar+p3-dist1", planning_horizons="2020", )