Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eurostat2023 data #936

Closed
wants to merge 50 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
6417c7a
build_pop_weighted_energy: don't reduce district heat share
nworbmot Jan 12, 2024
4560338
move building of daily heat profile to its own script
nworbmot Jan 15, 2024
15488ed
build_energy_totals: output district heat share to separate file
nworbmot Jan 15, 2024
0022a88
move calculation of district heating share to its own script
nworbmot Jan 15, 2024
63f393e
only add district heating (DH) for nodes with non-zero DH share
nworbmot Jan 19, 2024
88f6122
move building of distribution of existing heating to own script
nworbmot Jan 19, 2024
b2539a3
existing_heating: bugfix, missing Albania due to spacing error
nworbmot Jan 22, 2024
2cc816d
solve_network: make sure infeasibilities are printed properly
nworbmot Jan 24, 2024
1ee4bf2
Update scripts/base_network.py
fneum Jan 18, 2024
2807811
correctly source the existing heating technologies for buildings
nworbmot Jan 29, 2024
720b0e7
Merge branch 'ariadne2' of github.com:PyPSA/pypsa-eur into ariadne2
nworbmot Jan 29, 2024
8db5603
for existing heating use new default_heating_lifetime
nworbmot Jan 29, 2024
879e94c
add new default to overdimension heating in individual buildings
nworbmot Jan 29, 2024
29e0978
separate domestic and international aviation
nworbmot Jan 29, 2024
b1ba64a
add colours for domestic and international aviation
nworbmot Jan 29, 2024
e9be203
fix whitespace
lindnemi Jan 30, 2024
276a79c
Revert "add colours for domestic and international aviation"
nworbmot Feb 1, 2024
dcae9e1
Revert "separate domestic and international aviation"
nworbmot Feb 1, 2024
cc299f9
pre-commit formatting [no ci]
fneum Feb 2, 2024
7c0c843
update git-blame-ignore-revs to exclude autoformat
fneum Feb 2, 2024
747dd52
cluster_gas_network: generalise so it can be used elsewhere
fneum Jan 22, 2024
5880642
allow mock_snakemake to run in submodule setup
fneum Feb 5, 2024
f1420e6
lossy_bidirectional_links: allow to specify subset of links
fneum Feb 5, 2024
c00390e
Merge branch 'master' into ariadne2
fneum Feb 7, 2024
f124520
add logs to plot_*_network rules
fneum Feb 7, 2024
70f4f1d
fix wrong merge decision - code block was removed on purpose
fneum Feb 7, 2024
e2bd392
implement statistics post processing for csv creation and plotting.
p-glaum Feb 9, 2024
5718877
Merge branch 'master' of github.com:PyPSA/pypsa-eur into improve-plot…
p-glaum Feb 9, 2024
b67b025
bugfix: coal emissions for industry weren't tracked
nworbmot Feb 9, 2024
6dbb395
bugfix: make sure coal demand is there with regional demand
nworbmot Feb 9, 2024
ba11c2b
add release note and documentation
p-glaum Feb 12, 2024
5b2cbcd
change statistics script name
p-glaum Feb 12, 2024
4702f69
simplify statistics plotting
p-glaum Feb 12, 2024
0e734fd
improve and clean-up statistic plots
p-glaum Feb 12, 2024
d537f67
Merge remote-tracking branch 'upstream/master' into improve-plotting-…
p-glaum Feb 12, 2024
b3ab9bb
revert changes in STATISTICS_BARPLOTS
p-glaum Feb 12, 2024
b300681
bugfix: include all countries in ammonia production resource
nworbmot Feb 12, 2024
882d52f
bugfix: correct units of subtracted chlorine and methanol
nworbmot Feb 12, 2024
cdbe0f5
cluster nice names as well
lindnemi Feb 13, 2024
0baeaaa
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Feb 13, 2024
13cff1e
for today's industry energy demand, separate MeOH, Cl and HVC
nworbmot Feb 14, 2024
13412fd
industrial prod: use EU28 total for denominator for distribution key
nworbmot Feb 14, 2024
958dacb
use production to determine today's energy demand for basic chemicals
nworbmot Feb 14, 2024
6a65cf9
new script to interpolate industry sector ratios today to tomorrow
nworbmot Feb 14, 2024
11bac2e
Merge pull request #928 from PyPSA/fix_nice_name
lindnemi Feb 15, 2024
bf0c1ec
Merge branch 'improve-plotting-routine' of github.com:p-glaum/pypsa-e…
nworbmot Feb 15, 2024
e7b5a0b
plot_statistics_single: fix read csv file when file had only single e…
p-glaum Feb 15, 2024
e7fdd8e
Merge branch 'improve-plotting-routine' of github.com:p-glaum/pypsa-e…
nworbmot Feb 16, 2024
2dfca6e
Merge branch 'ariadne2' of github.com:PyPSA/pypsa-eur into ariadne2
nworbmot Feb 16, 2024
32abfdd
update energy totals from 2011 to 2019
toniseibold Feb 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
5d1ef8a64055a039aa4a0834d2d26fe7752fe9a0
92080b1cd2ca5f123158571481722767b99c2b27
13769f90af4500948b0376d57df4cceaa13e78b5
cc299f969e1535082bcf668e4afe206c57c8a920
9865a970893d9e515786f33c629b14f71645bf1e
23 changes: 20 additions & 3 deletions config/config.default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ scenario:
opts:
- ''
sector_opts:
- Co2L0-3H-T-H-B-I-A-dist1
- Co2L0-3h-T-H-B-I-A-dist1
planning_horizons:
# - 2020
# - 2030
Expand Down Expand Up @@ -314,9 +314,9 @@ pypsa_eur:

# docs in https://pypsa-eur.readthedocs.io/en/latest/configuration.html#energy
energy:
energy_totals_year: 2011
energy_totals_year: 2019
base_emissions_year: 1990
eurostat_report_year: 2016
eurostat_report_year: 2023
emissions: CO2

# docs in https://pypsa-eur.readthedocs.io/en/latest/configuration.html#biomass
Expand Down Expand Up @@ -501,6 +501,7 @@ sector:
SMR_cc: true
regional_methanol_demand: false
regional_oil_demand: false
regional_coal_demand: false
regional_co2_sequestration_potential:
enable: false
attribute: 'conservative estimate Mt'
Expand Down Expand Up @@ -636,6 +637,15 @@ industry:
2040: 0.12
2045: 0.16
2050: 0.20
sector_ratios_fraction_future:
2020: 0.0
2025: 0.1
2030: 0.3
2035: 0.5
2040: 0.7
2045: 0.9
2050: 1.0
basic_chemicals_without_NH3_production_today: 69. #Mt/a, = 86 Mtethylene-equiv - 17 MtNH3
HVC_production_today: 52.
MWh_elec_per_tHVC_mechanical_recycling: 0.547
MWh_elec_per_tHVC_chemical_recycling: 6.9
Expand Down Expand Up @@ -815,6 +825,13 @@ plotting:
energy_max: 20000
energy_min: -20000
energy_threshold: 50.
countries:
- all
carriers:
- electricity
- heat
carrier_groups:
electricity: [AC, low_voltage]

nice_names:
OCGT: "Open-Cycle Gas"
Expand Down
9 changes: 6 additions & 3 deletions doc/configtables/plotting.csv
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
,Unit,Values,Description
map,,,
-- boundaries,°,"[x1,x2,y1,y2]",Boundaries of the map plots in degrees latitude (y) and longitude (x)
projection,,,,
-- name,--,"Valid Cartopy projection name","See https://scitools.org.uk/cartopy/docs/latest/reference/projections.html for list of available projections."
projection,,,
-- name,--,Valid Cartopy projection name,See https://scitools.org.uk/cartopy/docs/latest/reference/projections.html for list of available projections.
-- args,--,--,"Other entries under 'projection' are passed as keyword arguments to the projection constructor, e.g. ``central_longitude: 10.``."
costs_max,bn Euro,float,Upper y-axis limit in cost bar plots.
costs_threshold,bn Euro,float,Threshold below which technologies will not be shown in cost bar plots.
energy_max,TWh,float,Upper y-axis limit in energy bar plots.
energy_min,TWh,float,Lower y-axis limit in energy bar plots.
energy_threshold,TWh,float,Threshold below which technologies will not be shown in energy bar plots.
tech_colors,--,carrier -> HEX colour code,Mapping from network ``carrier`` to a colour (`HEX colour code <https://en.wikipedia.org/wiki/Web_colors#Hex_triplet>`_).
countries,--,[str],List of countries you want to plot in your statistics figures. Default is all coutries but also single countries can be defined like ``DE``.
carriers,--,[str],Carrier you want to plot from in your statistics figures. This carrier must be an available bus carrier in your network or substring of a carrier or a defined carrier group.
carrier_groups,--,str -> carrier,Mapping from ``carrier_groups`` to individual bus carriers in the network.
nice_names,--,str -> str,Mapping from network ``carrier`` to a more readable name.
tech_colors,--,carrier -> HEX colour code,Mapping from network ``carrier`` to a colour (`HEX colour code <https://en.wikipedia.org/wiki/Web_colors#Hex_triplet>`_).
2 changes: 2 additions & 0 deletions doc/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ Release Notes
Upcoming Release
================

* Add plotting routine with statistics where we allow for plotting of individual energy carriers and countries. Besides the plots, we create all necessary csv files for the plotting routine.

* Merged two OPSD time series data versions into such that the option ``load:
power_statistics:`` becomes superfluous and was hence removed.

Expand Down
27 changes: 25 additions & 2 deletions rules/build_sector.smk
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,30 @@ rule build_industry_sector_ratios:
"../scripts/build_industry_sector_ratios.py"


rule build_industry_sector_ratios_intermediate:
params:
industry=config["industry"],
input:
industry_sector_ratios=RESOURCES + "industry_sector_ratios.csv",
industrial_energy_demand_per_country_today=RESOURCES
+ "industrial_energy_demand_per_country_today.csv",
industrial_production_per_country=RESOURCES
+ "industrial_production_per_country.csv",
output:
industry_sector_ratios=RESOURCES + "industry_sector_ratios_{planning_horizons}.csv",
threads: 1
resources:
mem_mb=1000,
log:
LOGS + "build_industry_sector_ratios_{planning_horizons}.log",
benchmark:
BENCHMARKS + "build_industry_sector_ratios_{planning_horizons}"
conda:
"../envs/environment.yaml"
script:
"../scripts/build_industry_sector_ratios_intermediate.py"


rule build_industrial_production_per_country:
params:
industry=config["industry"],
Expand Down Expand Up @@ -535,7 +559,7 @@ rule build_industrial_production_per_node:

rule build_industrial_energy_demand_per_node:
input:
industry_sector_ratios=RESOURCES + "industry_sector_ratios.csv",
industry_sector_ratios=RESOURCES + "industry_sector_ratios_{planning_horizons}.csv",
industrial_production_per_node=RESOURCES
+ "industrial_production_elec_s{simpl}_{clusters}_{planning_horizons}.csv",
industrial_energy_demand_per_node_today=RESOURCES
Expand Down Expand Up @@ -566,7 +590,6 @@ rule build_industrial_energy_demand_per_country_today:
industry=config["industry"],
input:
jrc="data/bundle-sector/jrc-idees-2015",
ammonia_production=RESOURCES + "ammonia_production.csv",
industrial_production_per_country=RESOURCES
+ "industrial_production_per_country.csv",
output:
Expand Down
19 changes: 19 additions & 0 deletions rules/collect.smk
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,22 @@ rule validate_elec_networks:
**config["scenario"],
kind=["production", "prices", "cross_border"],
),


rule plot_statistics:
input:
[
expand(
RESULTS
+ "statistics/figures/comparison/country_{country}/.statistics_{carrier}_plots",
country=config["plotting"].get("countries", "all"),
carrier=config["plotting"].get("carriers", ["all"]),
),
expand(
RESULTS
+ "statistics/figures/single/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}/country_{country}/.statistics_{carrier}_plots",
**config["scenario"],
country=config["plotting"].get("countries", "all"),
carrier=config["plotting"].get("carriers", ["all"]),
),
],
7 changes: 5 additions & 2 deletions rules/common.smk
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,11 @@ def has_internet_access(url="www.zenodo.org") -> bool:

def input_eurostat(w):
# 2016 includes BA, 2017 does not
report_year = config["energy"]["eurostat_report_year"]
return f"data/bundle-sector/eurostat-energy_balances-june_{report_year}_edition"
if config["energy"]["eurostat_report_year"] != 2023:
report_year = config["energy"]["eurostat_report_year"]
return f"data/bundle-sector/eurostat-energy_balances-june_{report_year}_edition"
else:
return "data/bundle-sector/eurostat-energy_balances-april_2023_edition"


def solved_previous_horizon(wildcards):
Expand Down
86 changes: 86 additions & 0 deletions rules/postprocess.smk
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,92 @@ STATISTICS_BARPLOTS = [
"market_value",
]

STATISTICS = {
"capacity_factor": ("-", "p.u."),
"installed_capacity": (1e3, "GW"),
"optimal_capacity": (1e3, "GW"),
"capex": (1e9, "bn €"),
"opex": (1e9, "bn €"),
"total_cost": ("1e9", "bn €"),
"curtailment": (1e3, "GWh"),
"supply": (1e6, "TWh"),
"withdrawal": (1e6, "TWh"),
"energy_balance": (1e6, "TWh"),
"market_value": ("-", "€/MWh"),
}


rule save_statistics_csv:
params:
statistics=STATISTICS,
input:
network=RESULTS
+ "postnetworks/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}.nc",
output:
**{
f"{csv}": RESULTS
+ "statistics/csv/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}/country_{country}/{carrier}_"
+ f"{csv}.csv"
for carrier in config["plotting"].get("carriers", "all")
for csv in STATISTICS
},
csv_touch=RESULTS
+ "statistics/csv/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}/country_{country}/.statistics_{carrier}_csv",
script:
"../scripts/write_statistics.py"


rule plot_statistics_single:
params:
plotting=config["plotting"],
statistics=STATISTICS,
input:
**{
f"{csv}": RESULTS
+ "statistics/csv/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}/country_{country}/{carrier}_"
+ f"{csv}.csv"
for carrier in config["plotting"].get("carriers", "all")
for csv in STATISTICS
},
output:
**{
f"{plot}": RESULTS
+ "statistics/figures/single/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}/country_{country}/{carrier}_"
+ f"{plot}.pdf"
for carrier in config["plotting"].get("carriers", "all")
for plot in STATISTICS
},
barplots_touch=RESULTS
+ "statistics/figures/single/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}/country_{country}/.statistics_{carrier}_plots",
script:
"../scripts/plot_statistics_single.py"


rule plot_statistics_comparison:
params:
plotting=config["plotting"],
statistics=STATISTICS,
input:
expand(
RESULTS
+ "statistics/csv/elec_s{simpl}_{clusters}_l{ll}_{opts}_{sector_opts}_{planning_horizons}/country_{country}/{carrier}_{csv}.csv",
**config["scenario"],
csv=STATISTICS,
allow_missing=True,
),
output:
**{
f"{plot}": RESULTS
+ "statistics/figures/comparison/country_{country}/{carrier}_"
+ f"{plot}.pdf"
for carrier in config["plotting"].get("carriers", "all")
for plot in STATISTICS
},
barplots_touch=RESULTS
+ "statistics/figures/comparison/country_{country}/.statistics_{carrier}_plots",
script:
"../scripts/plot_statistics_comparison.py"


rule plot_elec_statistics:
params:
Expand Down
34 changes: 34 additions & 0 deletions rules/solve_myopic.smk
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,40 @@
# SPDX-License-Identifier: MIT


rule build_existing_heating_distribution:
params:
baseyear=config["scenario"]["planning_horizons"][0],
sector=config["sector"],
existing_capacities=config["existing_capacities"],
input:
existing_heating="data/existing_infrastructure/existing_heating_raw.csv",
clustered_pop_layout=RESOURCES + "pop_layout_elec_s{simpl}_{clusters}.csv",
clustered_pop_energy_layout=RESOURCES
+ "pop_weighted_energy_totals_s{simpl}_{clusters}.csv",
district_heat_share=RESOURCES
+ "district_heat_share_elec_s{simpl}_{clusters}_{planning_horizons}.csv",
output:
existing_heating_distribution=RESOURCES
+ "existing_heating_distribution_elec_s{simpl}_{clusters}_{planning_horizons}.csv",
wildcard_constraints:
planning_horizons=config["scenario"]["planning_horizons"][0], #only applies to baseyear
threads: 1
resources:
mem_mb=2000,
log:
LOGS
+ "build_existing_heating_distribution_elec_s{simpl}_{clusters}_{planning_horizons}.log",
benchmark:
(
BENCHMARKS
+ "build_existing_heating_distribution/elec_s{simpl}_{clusters}_{planning_horizons}"
)
conda:
"../envs/environment.yaml"
script:
"../scripts/build_existing_heating_distribution.py"


rule add_existing_baseyear:
params:
baseyear=config["scenario"]["planning_horizons"][0],
Expand Down
7 changes: 5 additions & 2 deletions scripts/build_ammonia_production.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"""

import country_converter as coco
import numpy as np
import pandas as pd

cc = coco.CountryConverter()
Expand All @@ -30,8 +31,10 @@
ammonia.index = cc.convert(ammonia.index, to="iso2")

years = [str(i) for i in range(2013, 2018)]
countries = ammonia.index.intersection(snakemake.params.countries)
ammonia = ammonia.loc[countries, years].astype(float)

ammonia = ammonia[years]
ammonia.replace("--", np.nan, inplace=True)
ammonia = ammonia.astype(float)

# convert from ktonN to ktonNH3
ammonia *= 17 / 14
Expand Down
Loading