pypsa.Network.set_investment_periods

pypsa.Network.set_investment_periods#

Network.set_investment_periods(periods: Sequence) None#

Set the investment periods of the network.

If the network snapshots are a pandas.MultiIndex, the investment periods have to be a subset of the first level. If snapshots are a single index, they and all time-series are repeated for all periods. This changes the network snapshots to be a MultiIndex (inplace operation) with the first level being the investment periods and the second level the snapshots.

Parameters:

periods (list) – List of periods to be selected/initialized.

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')
>>> n.investment_periods = [1, 2]
>>> n.snapshots
MultiIndex([(1, '2015-01-01 00:00:00'),
        (1, '2015-01-01 01:00:00'),
        (1, '2015-01-01 02:00:00'),
        (2, '2015-01-01 00:00:00'),
        (2, '2015-01-01 01:00:00'),
        (2, '2015-01-01 02:00:00')],
       name='snapshot')