Skip to content

Latest commit

 

History

History
133 lines (76 loc) · 3.5 KB

import_export.rst

File metadata and controls

133 lines (76 loc) · 3.5 KB

Data Import and Export

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.

Import from folder of 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.

Export to folder of CSV files

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

Adding and removing components one-by-one

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

Adding and removing multiple components

Multiple components can be added by calling

pypsa.Network.madd

Multiple components can be removed by calling

pypsa.Network.mremove

Adding components using pandas DataFrames

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

Export to netCDF

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

Import from netCDF

To import network data from netCDF file run network.import_from_netcdf(file.nc).

pypsa.Network.import_from_netcdf

Export to HDF5

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

Import from HDF5

To import network data from HDF5 store at path run network.import_from_hdf5(path).

pypsa.Network.import_from_hdf5

Import from Pypower

PyPSA supports import from Pypower's ppc dictionary/numpy.array format version 2.

pypsa.Network.import_from_pypower_ppc

Import from Pandapower

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