add option for artificial load 1951-2021, rather than OPSD
This commit is contained in:
parent
ea703d4588
commit
aa9f047abb
29
Snakefile
29
Snakefile
@ -67,18 +67,29 @@ if config['enable'].get('retrieve_databundle', True):
|
||||
log: "logs/retrieve_databundle.log"
|
||||
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:
|
||||
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 build_load_data:
|
||||
input: "data/load_raw.csv"
|
||||
output: "resources/load{weather_year}.csv"
|
||||
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:
|
||||
input: "data/load_raw.csv"
|
||||
output: "resources/load{weather_year}.csv"
|
||||
log: "logs/build_load_data{weather_year}.log"
|
||||
script: 'scripts/build_load_data.py'
|
||||
rule build_artificial_load_data:
|
||||
input: "data/load_artificial_raw.csv"
|
||||
output: "resources/load{weather_year}.csv"
|
||||
log: "logs/build_artificial_load_data{weather_year}.log"
|
||||
script: "scripts/build_artificial_load_data.py"
|
||||
|
||||
|
||||
rule build_powerplants:
|
||||
|
@ -29,6 +29,8 @@ enable:
|
||||
retrieve_cost_data: true
|
||||
build_cutout: false
|
||||
retrieve_cutout: true
|
||||
retrieve_opsd_load_data: true
|
||||
retrieve_artificial_load_data: false
|
||||
build_natura_raster: false
|
||||
retrieve_natura_raster: true
|
||||
custom_busmap: false
|
||||
|
@ -30,6 +30,8 @@ enable:
|
||||
retrieve_cost_data: true
|
||||
build_cutout: false
|
||||
retrieve_cutout: true
|
||||
retrieve_opsd_load_data: true
|
||||
retrieve_artificial_load_data: false
|
||||
build_natura_raster: false
|
||||
retrieve_natura_raster: true
|
||||
custom_busmap: false
|
||||
|
47
scripts/build_artificial_load_data.py
Executable file
47
scripts/build_artificial_load_data.py
Executable 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])
|
@ -29,6 +29,8 @@ enable:
|
||||
retrieve_cost_data: true
|
||||
build_cutout: false
|
||||
retrieve_cutout: true
|
||||
retrieve_opsd_load_data: true
|
||||
retrieve_artificial_load_data: false
|
||||
build_natura_raster: false
|
||||
retrieve_natura_raster: true
|
||||
custom_busmap: false
|
||||
|
Loading…
Reference in New Issue
Block a user