industry: add current nodal electricity demand to subtract later
This commit is contained in:
parent
f2b347334d
commit
80cbe98630
18
Snakefile
18
Snakefile
@ -3,6 +3,7 @@ configfile: "config.yaml"
|
||||
|
||||
wildcard_constraints:
|
||||
lv="[a-z0-9\.]+",
|
||||
network="[a-zA-Z0-9]*",
|
||||
simpl="[a-zA-Z0-9]*",
|
||||
clusters="[0-9]+m?",
|
||||
sectors="[+a-zA-Z0-9]+",
|
||||
@ -229,7 +230,8 @@ rule build_industrial_production_per_node:
|
||||
rule build_industrial_energy_demand_per_node:
|
||||
input:
|
||||
industry_sector_ratios="resources/industry_sector_ratios.csv",
|
||||
industrial_production_per_node="resources/industrial_production_{network}_s{simpl}_{clusters}.csv"
|
||||
industrial_production_per_node="resources/industrial_production_{network}_s{simpl}_{clusters}.csv",
|
||||
industrial_energy_demand_per_node_today="resources/industrial_energy_demand_today_{network}_s{simpl}_{clusters}.csv"
|
||||
output:
|
||||
industrial_energy_demand_per_node="resources/industrial_energy_demand_{network}_s{simpl}_{clusters}.csv"
|
||||
threads: 1
|
||||
@ -248,6 +250,18 @@ rule build_industrial_energy_demand_per_country_today:
|
||||
script: 'scripts/build_industrial_energy_demand_per_country_today.py'
|
||||
|
||||
|
||||
rule build_industrial_energy_demand_per_node_today:
|
||||
input:
|
||||
industrial_distribution_key="resources/industrial_distribution_key_{network}_s{simpl}_{clusters}.csv",
|
||||
industrial_energy_demand_per_country_today="resources/industrial_energy_demand_per_country_today.csv"
|
||||
output:
|
||||
industrial_energy_demand_per_node_today="resources/industrial_energy_demand_today_{network}_s{simpl}_{clusters}.csv"
|
||||
threads: 1
|
||||
resources: mem_mb=1000
|
||||
script: 'scripts/build_industrial_energy_demand_per_node_today.py'
|
||||
|
||||
|
||||
|
||||
rule build_industrial_energy_demand_per_country:
|
||||
input:
|
||||
industry_sector_ratios="resources/industry_sector_ratios.csv",
|
||||
@ -287,7 +301,7 @@ rule prepare_sector_network:
|
||||
clustermaps=pypsaeur('resources/clustermaps_{network}_s{simpl}_{clusters}.h5'),
|
||||
clustered_pop_layout="resources/pop_layout_{network}_s{simpl}_{clusters}.csv",
|
||||
simplified_pop_layout="resources/pop_layout_{network}_s{simpl}.csv",
|
||||
industrial_demand="resources/industrial_demand_{network}_s{simpl}_{clusters}.csv",
|
||||
industrial_demand="resources/industrial_energy_demand_{network}_s{simpl}_{clusters}.csv",
|
||||
heat_demand_urban="resources/heat_demand_urban_{network}_s{simpl}_{clusters}.nc",
|
||||
heat_demand_rural="resources/heat_demand_rural_{network}_s{simpl}_{clusters}.nc",
|
||||
heat_demand_total="resources/heat_demand_total_{network}_s{simpl}_{clusters}.nc",
|
||||
|
@ -7,7 +7,12 @@ industry_sector_ratios=pd.read_csv(snakemake.input.industry_sector_ratios,
|
||||
index_col=0)
|
||||
|
||||
#material demand per node and industry (kton/a)
|
||||
nodal_production = pd.read_csv(snakemake.input.industrial_production_per_node, index_col=0)
|
||||
nodal_production = pd.read_csv(snakemake.input.industrial_production_per_node,
|
||||
index_col=0)
|
||||
|
||||
#energy demand today to get current electricity
|
||||
nodal_today = pd.read_csv(snakemake.input.industrial_energy_demand_per_node_today,
|
||||
index_col=0)
|
||||
|
||||
#final energy consumption per node and industry (TWh/a)
|
||||
nodal_df = nodal_production.dot(industry_sector_ratios.T)
|
||||
@ -20,6 +25,8 @@ rename_sectors = {'elec':'electricity',
|
||||
|
||||
nodal_df.rename(columns=rename_sectors,inplace=True)
|
||||
|
||||
nodal_df["current electricity"] = nodal_today["electricity"]
|
||||
|
||||
nodal_df.index.name = "TWh/a (MtCO2/a)"
|
||||
|
||||
nodal_df.to_csv(snakemake.output.industrial_energy_demand_per_node,
|
||||
|
54
scripts/build_industrial_energy_demand_per_node_today.py
Normal file
54
scripts/build_industrial_energy_demand_per_node_today.py
Normal file
@ -0,0 +1,54 @@
|
||||
|
||||
import pandas as pd
|
||||
import numpy as np
|
||||
|
||||
def build_nodal_demand():
|
||||
|
||||
industrial_demand = pd.read_csv(snakemake.input.industrial_energy_demand_per_country_today,
|
||||
header=[0,1],
|
||||
index_col=0)
|
||||
|
||||
distribution_keys = pd.read_csv(snakemake.input.industrial_distribution_key,
|
||||
index_col=0)
|
||||
distribution_keys["country"] = distribution_keys.index.str[:2]
|
||||
|
||||
nodal_demand = pd.DataFrame(0.,
|
||||
index=distribution_keys.index,
|
||||
columns=industrial_demand.index,
|
||||
dtype=float)
|
||||
|
||||
#map JRC/our sectors to hotmaps sector, where mapping exist
|
||||
sector_mapping = {'Electric arc' : 'Iron and steel',
|
||||
'Integrated steelworks' : 'Iron and steel',
|
||||
'DRI + Electric arc' : 'Iron and steel',
|
||||
'Ammonia' : 'Chemical industry',
|
||||
'Basic chemicals (without ammonia)' : 'Chemical industry',
|
||||
'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',
|
||||
}
|
||||
|
||||
for c in distribution_keys.country.unique():
|
||||
buses = distribution_keys.index[distribution_keys.country == c]
|
||||
for sector in industrial_demand.columns.levels[1]:
|
||||
distribution_key = distribution_keys.loc[buses,sector_mapping.get(sector,"population")]
|
||||
demand = industrial_demand[c,sector]
|
||||
outer = pd.DataFrame(np.outer(distribution_key,demand),index=distribution_key.index,columns=demand.index)
|
||||
nodal_demand.loc[buses] += outer
|
||||
|
||||
nodal_demand.index.name = "TWh/a"
|
||||
|
||||
nodal_demand.to_csv(snakemake.output.industrial_energy_demand_per_node_today)
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
build_nodal_demand()
|
Loading…
Reference in New Issue
Block a user