Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion docs/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ SPDX-License-Identifier: MIT

## Upcoming Version

*
* Deprecate the argument `extend_by_vres` of `pm.powerplants()` and the function `extend_by_VRE()`. Both will be removed in v0.11.0. Wind and solar power plants are already included from GEM and MASTR, and the option added them again from outdated OPSD data (2020). ([#232](https://github.com/PyPSA/powerplantmatching/issues/232))
* Bugfix: `pm.powerplants(from_url=True)` now applies `extend_by_vres` like the other code paths, and the deprecated argument `extendby_kwargs` now raises a `FutureWarning` instead of a logging error.

## [v0.9.0](https://github.com/PyPSA/powerplantmatching/releases/tag/v0.9.0) (3rd October 2026)

Expand Down
27 changes: 22 additions & 5 deletions powerplantmatching/collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import logging
import os
import warnings

import pandas as pd
from deprecation import deprecated
Expand Down Expand Up @@ -143,8 +144,10 @@ def powerplants(
Configuration input dictionary to be merged into the default
configuration data
extend_by_vres : Boolean, default False
Whether extend the dataset by variable renewable energy sources
given by powerplantmatching.data.OPSD_VRE()
Deprecated since v0.10.0 and will be removed in v0.11.0. Wind and
solar power plants are already included from GEM and MASTR. This
option adds them again from the outdated
powerplantmatching.data.OPSD_VRE() and counts them twice.
extendby_kwargs : Dict,
Dict of keyword arguments passed to powerplantmatchting.
heuristics.extend_by_non_matched
Expand All @@ -164,6 +167,15 @@ def powerplants(
"""
from . import latest_release

if extend_by_vres:
warnings.warn(
"`extend_by_vres` is deprecated and will be removed in v0.11.0. Wind "
"and solar power plants are already included from GEM and MASTR. "
"This option adds them again from outdated OPSD data (2020).",
FutureWarning,
stacklevel=2,
)

if config is None:
if config_update is None:
config = get_config()
Expand All @@ -180,9 +192,10 @@ def powerplants(
msg = "The following arguments were deprecated and are being ignored: "
logger.warning(msg + f"{used_deprecated_args}")
if extendby_kwargs:
logger.warning(
DeprecationWarning,
"`extendby_kwargs` is deprecated in the favor of extend_by_kwargs",
warnings.warn(
"`extendby_kwargs` is deprecated in favor of `extend_by_kwargs`",
FutureWarning,
stacklevel=2,
)
extend_by_kwargs.update(extendby_kwargs)

Expand All @@ -206,6 +219,10 @@ def powerplants(
)
logger.info(f"Store data at {fn}")
df.to_csv(fn)
if extend_by_vres:
return df.pipe(
extend_by_VRE, config=config, base_year=config["opsd_vres_base_year"]
)
return df

if not update and os.path.exists(fn):
Expand Down
5 changes: 5 additions & 0 deletions powerplantmatching/heuristics.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,11 @@ def fill_missing_duration(df):
return df


@deprecated(
deprecated_in="0.10.0",
removed_in="0.11.0",
details="Wind and solar power plants are already included from GEM and MASTR.",
)
def extend_by_VRE(df, config=None, base_year=2017, prune_beyond=True):
"""
Extends a given reduced dataframe by externally given VREs.
Expand Down
32 changes: 32 additions & 0 deletions test/test_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
#
# SPDX-License-Identifier: MIT

import pandas as pd
import pytest
from deprecation import DeprecatedWarning

import powerplantmatching as pm
from powerplantmatching import data
from powerplantmatching.core import _data_out, package_config

config = pm.get_config()
sources = [s if isinstance(s, str) else list(s)[0] for s in config["matching_sources"]]
Expand Down Expand Up @@ -64,3 +67,32 @@ def test_reduced_retrieval():
config["matching_sources"] = ["GEO", "GPD"]
config["fully_included_sources"] = []
pm.powerplants(reduced=False, config=config)


@pytest.fixture
def cached_config(tmp_path, monkeypatch):
monkeypatch.setitem(package_config, "data_dir", tmp_path)
config = pm.get_config()
columns = config["target_columns"]
fn = _data_out("matched_data_red.csv", config)
plant = {"Name": ["A"], "Fueltype": ["Hydro"], "EIC": ["{}"], "projectID": ["{}"]}
pd.DataFrame(plant, columns=columns).to_csv(fn)
config["matched_data_url"] = fn
vre = pd.DataFrame({"Name": ["B"], "Fueltype": ["Solar"]}, columns=columns)
monkeypatch.setattr(data, "OPSD_VRE", lambda config: vre)
return config


@pytest.mark.parametrize("from_url", [False, True])
def test_extend_by_vres_deprecated(cached_config, from_url):
with pytest.warns(FutureWarning, match="extend_by_vres"):
with pytest.warns(DeprecatedWarning, match="extend_by_VRE"):
df = pm.powerplants(
config=cached_config, from_url=from_url, extend_by_vres=True
)
assert df.Fueltype.tolist() == ["Hydro", "Solar"]


def test_extendby_kwargs_deprecated(cached_config):
with pytest.warns(FutureWarning, match="extendby_kwargs"):
pm.powerplants(config=cached_config, extendby_kwargs={"query": None})
Loading