oemof-solph icon indicating copy to clipboard operation
oemof-solph copied to clipboard

pandas DatetimeIndex vs. PeriodsIndex in EnergySystem object

Open simnh opened this issue 5 years ago • 2 comments

I just stumbled upon the difference between periods and timesteps:

https://stackoverflow.com/questions/42284591/python-pandas-difference-between-timestamps-and-period-range

From that definition I would think, that the es.timeindex should rather be a period index. However, I do not yet know the positive/negative implications.

simnh avatar Mar 07 '19 10:03 simnh

This depends heavily on the definition. You might say, the timestamp gives the point in time where some value changes. But is the named value the new one or is it valid until the time stamp? (Also, we have a fencepost problem, as one value - the first or the last one - has to be ignored. E.g., you need 25 values to describe every hour of one day.) With this respect, the use of periods is be more intuitive as it does not require further definitions.

However, pandas.PeriodIndex features

ordinal values indicating regular periods in time which is not compatible with oemof's aspiration to support irregular time periods. (For example, the GenericStorage defines a loss per time stamp but giving it a sequence allows to have different time spans.)

I would conclude that the pd.DateTimeIndex is the lesser of the two evils. Also, explicitly defining perfectly aligned but irregular time spans would require require either redundant information (starting point and time span, but t_n+ dt_n = t_{n+1}) or more points in time than actual data points.

p-snft avatar Apr 24 '19 09:04 p-snft

Another thought would be to drop our strive to support unequal time steps. In some cases (e.g. minimum_uptime in NonConvex), time is anyway given as a number of time steps.

p-snft avatar Apr 25 '19 07:04 p-snft

We now have a good solution for time that is released with v0.5.

p-snft avatar Nov 10 '22 05:11 p-snft