# Continuous Function from Binned Data with Consistent Integrals

I have binned energy production data (in Wh) in 5-minute intervals. This means that, at the timestamp of t + 5 minutes, the value represents the amount of energy generated in the interval from t to t + 5 minutes. Here is a generated sample:

So between time 0/60 and time 5/60, 1 Wh was generated; between time 5/60 and time 10/60, 4 Wh were generated; etc.

I would like to estimate the continuous process that underlies these discrete values. To that end, I first generate the associated step-function for power (in W).

My goal is to have a curve such as the following to estimate the continuous process. This will allow me to integrate across any interval and have an estimate of energy generation at a finer grain.

This is fairly simple just using splines. However, my constraint is that the integrals of the continuous function must match the integrals of the step-function at the discrete intervals in which the raw data are provided. So, $$\int_\frac{0}{60}^\frac{5}{60} f(t) dt = 1$$, $$\int_\frac{5}{60}^\frac{10}{60} f(t) dt = 4$$, $$\int_\frac{10}{60}^\frac{15}{60} f(t) dt = 2$$, etc.

Does anyone know of a way to do this? I'm fine hard-coding the math, but if there are packages in either Python or R that can do this, that would be great.