Index
frequenz.gridpool.config ¤
Microgrid configuration data model and loading.
Attributes¤
frequenz.gridpool.config.ComponentCategory
module-attribute
¤
ComponentCategory = Literal[
"meter", "inverter", "component"
]
Valid component categories.
frequenz.gridpool.config.ComponentType
module-attribute
¤
ComponentType = Literal[
"grid", "pv", "battery", "consumption", "chp", "ev"
]
Valid component types.
Classes¤
frequenz.gridpool.config.BatteryConfig ¤
Configuration of a battery in a microgrid.
Source code in src/frequenz/gridpool/config/microgrid.py
frequenz.gridpool.config.ComponentTypeConfig ¤
Configuration of a microgrid component type.
Source code in src/frequenz/gridpool/config/microgrid.py
Attributes¤
component
class-attribute
instance-attribute
¤
List of component IDs for this component.
formula
class-attribute
instance-attribute
¤
Formula to calculate the power of this component.
inverter
class-attribute
instance-attribute
¤
List of inverter IDs for this component.
meter
class-attribute
instance-attribute
¤
List of meter IDs for this component.
Methods:¤
__post_init__ ¤
Set the default formula if none is provided.
Source code in src/frequenz/gridpool/config/microgrid.py
cids ¤
Get component IDs for this component.
By default, the meter IDs are returned if available, otherwise the inverter IDs. For components without meters or inverters, the component IDs are returned.
If a metric is provided, the component IDs are extracted from the formula.
| PARAMETER | DESCRIPTION |
|---|---|
metric
|
Metric name of the formula.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[int]
|
List of component IDs for this component. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the metric is not supported or improperly set. |
Source code in src/frequenz/gridpool/config/microgrid.py
is_valid_type
classmethod
¤
frequenz.gridpool.config.Metadata ¤
Metadata for a microgrid.
Source code in src/frequenz/gridpool/config/microgrid.py
Attributes¤
altitude
class-attribute
instance-attribute
¤
altitude: float | None = None
Geographic altitude of the microgrid.
delivery_area
class-attribute
instance-attribute
¤
delivery_area: str | None = None
Delivery area of the microgrid.
end_time
class-attribute
instance-attribute
¤
end_time: datetime | None = None
End time of the microgrid operation.
enterprise_id
class-attribute
instance-attribute
¤
enterprise_id: int | None = None
Enterprise ID of the microgrid.
latitude
class-attribute
instance-attribute
¤
latitude: float | None = None
Geographic latitude of the microgrid.
frequenz.gridpool.config.MicrogridConfig ¤
Configuration of a microgrid.
Source code in src/frequenz/gridpool/config/microgrid.py
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 | |
Attributes¤
battery
class-attribute
instance-attribute
¤
battery: dict[str, BatteryConfig] | None = None
Configuration of the batteries.
ctype
class-attribute
instance-attribute
¤
ctype: dict[str, ComponentTypeConfig] = field(
default_factory=dict
)
Mapping of component category types to ac power component config.
pv
class-attribute
instance-attribute
¤
Configuration of the PV system.
wind
class-attribute
instance-attribute
¤
wind: dict[str, WindConfig] | None = None
Configuration of the wind turbines.
Methods:¤
component_type_ids ¤
component_type_ids(
component_type: str,
component_category: str | None = None,
metric: str = "",
) -> list[int]
Get a list of all component IDs for a component type.
| PARAMETER | DESCRIPTION |
|---|---|
component_type
|
Component type to be aggregated.
TYPE:
|
component_category
|
Specific category of component IDs to retrieve (e.g., "meter", "inverter", or "component"). If not provided, the default logic is used.
TYPE:
|
metric
|
Metric name of the formula if CIDs should be extracted from the formula.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
list[int]
|
List of component IDs for this component type. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the component type is unknown. |
KeyError
|
If |
Source code in src/frequenz/gridpool/config/microgrid.py
component_types ¤
formula ¤
Get the formula for a component type.
| PARAMETER | DESCRIPTION |
|---|---|
component_type
|
Component type to be aggregated.
TYPE:
|
metric
|
Metric to be aggregated.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
str
|
Formula to be used for this aggregated component as string. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the component type is unknown or formula is missing. |
Source code in src/frequenz/gridpool/config/microgrid.py
load_from_file
classmethod
¤
Load and validate configuration settings from a TOML file.
| PARAMETER | DESCRIPTION |
|---|---|
config_path
|
the path to the TOML configuration file.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict[str, Self]
|
A dict mapping microgrid IDs to MicrogridConfig instances. |
Source code in src/frequenz/gridpool/config/microgrid.py
frequenz.gridpool.config.PVConfig ¤
Configuration of a PV system in a microgrid.
Source code in src/frequenz/gridpool/config/microgrid.py
Attributes¤
curtailable
class-attribute
instance-attribute
¤
curtailable: bool | None = None
Flag to indicate if PV system can be curtailed.
end_time
class-attribute
instance-attribute
¤
end_time: datetime | None = None
End time of the PV system installation.
peak_power
class-attribute
instance-attribute
¤
peak_power: float | None = None
Peak power of the PV system in Watt.
frequenz.gridpool.config.WindConfig ¤
Configuration of a wind turbine in a microgrid.
Source code in src/frequenz/gridpool/config/microgrid.py
Attributes¤
end_time
class-attribute
instance-attribute
¤
end_time: datetime | None = None
End time of the wind turbine installation.
hellmann_exponent
class-attribute
instance-attribute
¤
hellmann_exponent: float | None = None
Hellmann exponent for wind speed extrapolation. See: https://w.wiki/FMw9
latitude
class-attribute
instance-attribute
¤
latitude: float | None = None
Geographic latitude of the wind turbine.
longitude
class-attribute
instance-attribute
¤
longitude: float | None = None
Geographic longitude of the wind turbine.
number_of_turbines
class-attribute
instance-attribute
¤
number_of_turbines: int = 1
Number of wind turbines.
rated_power
class-attribute
instance-attribute
¤
rated_power: float | None = None
Rated power of the wind turbine in Watt.
start_time
class-attribute
instance-attribute
¤
start_time: datetime | None = None
Start time of the wind turbine installation.
Functions:¤
frequenz.gridpool.config.load_configs
async
¤
load_configs(
default_files: (
str | Path | list[str | Path] | None
) = None,
assets_client: AssetsApiClient | None = None,
override_files: (
str | Path | list[str | Path] | None
) = None,
microgrid_ids: list[int] | None = None,
) -> dict[str, MicrogridConfig]
Load configs from up to three sources and merge them in layers.
Combines up to three sources, listed here from lowest to highest precedence: a default config file layer, the Assets API, and an override config file layer. Higher layers win on conflicts, while lower layers fill in anything the higher ones leave unset. This lets callers pick a strategy by choosing which sources to pass, for example:
default_files+assets_client: files provide defaults that the Assets API overrides.assets_client+override_files: the Assets API provides the base that files override.- all three: the Assets API sits between a default and an override file layer.
The microgrid IDs fetched from the Assets API are microgrid_ids when
given, otherwise the IDs found in the default and override files. This
lets the Assets API layer be used even when no files are given.
| PARAMETER | DESCRIPTION |
|---|---|
default_files
|
Optional path or list of paths to config files forming the lowest-precedence layer. |
assets_client
|
Optional Assets API client. When given, microgrid metadata and formulas are fetched and layered above the default files.
TYPE:
|
override_files
|
Optional path or list of paths to config files forming the highest-precedence layer. |
microgrid_ids
|
Optional explicit microgrid IDs to fetch from the Assets API. When given, these replace the IDs derived from the files, so the Assets API layer can be used without any files. |
| RETURNS | DESCRIPTION |
|---|---|
dict[str, MicrogridConfig]
|
dict[str, MicrogridConfig]:
Mapping from microgrid ID (as string) to the merged
|
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If none of the three sources is provided, or if
|
Source code in src/frequenz/gridpool/config/load.py
frequenz.gridpool.config.load_configs_from_api
async
¤
load_configs_from_api(
assets_client: AssetsApiClient, microgrid_ids: list[int]
) -> dict[str, MicrogridConfig]
Load microgrid configs from the Assets API.
For each microgrid, fetches its location metadata (latitude, longitude) and then derives the per-type formulas and meter/inverter/component IDs from its component graph. This is the canonical single-source loader so that callers (e.g. the forecast pipeline) do not have to re-implement this logic.
The two steps fail independently: a microgrid whose metadata cannot be fetched is skipped, while one whose component graph cannot be derived is still returned with metadata only. Both failures are logged as warnings.
| PARAMETER | DESCRIPTION |
|---|---|
assets_client
|
Assets API client used to fetch microgrid metadata and the component graph.
TYPE:
|
microgrid_ids
|
List of microgrid IDs to load configurations for. |
| RETURNS | DESCRIPTION |
|---|---|
dict[str, MicrogridConfig]
|
dict[str, MicrogridConfig]:
Mapping from microgrid ID (as string) to the loaded
|
Source code in src/frequenz/gridpool/config/load.py
frequenz.gridpool.config.load_configs_from_files ¤
load_configs_from_files(
microgrid_config_files: (
str | Path | list[str | Path] | None
) = None,
) -> dict[str, MicrogridConfig]
Load multiple microgrid configurations from one or more files.
Configs for a single microgrid are expected to be in a single file. Later files with the same microgrid ID will overwrite the previous configs.
| PARAMETER | DESCRIPTION |
|---|---|
microgrid_config_files
|
Path to a single microgrid config file or list of paths. |
| RETURNS | DESCRIPTION |
|---|---|
dict[str, MicrogridConfig]
|
Dictionary of single microgrid formula configs with microgrid IDs as keys. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If no config files are provided, or if no config files are found. |
Source code in src/frequenz/gridpool/config/load.py
frequenz.gridpool.config.merge_config_maps ¤
merge_config_maps(
base: dict[str, MicrogridConfig],
override: dict[str, MicrogridConfig],
) -> dict[str, MicrogridConfig]
Merge two dictionaries of MicrogridConfig objects.
For microgrid IDs present in both maps the configs are merged via
merge_microgrid_configs. IDs that exist only in one map are
included unchanged.
| PARAMETER | DESCRIPTION |
|---|---|
base
|
The base dictionary of MicrogridConfig objects.
TYPE:
|
override
|
The overriding dictionary of MicrogridConfig objects.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
dict[str, MicrogridConfig]
|
A new dictionary representing the merged result. |
Source code in src/frequenz/gridpool/config/microgrid.py
frequenz.gridpool.config.merge_microgrid_configs ¤
merge_microgrid_configs(
base: MicrogridConfig, override: MicrogridConfig
) -> MicrogridConfig
Merge two MicrogridConfig objects.
The override config takes precedence over base. Nested dictionaries
are merged recursively. If a field in override is None the value
from base is retained, so partial overrides never nullify existing data.
| PARAMETER | DESCRIPTION |
|---|---|
base
|
The base MicrogridConfig.
TYPE:
|
override
|
The overriding MicrogridConfig.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
MicrogridConfig
|
A new MicrogridConfig representing the merged result. |