add option for artificial load 1951-2021, rather than OPSD

This commit is contained in:
Fabian Neumann 2022-07-29 13:38:21 +02:00
parent ea703d4588
commit aa9f047abb
5 changed files with 73 additions and 9 deletions

View File

@ -67,18 +67,29 @@ if config['enable'].get('retrieve_databundle', True):
log: "logs/retrieve_databundle.log" log: "logs/retrieve_databundle.log"
script: 'scripts/retrieve_databundle.py' script: 'scripts/retrieve_databundle.py'
if config["enable"].get('retrieve_opsd_load_data', True):
rule retrieve_load_data:
input: HTTP.remote("data.open-power-system-data.org/time_series/2019-06-05/time_series_60min_singleindex.csv", keep_local=True, static=True)
output: "data/load_raw.csv"
run: move(input[0], output[0])
rule retrieve_load_data: rule build_load_data:
input: HTTP.remote("data.open-power-system-data.org/time_series/2019-06-05/time_series_60min_singleindex.csv", keep_local=True, static=True) input: "data/load_raw.csv"
output: "data/load_raw.csv" output: "resources/load{weather_year}.csv"
run: move(input[0], output[0]) log: "logs/build_load_data{weather_year}.log"
script: 'scripts/build_load_data.py'
if config["enable"].get('retrieve_artificial_load_data', False):
rule retrieve_artificial_load_data:
input: HTTP.remote("https://sandbox.zenodo.org/record/1089549/files/demand_hourly.csv", keep_local=True, static=True)
output: "data/load_artificial_raw.csv"
run: move(input[0], output[0])
rule build_load_data: rule build_artificial_load_data:
input: "data/load_raw.csv" input: "data/load_artificial_raw.csv"
output: "resources/load{weather_year}.csv" output: "resources/load{weather_year}.csv"
log: "logs/build_load_data{weather_year}.log" log: "logs/build_artificial_load_data{weather_year}.log"
script: 'scripts/build_load_data.py' script: "scripts/build_artificial_load_data.py"
rule build_powerplants: rule build_powerplants:

View File

@ -29,6 +29,8 @@ enable:
retrieve_cost_data: true retrieve_cost_data: true
build_cutout: false build_cutout: false
retrieve_cutout: true retrieve_cutout: true
retrieve_opsd_load_data: true
retrieve_artificial_load_data: false
build_natura_raster: false build_natura_raster: false
retrieve_natura_raster: true retrieve_natura_raster: true
custom_busmap: false custom_busmap: false

View File

@ -30,6 +30,8 @@ enable:
retrieve_cost_data: true retrieve_cost_data: true
build_cutout: false build_cutout: false
retrieve_cutout: true retrieve_cutout: true
retrieve_opsd_load_data: true
retrieve_artificial_load_data: false
build_natura_raster: false build_natura_raster: false
retrieve_natura_raster: true retrieve_natura_raster: true
custom_busmap: false custom_busmap: false

View File

@ -0,0 +1,47 @@
# SPDX-FileCopyrightText: 2022 The PyPSA-Eur Authors
#
# SPDX-License-Identifier: MIT
"""This rule downloads the load data"""
import logging
logger = logging.getLogger(__name__)
from _helpers import configure_logging
import pandas as pd
if __name__ == "__main__":
if 'snakemake' not in globals():
from _helpers import mock_snakemake
snakemake = mock_snakemake('build_artificial_load_data', weather_year='')
configure_logging(snakemake)
weather_year = snakemake.wildcards.weather_year
if weather_year:
snapshots = dict(
start=weather_year,
end=str(int(weather_year)+1),
closed="left"
)
else:
snapshots = snakemake.config['snapshots']
snapshots = pd.date_range(freq='h', **snapshots)
fixed_year = snakemake.config["load"].get("fixed_year", False)
years = slice(str(fixed_year), str(fixed_year)) if fixed_year else slice(snapshots[0], snapshots[-1])
countries = snakemake.config['countries']
load = pd.read_csv(
snakemake.input[0],
index_col=0,
parse_dates=True
).loc[snapshots, countries]
assert not load.isna().any().any(), 'Load data contains nans.'
if fixed_year:
load.index = load.index.map(lambda t: t.replace(year=snapshots.year[0]))
load.to_csv(snakemake.output[0])

View File

@ -29,6 +29,8 @@ enable:
retrieve_cost_data: true retrieve_cost_data: true
build_cutout: false build_cutout: false
retrieve_cutout: true retrieve_cutout: true
retrieve_opsd_load_data: true
retrieve_artificial_load_data: false
build_natura_raster: false build_natura_raster: false
retrieve_natura_raster: true retrieve_natura_raster: true
custom_busmap: false custom_busmap: false