Skip to content

Configuration option inclusive for snapshots is confusing #2101

@euronion

Description

@euronion

Version Checks (indicate both or one)

  • I have confirmed this bug exists on the lastest release of PyPSA-Eur.

  • I have confirmed this bug exists on the current master branch of PyPSA-Eur.

Issue Description

The snapshots configuration section has the inclusive argument. In combination with the defaults, it is confusing:

e.g.

snapshots:
  start: "2019-01-01"
  end: "2020-01-01"
  inclusive: left

Gives us a full year:

DatetimeIndex(['2019-01-01 00:00:00', '2019-01-01 01:00:00',
               '2019-01-01 02:00:00', '2019-01-01 03:00:00',
               '2019-01-01 04:00:00', '2019-01-01 05:00:00',
               '2019-01-01 06:00:00', '2019-01-01 07:00:00',
               '2019-01-01 08:00:00', '2019-01-01 09:00:00',
               ...
               '2019-12-31 14:00:00', '2019-12-31 15:00:00',
               '2019-12-31 16:00:00', '2019-12-31 17:00:00',
               '2019-12-31 18:00:00', '2019-12-31 19:00:00',
               '2019-12-31 20:00:00', '2019-12-31 21:00:00',
               '2019-12-31 22:00:00', '2019-12-31 23:00:00'],
              dtype='datetime64[ns]', length=8760, freq=None)

However

snapshots:
  start: "2019-01-01"
  end: "2020-01-01"
  inclusive: right

doesn't give us 2019-01-02 until 2020-01-01, but only excludes the first hour for 2019-01-01 and includes only the first hour of 2020-01-01:

DatetimeIndex(['2019-01-01 01:00:00', '2019-01-01 02:00:00',
               '2019-01-01 03:00:00', '2019-01-01 04:00:00',
               '2019-01-01 05:00:00', '2019-01-01 06:00:00',
               '2019-01-01 07:00:00', '2019-01-01 08:00:00',
               '2019-01-01 09:00:00', '2019-01-01 10:00:00',
               ...
               '2019-12-31 15:00:00', '2019-12-31 16:00:00',
               '2019-12-31 17:00:00', '2019-12-31 18:00:00',
               '2019-12-31 19:00:00', '2019-12-31 20:00:00',
               '2019-12-31 21:00:00', '2019-12-31 22:00:00',
               '2019-12-31 23:00:00', '2020-01-01 00:00:00'],
              dtype='datetime64[ns]', length=8760, freq=None)

In my mind, the following two configuration options should behave identically:

# Option 1
snapshots:
  start: "2019-01-01"
  end: "2020-01-01"
  inclusive: left

and

# Option 2
snapshots:
  start: "2019-01-01"
  end: "2019-12-31"
  inclusive: both

But they don't.
Option 1 covers the full year of 2019.
Option 2 covers the year of 2019 except for 2019-12-31, where it only includes 2019-12-31 00:00:00 and excludes the rest of the day.

The problem here is either documentation of the default configuration entry.
There is the implicit assumption that the day specified in the config refers to the start of the day,
whilst logically left should indicate the start of the day, right the end of the dayandboththe start of thestart timestamp and the end of theend` timestamp.

It would be cleaner to use the hour of the day in the configuration as well.

Then the inclusive option works as designed and

snapshots:
  start: "2019-01-01 00:00:00"
  end: "2020-01-01 00:00:00"
  inclusive: left

becomes identical to

snapshots:
  start: "2019-01-01 00:00:00"
  end: "2019-12-31 23:00:00"
  inclusive: left

Reproducible Example

see above

Expected Behavior

see above

Installed Versions

Details Replace this line.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions