Document the new time_aggregation rule

This commit is contained in:
Koen van Greevenbroek 2024-05-15 13:34:20 +02:00
parent 354fffe6f0
commit f8f0b4cea0
5 changed files with 391 additions and 558 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 700 KiB

After

Width:  |  Height:  |  Size: 710 KiB

View File

@ -260,6 +260,8 @@ Upcoming Release
* Fix gas network retrofitting in `add_brownfield`.
* Time aggregation for sector-coupled networks have been split into its own rule. When using time step segmentation, time aggregation is constant over planning horizons of the same network.
PyPSA-Eur 0.10.0 (19th February 2024)
=====================================

View File

@ -183,6 +183,11 @@ Rule ``cluster_gas_network``
.. automodule:: cluster_gas_network
Rule ``time_aggregation``
==============================================================================
.. automodule:: time_aggregation
Rule ``prepare_sector_network``
==============================================================================

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,40 @@
# -*- coding: utf-8 -*-
# SPDX-FileCopyrightText: : 2017-2024 The PyPSA-Eur Authors
#
# SPDX-License-Identifier: MIT
"""
Defines the time aggregation to be used for sector-coupled network.
Relevant Settings
-----------------
.. code:: yaml
clustering:
temporal:
resolution_sector:
enable:
drop_leap_day:
Inputs
------
- ``networks/elec_s{simpl}_{clusters}_ec_l{ll}_{opts}.nc``: the network whose snapshots are to be aggregated
- ``resources/hourly_heat_demand_total_elec_s{simpl}_{clusters}.nc``: the total hourly heat demand
- ``resources/solar_thermal_total_elec_s{simpl}_{clusters}.nc``: the total hourly solar thermal generation
Outputs
-------
- ``snapshot_weightings_elec_s{simpl}_{clusters}_ec_l{ll}_{opts}.csv``
Description
-----------
Computes a time aggregation scheme for the given network, in the form of a CSV file with the snapshot weightings, indexed by the new subset of snapshots. This rule only computes said aggregation scheme; aggregation of time-varying network data is done in ``prepare_sector_network.py``.
"""
import logging
import numpy as np
@ -69,16 +105,18 @@ if __name__ == "__main__":
for attr, pnl in c.pnl.items()
if not pnl.empty and attr != "e_min_pu"
]
dfs.append(
xr.open_dataset(snakemake.input.hourly_heat_demand_total)
.to_dataframe()
.unstack(level=1)
)
dfs.append(
xr.open_dataset(snakemake.input.solar_thermal_total)
.to_dataframe()
.unstack(level=1)
)
if snakemake.input.hourly_heat_demand_total:
dfs.append(
xr.open_dataset(snakemake.input.hourly_heat_demand_total)
.to_dataframe()
.unstack(level=1)
)
if snakemake.input.solar_thermal_total:
dfs.append(
xr.open_dataset(snakemake.input.solar_thermal_total)
.to_dataframe()
.unstack(level=1)
)
df = pd.concat(dfs, axis=1)
# Reset columns to flat index