2023-03-06 08:27:45 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
2024-02-19 15:21:48 +00:00
|
|
|
# SPDX-FileCopyrightText: : 2020-2024 The PyPSA-Eur Authors
|
2023-03-06 17:49:23 +00:00
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: MIT
|
2021-07-01 18:09:04 +00:00
|
|
|
"""
|
2023-03-09 11:45:43 +00:00
|
|
|
Build industrial production per model region.
|
2024-06-05 13:02:44 +00:00
|
|
|
|
|
|
|
Inputs
|
|
|
|
-------
|
|
|
|
|
2024-09-13 13:37:01 +00:00
|
|
|
- ``resources/industrial_distribution_key_base_s_{clusters}.csv``
|
2024-06-05 13:02:44 +00:00
|
|
|
- ``resources/industrial_production_per_country_tomorrow_{planning_horizons}.csv``
|
|
|
|
|
|
|
|
Outputs
|
|
|
|
-------
|
|
|
|
|
2024-09-13 13:37:01 +00:00
|
|
|
- ``resources/industrial_production_per_node_base_s_{clusters}_{planning_horizons}.csv``
|
2024-06-05 13:02:44 +00:00
|
|
|
|
|
|
|
Description
|
|
|
|
-------
|
|
|
|
|
|
|
|
This rule maps the industrial production per country from a certain time horizon to each bus region.
|
|
|
|
The mapping file provides a value between 0 and 1 for each bus and industry subcategory, indicating the share of the country's production of that sector in that bus.
|
|
|
|
The industrial production per country is multiplied by the mapping value to get the industrial production per bus.
|
|
|
|
The unit of the production is kt/a.
|
2021-07-01 18:09:04 +00:00
|
|
|
"""
|
2020-10-05 18:04:04 +00:00
|
|
|
|
2021-07-01 18:09:04 +00:00
|
|
|
from itertools import product
|
|
|
|
|
2020-10-05 18:04:04 +00:00
|
|
|
import pandas as pd
|
2024-02-12 10:53:20 +00:00
|
|
|
from _helpers import set_scenario_config
|
2023-03-06 08:27:45 +00:00
|
|
|
|
2021-07-01 18:09:04 +00:00
|
|
|
# map JRC/our sectors to hotmaps sector, where mapping exist
|
|
|
|
sector_mapping = {
|
2024-08-30 12:53:54 +00:00
|
|
|
"Electric arc": "EAF",
|
|
|
|
"Integrated steelworks": "Integrated steelworks",
|
|
|
|
"DRI + Electric arc": "DRI + EAF",
|
|
|
|
"Ammonia": "Ammonia",
|
2021-09-24 11:00:58 +00:00
|
|
|
"HVC": "Chemical industry",
|
2021-09-24 11:19:48 +00:00
|
|
|
"HVC (mechanical recycling)": "Chemical industry",
|
|
|
|
"HVC (chemical recycling)": "Chemical industry",
|
2021-09-24 11:00:58 +00:00
|
|
|
"Methanol": "Chemical industry",
|
|
|
|
"Chlorine": "Chemical industry",
|
2021-07-01 18:09:04 +00:00
|
|
|
"Other chemicals": "Chemical industry",
|
|
|
|
"Pharmaceutical products etc.": "Chemical industry",
|
|
|
|
"Cement": "Cement",
|
|
|
|
"Ceramics & other NMM": "Non-metallic mineral products",
|
|
|
|
"Glass production": "Glass",
|
|
|
|
"Pulp production": "Paper and printing",
|
|
|
|
"Paper production": "Paper and printing",
|
|
|
|
"Printing and media reproduction": "Paper and printing",
|
|
|
|
"Alumina production": "Non-ferrous metals",
|
|
|
|
"Aluminium - primary production": "Non-ferrous metals",
|
|
|
|
"Aluminium - secondary production": "Non-ferrous metals",
|
|
|
|
"Other non-ferrous metals": "Non-ferrous metals",
|
|
|
|
}
|
|
|
|
|
2020-10-05 18:04:04 +00:00
|
|
|
|
2020-10-12 10:07:49 +00:00
|
|
|
def build_nodal_industrial_production():
|
2021-07-01 18:09:04 +00:00
|
|
|
fn = snakemake.input.industrial_production_per_country_tomorrow
|
|
|
|
industrial_production = pd.read_csv(fn, index_col=0)
|
|
|
|
|
|
|
|
fn = snakemake.input.industrial_distribution_key
|
|
|
|
keys = pd.read_csv(fn, index_col=0)
|
|
|
|
keys["country"] = keys.index.str[:2]
|
|
|
|
|
|
|
|
nodal_production = pd.DataFrame(
|
|
|
|
index=keys.index, columns=industrial_production.columns, dtype=float
|
|
|
|
)
|
|
|
|
|
|
|
|
countries = keys.country.unique()
|
|
|
|
sectors = industrial_production.columns
|
2021-09-24 11:00:58 +00:00
|
|
|
|
2021-07-01 18:09:04 +00:00
|
|
|
for country, sector in product(countries, sectors):
|
|
|
|
buses = keys.index[keys.country == country]
|
|
|
|
mapping = sector_mapping.get(sector, "population")
|
2021-09-24 11:00:58 +00:00
|
|
|
|
2021-07-01 18:09:04 +00:00
|
|
|
key = keys.loc[buses, mapping]
|
|
|
|
nodal_production.loc[buses, sector] = (
|
|
|
|
industrial_production.at[country, sector] * key
|
2023-03-06 08:27:45 +00:00
|
|
|
)
|
2021-07-01 18:09:04 +00:00
|
|
|
|
|
|
|
nodal_production.to_csv(snakemake.output.industrial_production_per_node)
|
|
|
|
|
2020-10-05 18:04:04 +00:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2021-07-01 18:09:04 +00:00
|
|
|
if "snakemake" not in globals():
|
2023-03-06 18:09:45 +00:00
|
|
|
from _helpers import mock_snakemake
|
2023-03-06 08:27:45 +00:00
|
|
|
|
2024-09-13 13:37:01 +00:00
|
|
|
snakemake = mock_snakemake("build_industrial_production_per_node", clusters=48)
|
2024-02-12 10:53:20 +00:00
|
|
|
set_scenario_config(snakemake)
|
2020-10-05 18:04:04 +00:00
|
|
|
|
2020-10-12 10:07:49 +00:00
|
|
|
build_nodal_industrial_production()
|