Improve low capacity warning
Add the region and technology names so users can quickly identify where
they are asking for more capacity than is available.
Also some line modifications by black (remove spaces).
@@ -454,6 +454,8 @@ class ResourceGroup:
max_lcoe: float = None,
cap_multiplier: float = None,
profiles: bool = True,
+ region: str = None,
+ technology: str = None,
) -> pd.DataFrame:
"""
Compute resource clusters.
@@ -479,6 +481,10 @@ class ResourceGroup:
Multiplier applied to resource capacity before selection by `min_capacity`.
profiles
Whether to include cluster profiles, if available, in column `profile`.
+ region:
+ Name of the model region
+ technology:
+ Name of the resource technology
Returns
-------
@@ -523,7 +529,8 @@ class ResourceGroup:
capacity = df.loc[mask, CAPACITY].sum()
if min_capacity and capacity < min_capacity:
logger.warning(
- f"Selected capacity less than minimum ({capacity} < {min_capacity} MW)"
+ f"Selected technology {technology} capacity in region {region} less "
+ f"than minimum ({capacity} < {min_capacity} MW)"
)
# Apply mask
df = df[mask | ~base] if tree else df[mask]
@@ -688,6 +695,8 @@ class ClusterBuilder:
max_clusters=max_clusters,
max_lcoe=max_lcoe,
cap_multiplier=cap_multiplier,
+ region=region,
+ technology=kwargs.get("technology"),
),
}
self.clusters.append(c)
@@ -900,7 +909,7 @@ def cluster_rows(
def build_tree(
- df: pd.DataFrame, by: Iterable[Iterable], max_level: int = None, **kwargs: Any,
+ df: pd.DataFrame, by: Iterable[Iterable], max_level: int = None, **kwargs: Any
) -> pd.DataFrame:
"""
Build a hierarchical tree of rows in a dataframe.
