pypowsybl.network.Network.get_aliases

Network.get_aliases(all_attributes=False, attributes=None, **kwargs)[source]

Get a dataframe of aliases of all network elements.

Parameters:
  • all_attributes (bool) – flag for including all attributes in the dataframe, default is false

  • attributes (List[str] | None) – attributes to include in the dataframe. The 2 parameters are mutually exclusive. If no parameter is specified, the dataframe will include the default attributes.

  • kwargs (Buffer | _SupportsArray[dtype[Any]] | _NestedSequence[_SupportsArray[dtype[Any]]] | complex | bytes | str | _NestedSequence[complex | bytes | str]) – optional filters, passed as named arguments (for example id='ELEMENT_ID')

Returns:

A dataframe of aliases.

Return type:

DataFrame

Notes

The resulting dataframe, depending on the parameters, will include the following columns:

  • type: the type of the network element (network, line, generator, load, …)

  • alias: alias value

  • alias_type: alias type

This dataframe is indexed on the network element ID.

For CGMES imports, aliases retention depends on import parameters:

  • If iidm.import.cgmes.remove-properties-and-aliases-after-import is true, aliases are removed after import and this dataframe may be empty (default behaviour)

  • If it is false, aliases remain available.

Examples

Basic usage:

>>> import pypowsybl as pp
>>> network = pp.network.create_four_substations_node_breaker_network()
>>> network.add_aliases(id='TWT', alias='TWT_ALIAS', alias_type='external')
>>> aliases = network.get_aliases()
>>> aliases.loc['TWT']['alias']
'TWT_ALIAS'
>>> aliases.loc['TWT']['alias_type']
'external'

CGMES import example with explicit alias retention to obtain Terminal IDs and other internal CGMES ids:

>>> from pathlib import Path
>>> data_dir = globals().get('DATA_DIR', Path().resolve().parents[3] / 'data')
>>> cgmes_zip = data_dir / 'CGMES_Full.zip'
>>> network = pp.network.load(
...     str(cgmes_zip),
...     {
...         'iidm.import.cgmes.source-for-iidm-id': 'rdfID',
...         'iidm.import.cgmes.remove-properties-and-aliases-after-import': 'false',
...     },
... )
>>> aliases = network.get_aliases()
>>> list(aliases[['type', 'alias', 'alias_type']].columns)
['type', 'alias', 'alias_type']
>>> len(aliases) > 0
True