add coke oven transformation output
This commit is contained in:
parent
fe9185ef3f
commit
c5256c1f37
@ -301,6 +301,7 @@ rule build_energy_totals:
|
|||||||
eurostat="data/eurostat/Balances-April2023",
|
eurostat="data/eurostat/Balances-April2023",
|
||||||
eurostat_households="data/eurostat/eurostat-household_energy_balances-february_2024.csv",
|
eurostat_households="data/eurostat/eurostat-household_energy_balances-february_2024.csv",
|
||||||
output:
|
output:
|
||||||
|
transformation_output_coke=resources("transformation_output_coke.csv"),
|
||||||
energy_name=resources("energy_totals.csv"),
|
energy_name=resources("energy_totals.csv"),
|
||||||
co2_name=resources("co2_totals.csv"),
|
co2_name=resources("co2_totals.csv"),
|
||||||
transport_name=resources("transport_data.csv"),
|
transport_name=resources("transport_data.csv"),
|
||||||
@ -666,6 +667,7 @@ rule build_industrial_energy_demand_per_country_today:
|
|||||||
countries=config_provider("countries"),
|
countries=config_provider("countries"),
|
||||||
industry=config_provider("industry"),
|
industry=config_provider("industry"),
|
||||||
input:
|
input:
|
||||||
|
transformation_output_coke=resources("transformation_output_coke.csv"),
|
||||||
jrc="data/jrc-idees-2021",
|
jrc="data/jrc-idees-2021",
|
||||||
industrial_production_per_country=resources(
|
industrial_production_per_country=resources(
|
||||||
"industrial_production_per_country.csv"
|
"industrial_production_per_country.csv"
|
||||||
|
@ -1473,6 +1473,31 @@ def update_residential_from_eurostat(energy: pd.DataFrame) -> pd.DataFrame:
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def build_transformation_output_coke(eurostat, fn):
|
||||||
|
"""
|
||||||
|
Extracts and builds the transformation output data for coke ovens from the
|
||||||
|
Eurostat dataset.
|
||||||
|
|
||||||
|
This function specifically filters the Eurostat data to extract
|
||||||
|
transformation output related to coke ovens.
|
||||||
|
Since the transformation output for coke ovens
|
||||||
|
is not included in the final energy consumption of the iron and steel sector,
|
||||||
|
it needs to be processed and added separately. The filtered data is saved
|
||||||
|
as a CSV file.
|
||||||
|
|
||||||
|
Parameters:
|
||||||
|
eurostat (pd.DataFrame): A pandas DataFrame containing Eurostat data with
|
||||||
|
a multi-level index
|
||||||
|
fn (str): The file path where the resulting CSV file should be saved.
|
||||||
|
|
||||||
|
Output:
|
||||||
|
The resulting transformation output data for coke ovens is saved as a CSV
|
||||||
|
file at the path specified in fn.
|
||||||
|
"""
|
||||||
|
slicer = pd.IndexSlice[:,:,:, "Coke ovens", "Other sources", :]
|
||||||
|
df = eurostat.loc[slicer, :].droplevel(level=[2,3,4,5])
|
||||||
|
df.to_csv(fn)
|
||||||
|
|
||||||
# %%
|
# %%
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
if "snakemake" not in globals():
|
if "snakemake" not in globals():
|
||||||
@ -1498,6 +1523,10 @@ if __name__ == "__main__":
|
|||||||
nprocesses=snakemake.threads,
|
nprocesses=snakemake.threads,
|
||||||
disable_progressbar=snakemake.config["run"].get("disable_progressbar", False),
|
disable_progressbar=snakemake.config["run"].get("disable_progressbar", False),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
build_transformation_output_coke(eurostat,
|
||||||
|
snakemake.output.transformation_output_coke)
|
||||||
|
|
||||||
swiss = build_swiss()
|
swiss = build_swiss()
|
||||||
idees = build_idees(idees_countries)
|
idees = build_idees(idees_countries)
|
||||||
|
|
||||||
|
@ -227,6 +227,18 @@ def industrial_energy_demand(countries, year):
|
|||||||
return pd.concat(demand_l, keys=countries)
|
return pd.concat(demand_l, keys=countries)
|
||||||
|
|
||||||
|
|
||||||
|
def add_coke_ovens(demand, fn, year):
|
||||||
|
df = pd.read_csv(fn, index_col=[0,1]).xs(year, level=1)
|
||||||
|
df = df.rename(columns={'Total all products':'Total'})[fuels.keys()]
|
||||||
|
df = df.rename(columns=fuels).T.groupby(level=0).sum().T
|
||||||
|
df["other"] = df["all"] - df.loc[:,df.columns != "all"].sum(axis=1)
|
||||||
|
df = df.T.reindex_like(demand.xs("Integrated steelworks", axis=1, level=1)).fillna(0)
|
||||||
|
sel = demand.columns.get_level_values(1)=="Integrated steelworks"
|
||||||
|
demand.loc[:,sel] += 0.75 * df.values
|
||||||
|
|
||||||
|
return demand
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
if "snakemake" not in globals():
|
if "snakemake" not in globals():
|
||||||
from _helpers import mock_snakemake
|
from _helpers import mock_snakemake
|
||||||
@ -253,6 +265,10 @@ if __name__ == "__main__":
|
|||||||
# for format compatibility
|
# for format compatibility
|
||||||
demand = demand.stack(future_stack=True).unstack(level=[0, 2])
|
demand = demand.stack(future_stack=True).unstack(level=[0, 2])
|
||||||
|
|
||||||
|
# add energy consumption of coke ovens
|
||||||
|
demand = add_coke_ovens(demand, snakemake.input.transformation_output_coke,
|
||||||
|
year)
|
||||||
|
|
||||||
# style and annotation
|
# style and annotation
|
||||||
demand.index.name = "TWh/a"
|
demand.index.name = "TWh/a"
|
||||||
demand.sort_index(axis=1, inplace=True)
|
demand.sort_index(axis=1, inplace=True)
|
||||||
|
Loading…
Reference in New Issue
Block a user