pypsa.Network.set_snapshots

pypsa.Network.set_snapshots#

Network.set_snapshots(snapshots: Sequence, default_snapshot_weightings: float = 1.0, weightings_from_timedelta: bool = False) None#

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

Snapshot weightings, typically representing the hourly length of each snapshot, is filled with the default_snapshot_weighintgs value, or uses the timedelta of the snapshots if weightings_from_timedelta flag is True, and snapshots are of type pd.DatetimeIndex.

This will reindex all components time-dependent DataFrames (pypsa.Network.dynamic()). NaNs are filled with the default value for that quantity.

Parameters:
  • snapshots (list, pandas.Index or pd.MultiIndex) – All time steps.

  • default_snapshot_weightings (float) – The default weight for each snapshot. Defaults to 1.0.

  • weightings_from_timedelta (bool) – Wheter to use the timedelta of snapshots as snapshot_weightings if snapshots is of type pd.DatetimeIndex. Defaults to False.

Examples

>>> n = pypsa.Network()
>>> n.set_snapshots(pd.date_range("2015-01-01", freq="h", periods=3))
>>> n.snapshots
DatetimeIndex(['2015-01-01 00:00:00', '2015-01-01 01:00:00',
               '2015-01-01 02:00:00'],
              dtype='datetime64[ns]', name='snapshot', freq='h')