See the module pypsa.io
.
PyPSA is intended to be data format agnostic, but given the reliance internally on pandas DataFrames, it is natural to use comma-separated-variable (CSV) files.
Create a folder with CSVs for each component type (e.g. generators.csv, storage_units.csv
), then a CSV for each time-dependent variable (e.g. generators-p_max_pu.csv, loads-p_set.csv
).
Then run network.import_from_csv_folder(csv_folder_name)
.
pypsa.Network.import_from_csv_folder
Note
Note that is is NOT necessary to add every single column, only those where values differ from the defaults listed in components
. All empty values/columns are filled with the defaults.
The network can be exported as a folder of csv files with network.export_to_csv_folder(csv_folder_name)
.
pypsa.Network.export_to_csv_folder
Networks can also be built step-by-step for each component by calling
pypsa.Network.add
Likewise, components can also be removed with
pypsa.Network.remove
Multiple components can be added by calling
pypsa.Network.madd
Multiple components can be removed by calling
pypsa.Network.mremove
To add multiple components whose static attributes are given in a pandas DataFrame, use
pypsa.Network.import_components_from_dataframe
To import time-varying information use
pypsa.Network.import_series_from_dataframe
netCDF files take up less space than CSV files and are faster to load.
netCDF is also preferred over HDF5 because netCDF is structured more cleanly, is easier to use from other programming languages, can limit float precision to save space and supports lazy loading.
To export network and components to a netCDF file run network.export_to_netcdf('file.nc')
.
pypsa.Network.export_to_netcdf
To import network data from netCDF file run network.import_from_netcdf(file.nc)
.
pypsa.Network.import_from_netcdf
Note
netCDF is preferred over HDF5 because netCDF is structured more cleanly, is easier to use from other programming languages, can limit float precision to save space and supports lazy loading.
To export network and components to an HDF store run network.export_to_hdf5(path)
.
pypsa.Network.export_to_hdf5
To import network data from HDF5 store at path
run network.import_from_hdf5(path)
.
pypsa.Network.import_from_hdf5
PyPSA supports import from Pypower's ppc dictionary/numpy.array format version 2.
pypsa.Network.import_from_pypower_ppc
Warning
Importing from pandapower is still in beta; not all pandapower data is supported.
PyPSA supports import from pandapower.
pypsa.Network.import_from_pandapower_net