Networks#

Network#

Constructor#

class pypsa.Network(import_name: str | Path = '', name: str = '', ignore_standard_types: bool = False, override_components: DataFrame | None = None, override_component_attrs: Dict | None = None, **kwargs: Any)#

Network container for all buses, one-ports and branches.

Parameters:
  • import_name (string, Path) – Path to netCDF file, HDF5 .h5 store or folder of CSV files from which to import network data. The string could be a URL. If cloudpathlib is installed, the string could be a object storage URI with an s3, gs or az URI scheme.

  • name (string, default "") – Network name.

  • ignore_standard_types (boolean, default False) – If True, do not read in PyPSA standard types into standard types DataFrames.

  • override_components (pandas.DataFrame) – If you want to override the standard PyPSA components in pypsa.components.components, pass it a DataFrame with index of component name and columns of list_name and description, following the format of pypsa.components.components. See git repository examples/new_components/.

  • override_component_attrs (pypsa.descriptors.Dict of pandas.DataFrame) – If you want to override pypsa.component_attrs, follow its format. See Components for more information.

  • kwargs – Any remaining attributes to set

Return type:

None

Examples

>>> nw1 = pypsa.Network("my_store.h5")
>>> nw2 = pypsa.Network("/my/folder")
>>> nw3 = pypsa.Network("https://github.com/PyPSA/PyPSA/raw/master/examples/scigrid-de/scigrid-with-load-gen-trafos.nc")
>>> nw4 = pypsa.Network("s3://my-bucket/my-network.nc")

General methods#

read_in_default_standard_types()

static(component_name)

Return the DataFrame of static components for component_name, i.e. n.component_names.

df(component_name)

Alias for pypsa.Network.static().

dynamic(component_name)

Return the dictionary of DataFrames of varying components for component_name, i.e. n.component_names_t.

pnl(component_name)

Alias for pypsa.Network.dynamic().

to_crs(new)

Convert the network's geometries and bus coordinates to a new coordinate reference system.

set_snapshots(snapshots[, ...])

Set the snapshots/time steps and reindex all time-dependent data.

set_investment_periods(periods)

Set the investment periods of the network.

add(class_name, name[, suffix, overwrite])

Add components to the network.

madd(class_name, names[, suffix])

Add multiple components to the network, along with their attributes.

remove(class_name, name[, suffix])

Removes a single component or a list of components from the network.

mremove(class_name, names)

Removes multiple components from the network.

copy([snapshots, investment_periods, ...])

Returns a deep copy of Network objec t.

branches()

passive_branches()

controllable_branches()

determine_network_topology([...])

Build sub_networks from topology.

iterate_components([components, skip_empty])

consistency_check([check_dtypes])

Checks the network for consistency; e.g. that all components are connected to existing buses and that no impedances are singular.

Attributes#

meta

Dictionary of the network meta data.

crs

Coordinate reference system of the network's geometries (n.shapes).

srid

Spatial reference system identifier of the network's geometries (n.shapes).

snapshots

Time steps of the network

snapshot_weightings

Weightings applied to each snapshots during the optimization (LOPF).

investment_periods

Investment steps during the optimization.

investment_period_weightings

Weightings applied to each investment period during the optimization (LOPF).

Input and output methods#

merge(other[, components_to_skip, inplace, ...])

Merge the components of two networks.

import_from_csv_folder(csv_folder_name[, ...])

Import network data from CSVs in a folder.

export_to_csv_folder(csv_folder_name[, ...])

Export network and components to a folder of CSVs.

import_from_hdf5(path[, skip_time])

Import network data from HDF5 store at path.

export_to_hdf5(path[, export_standard_types])

Export network and components to an HDF store.

import_from_netcdf(path[, skip_time])

Import network data from netCDF file or xarray Dataset at path.

export_to_netcdf([path, ...])

Export network and components to a netCDF file.

import_from_pypower_ppc(ppc[, ...])

Import network from PYPOWER PPC dictionary format version 2.

import_from_pandapower_net(net[, ...])

Import PyPSA network from pandapower net.

import_components_from_dataframe(dataframe, ...)

Import components from a pandas DataFrame.

import_series_from_dataframe(dataframe, ...)

Import time series from a pandas DataFrame.

Power flow methods#

Also see Power Flow for all power flow functions.

calculate_dependent_values()

Calculate per unit impedances and append voltages to lines and shunt impedances.

lpf([snapshots, skip_pre])

Linear power flow for generic network.

pf([snapshots, skip_pre, x_tol, use_seed, ...])

Full non-linear power flow for generic network.

Contingency analysis#

See Contingency Analysis.

Clustering methods#

See Clustering.

Optimization methods#

See Optimisation.

Statistics methods#

See Statistics.

Plotting methods#

See Plots.

Graph methods#

graph([branch_components, weight, ...])

Build NetworkX graph.

adjacency_matrix([branch_components, ...])

Construct a sparse adjacency matrix (directed)

incidence_matrix([branch_components, busorder])

Construct a sparse incidence matrix (directed)

Descriptor methods#

get_committable_i(c)

Getter function.

get_extendable_i(c)

Getter function.

get_switchable_as_dense(component, attr[, ...])

Return a Dataframe for a time-varying component attribute with values for all non-time-varying components filled in with the default values for the attribute.

get_non_extendable_i(c)

Getter function.

get_active_assets(c[, investment_period])

Get active components mask of component type in investment period(s).

Sub-Network#

Constructor#

class pypsa.SubNetwork(n: Network, name: str)#

Connected network of electric buses (AC or DC) with passive flows or isolated non-electric buses.

Generated by n.determine_network_topology().

methods#

adjacency_matrix([branch_components, ...])

Construct a sparse adjacency matrix (directed)

branches()

branches_i([active_only])

buses()

buses_i()

calculate_BODF([skip_pre])

Calculate the Branch Outage Distribution Factor (BODF) for sub_network.

calculate_B_H([skip_pre])

Calculate B and H matrices for AC or DC sub-networks.

calculate_PTDF([skip_pre])

Calculate the Power Transfer Distribution Factor (PTDF) for sub_network.

calculate_Y([skip_pre, active_branches_only])

Calculate bus admittance matrices for AC sub-networks.

find_bus_controls()

Find slack and all PV and PQ buses for a sub_network.

find_slack_bus()

Find the slack bus in a connected sub-network.

generators()

generators_i()

graph([branch_components, weight, ...])

Build NetworkX graph.

incidence_matrix([branch_components, busorder])

Construct a sparse incidence matrix (directed)

iterate_components([components, skip_empty])

Iterate over components of the sub-network and extract corresponding data.

lines_i()

loads()

loads_i()

lpf([snapshots, skip_pre])

Linear power flow for connected sub-network.

pf([snapshots, skip_pre, x_tol, use_seed, ...])

Non-linear power flow for connected sub-network.

shunt_impedances()

shunt_impedances_i()

storage_units()

storage_units_i()

stores_i()

transformers_i()