-
-
Notifications
You must be signed in to change notification settings - Fork 667
Description
Description
This feature would add an option to pybamm.Interpolate
that would allow for holding the of the interpolant at the previous value until the next value is reached. For example, if the interpolant f
has the following knots and values
knots = [0,1,2]
values=[10,0,0],
then f(0.5)=10
and f(1.5)=0
Motivation
It seems natural to me for some drive cycles to use a zero order hold interpolation. In other words, rather than linearly interpolating the current/power/etc, hold at the previous one until the next time point is reached. This is implicitly how the string experiments work, i.e. ["Discharge at 3A for 25 seconds","Rest for 25 seconds"] holds at 3A until 25 seconds rather than linearly changing the current. However, since pybamm.Interpolate
only supports linear, cubic, and pchip interpolation, this is a little bit cumbersome right now.
Possible Implementation
It would be pretty straightforward to add a zero order hold option to interpolate (it is supported by scipy.interpolate). I think only 1D is necessary, I can't think of a case where one would want this in multiple dimensions.
Additional context
if there's already an easy way of doing this lmk, otherwise I am going to implement it