powergrid_synth.core.exporter
This module implements the GridExporter class, responsible for exporting the generated synthetic grid to standard file formats.
It converts the internal NetworkX graph into pandapower and pypowsybl network objects, then delegates to their built-in export functions.
- Supported pandapower formats:
JSON, Excel, SQLite, Pickle
- Supported pypowsybl formats:
CGMES, XIIDM, MATPOWER, PSS/E, UCTE, AMPL, BIIDM, JIIDM
Module Contents
- class powergrid_synth.core.exporter.GridExporter(graph, base_mva=100.0, base_kv_map=None)[source]
Exports the generated synthetic grid to standard file formats via pandapower and pypowsybl built-in functions.
- Parameters:
graph (networkx.Graph) – The synthetic power grid as a NetworkX Graph.
base_mva (float) – System base apparent power in MVA.
base_kv_map (Optional[dict]) – Dictionary mapping voltage level indices to kV values (e.g.,
{0: 380.0, 1: 110.0, 2: 20.0}). IfNone, a default mapping is used.
Example:
exporter = GridExporter(grid, base_mva=100.0, base_kv_map={0: 380.0, 1: 110.0}) exporter.to_json("output/grid.json") exporter.to_excel("output/grid.xlsx") exporter.to_pypowsybl("output/grid", format="CGMES")
- to_cgmes(filepath, parameters=None)[source]
Export to CGMES (Common Grid Model Exchange Standard) via pypowsybl.
- Parameters:
filepath (str) – Destination directory path.
parameters (Optional[dict]) – Optional CGMES-specific parameters.
- Return type:
None
- to_excel(filepath, include_results=True)[source]
Export the grid to a pandapower Excel file.
- Parameters:
filepath (str) – Destination file path (e.g.
"output/grid.xlsx").include_results (bool) – Whether to include power flow results if available.
- Return type:
None
- to_json(filepath)[source]
Export the grid to a pandapower JSON file.
- Parameters:
filepath (str) – Destination file path (e.g.
"output/grid.json").- Return type:
None
- to_matpower(filepath)[source]
Export to MATPOWER format via pypowsybl.
- Parameters:
filepath (str) – Destination path (e.g.
"output/grid").- Return type:
None
- to_pickle(filepath)[source]
Export the grid to a pandapower pickle file.
- Parameters:
filepath (str) – Destination file path (e.g.
"output/grid.p").- Return type:
None
- to_psse(filepath)[source]
Export to PSS/E format via pypowsybl.
- Parameters:
filepath (str) – Destination path.
- Return type:
None
- to_pypowsybl(filepath, format='XIIDM', parameters=None)[source]
Export the grid using pypowsybl’s built-in save.
Supported formats: CGMES, XIIDM, MATPOWER, PSS/E, UCTE, AMPL, BIIDM, JIIDM.
- Parameters:
filepath (str) – Destination path (file or directory depending on format).
format (str) – One of the pypowsybl export format strings.
parameters (Optional[dict]) – Optional format-specific parameters.
- Return type:
None