eliminate manual country code conversion, adjust mock_snakemake to ll wildcard
This commit is contained in:
parent
fe43246522
commit
483f3e1b82
@ -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
|
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
|
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
|
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
|
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
|
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
|
IRENA existing VRE capacities,existing_infrastructure/{solar|onwind|offwind}_capcity_IRENA.csv,unknown,https://www.irena.org/Statistics/Download-Data
|
||||||
|
|
@ -120,7 +120,6 @@ rule plot_summary:
|
|||||||
energy=RESULTS + "csvs/energy.csv",
|
energy=RESULTS + "csvs/energy.csv",
|
||||||
balances=RESULTS + "csvs/supply_energy.csv",
|
balances=RESULTS + "csvs/supply_energy.csv",
|
||||||
eurostat=input_eurostat,
|
eurostat=input_eurostat,
|
||||||
country_codes="data/Country_codes.csv",
|
|
||||||
output:
|
output:
|
||||||
costs=RESULTS + "graphs/costs.pdf",
|
costs=RESULTS + "graphs/costs.pdf",
|
||||||
energy=RESULTS + "graphs/energy.pdf",
|
energy=RESULTS + "graphs/energy.pdf",
|
||||||
|
@ -16,7 +16,6 @@ rule add_existing_baseyear:
|
|||||||
cop_soil_total=RESOURCES + "cop_soil_total_elec_s{simpl}_{clusters}.nc",
|
cop_soil_total=RESOURCES + "cop_soil_total_elec_s{simpl}_{clusters}.nc",
|
||||||
cop_air_total=RESOURCES + "cop_air_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",
|
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_solar="data/existing_infrastructure/solar_capacity_IRENA.csv",
|
||||||
existing_onwind="data/existing_infrastructure/onwind_capacity_IRENA.csv",
|
existing_onwind="data/existing_infrastructure/onwind_capacity_IRENA.csv",
|
||||||
existing_offwind="data/existing_infrastructure/offwind_capacity_IRENA.csv",
|
existing_offwind="data/existing_infrastructure/offwind_capacity_IRENA.csv",
|
||||||
|
@ -131,7 +131,7 @@ if __name__ == "__main__":
|
|||||||
simpl="",
|
simpl="",
|
||||||
clusters="37",
|
clusters="37",
|
||||||
opts="",
|
opts="",
|
||||||
lv=1.0,
|
ll='v1.0',
|
||||||
sector_opts="168H-T-H-B-I-solar+p3-dist1",
|
sector_opts="168H-T-H-B-I-solar+p3-dist1",
|
||||||
planning_horizons=2030,
|
planning_horizons=2030,
|
||||||
)
|
)
|
||||||
|
@ -16,9 +16,12 @@ from types import SimpleNamespace
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
import pypsa
|
import pypsa
|
||||||
import xarray as xr
|
import xarray as xr
|
||||||
|
import country_converter as coco
|
||||||
from _helpers import override_component_attrs, update_config_with_sector_opts
|
from _helpers import override_component_attrs, update_config_with_sector_opts
|
||||||
from prepare_sector_network import cluster_heat_buses, define_spatial, prepare_costs
|
from prepare_sector_network import cluster_heat_buses, define_spatial, prepare_costs
|
||||||
|
|
||||||
|
cc = coco.CountryConverter()
|
||||||
|
|
||||||
spatial = SimpleNamespace()
|
spatial = SimpleNamespace()
|
||||||
|
|
||||||
|
|
||||||
@ -55,8 +58,6 @@ def add_existing_renewables(df_agg):
|
|||||||
power plants.
|
power plants.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
cc = pd.read_csv(snakemake.input.country_codes, index_col=0)
|
|
||||||
|
|
||||||
carriers = {"solar": "solar", "onwind": "onwind", "offwind": "offwind-ac"}
|
carriers = {"solar": "solar", "onwind": "onwind", "offwind": "offwind-ac"}
|
||||||
|
|
||||||
for tech in ["solar", "onwind", "offwind"]:
|
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 = pd.read_csv(snakemake.input[f"existing_{tech}"], index_col=0).fillna(0.0)
|
||||||
df.columns = df.columns.astype(int)
|
df.columns = df.columns.astype(int)
|
||||||
|
df.index = cc.convert(df.index, to='iso2')
|
||||||
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)
|
|
||||||
|
|
||||||
# calculate yearly differences
|
# calculate yearly differences
|
||||||
df.insert(loc=0, value=0.0, column="1999")
|
df.insert(loc=0, value=0.0, column="1999")
|
||||||
@ -422,9 +413,7 @@ def add_heating_capacities_installed_before_baseyear(
|
|||||||
# convert GW to MW
|
# convert GW to MW
|
||||||
df *= 1e3
|
df *= 1e3
|
||||||
|
|
||||||
cc = pd.read_csv(snakemake.input.country_codes, index_col=0)
|
df.index = cc.convert(df.index, to='iso2')
|
||||||
|
|
||||||
df.rename(index=cc["2 letter code (ISO-3166-2)"], inplace=True)
|
|
||||||
|
|
||||||
# coal and oil boilers are assimilated to oil boilers
|
# coal and oil boilers are assimilated to oil boilers
|
||||||
df["oil boiler"] = df["oil boiler"] + df["coal boiler"]
|
df["oil boiler"] = df["oil boiler"] + df["coal boiler"]
|
||||||
@ -611,7 +600,7 @@ if __name__ == "__main__":
|
|||||||
"add_existing_baseyear",
|
"add_existing_baseyear",
|
||||||
simpl="",
|
simpl="",
|
||||||
clusters="45",
|
clusters="45",
|
||||||
lv=1.0,
|
ll='v1.0',
|
||||||
opts="",
|
opts="",
|
||||||
sector_opts="8760H-T-H-B-I-A-solar+p3-dist1",
|
sector_opts="8760H-T-H-B-I-A-solar+p3-dist1",
|
||||||
planning_horizons=2020,
|
planning_horizons=2020,
|
||||||
|
@ -1038,7 +1038,7 @@ if __name__ == "__main__":
|
|||||||
"build_retro_cost",
|
"build_retro_cost",
|
||||||
simpl="",
|
simpl="",
|
||||||
clusters=48,
|
clusters=48,
|
||||||
lv=1.0,
|
ll='v1.0',
|
||||||
sector_opts="Co2L0-168H-T-H-B-I-solar3-dist1",
|
sector_opts="Co2L0-168H-T-H-B-I-solar3-dist1",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -917,7 +917,7 @@ if __name__ == "__main__":
|
|||||||
"plot_network",
|
"plot_network",
|
||||||
simpl="",
|
simpl="",
|
||||||
clusters="181",
|
clusters="181",
|
||||||
lv="opt",
|
ll="vopt",
|
||||||
opts="",
|
opts="",
|
||||||
sector_opts="Co2L0-730H-T-H-B-I-A-solar+p3-linemaxext10",
|
sector_opts="Co2L0-730H-T-H-B-I-A-solar+p3-linemaxext10",
|
||||||
planning_horizons="2050",
|
planning_horizons="2050",
|
||||||
|
@ -345,7 +345,7 @@ def plot_balances():
|
|||||||
plt.cla()
|
plt.cla()
|
||||||
|
|
||||||
|
|
||||||
def historical_emissions(cts):
|
def historical_emissions(countries):
|
||||||
"""
|
"""
|
||||||
Read historical emissions to add them to the carbon budget plot.
|
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)"
|
e["total woL"] = "Total (without LULUCF)"
|
||||||
|
|
||||||
pol = ["CO2"] # ["All greenhouse gases - (CO2 equivalent)"]
|
pol = ["CO2"] # ["All greenhouse gases - (CO2 equivalent)"]
|
||||||
cts
|
if "GB" in countries:
|
||||||
if "GB" in cts:
|
countries.remove("GB")
|
||||||
cts.remove("GB")
|
countries.append("UK")
|
||||||
cts.append("UK")
|
|
||||||
|
|
||||||
year = np.arange(1990, 2018).tolist()
|
year = np.arange(1990, 2018).tolist()
|
||||||
|
|
||||||
idx = pd.IndexSlice
|
idx = pd.IndexSlice
|
||||||
co2_totals = (
|
co2_totals = (
|
||||||
df.loc[idx[year, e.values, cts, pol], "emissions"]
|
df.loc[idx[year, e.values, countries, pol], "emissions"]
|
||||||
.unstack("Year")
|
.unstack("Year")
|
||||||
.rename(index=pd.Series(e.index, e.values))
|
.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])
|
ax1.set_xlim([1990, snakemake.config["scenario"]["planning_horizons"][-1] + 1])
|
||||||
|
|
||||||
path_cb = "results/" + snakemake.params.RDIR + "/csvs/"
|
path_cb = "results/" + snakemake.params.RDIR + "/csvs/"
|
||||||
countries = pd.read_csv(snakemake.input.country_codes, index_col=1)
|
countries = snakemake.confing["countries"]
|
||||||
cts = countries.index.to_list()
|
e_1990 = co2_emissions_year(countries, input_eurostat, opts, year=1990)
|
||||||
e_1990 = co2_emissions_year(cts, input_eurostat, opts, year=1990)
|
|
||||||
CO2_CAP = pd.read_csv(path_cb + "carbon_budget_distribution.csv", index_col=0)
|
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)
|
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)
|
ax1.plot(emissions, color="black", linewidth=3, label=None)
|
||||||
|
|
||||||
|
@ -3234,7 +3234,7 @@ if __name__ == "__main__":
|
|||||||
simpl="",
|
simpl="",
|
||||||
opts="",
|
opts="",
|
||||||
clusters="37",
|
clusters="37",
|
||||||
lv=1.5,
|
ll='v1.5',
|
||||||
sector_opts="cb40ex0-365H-T-H-B-I-A-solar+p3-dist1",
|
sector_opts="cb40ex0-365H-T-H-B-I-A-solar+p3-dist1",
|
||||||
planning_horizons="2020",
|
planning_horizons="2020",
|
||||||
)
|
)
|
||||||
|
@ -325,7 +325,7 @@ if __name__ == "__main__":
|
|||||||
simpl="",
|
simpl="",
|
||||||
opts="",
|
opts="",
|
||||||
clusters="45",
|
clusters="45",
|
||||||
lv=1.0,
|
ll='v1.0',
|
||||||
sector_opts="8760H-T-H-B-I-A-solar+p3-dist1",
|
sector_opts="8760H-T-H-B-I-A-solar+p3-dist1",
|
||||||
planning_horizons="2020",
|
planning_horizons="2020",
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user