inflow: weekly to hourly, linear interpolation

Hey everybody! I bit confusing, I believe I have a fundamental wrong understanding of my math.
How do I calculate hourly water inflow from weekly inflow?
background: I am working on an optimisation problem and all my data (price, wind, solar) is in hourly timesteps, just my inflow is weekly. I got weekly inflow data (see code), e.g., in week 2 --> 232 million m3 water flow into a certain reservoir.
If I were to calculate a step-interpolation (every hour the same amount of water), it would be 1.38 million m3 / per hour (168*1.38 = 323). Whats about linear interpolation? I tried the build-in interpl function, but received the y-axis point of the graph, not the actual inflow. E.g., in [hour = inflow] hour 167 = 231.9464, hour 168 = 232, hour 169 = 232.0535 - which is wrong because the oveerall weekly inflow would be much greater than 323. I tried to subtract the weekly inflow (e.g., 232) from the calculated value, but even then I get the wrong overall inflow (e.g., 750 milliom m3). Remeber, the overall inflow in week two should be 323 million m3. I searched answers and found a bit on temperature or index values, where interpolation in the way I did below makes sense. But, with the extra constraint that the sum of hourly inflows needs to be the weekly inflow, I cannot get my head around.
How do I calculate a linear or even a spline interpolated inflow of each hour?
clear all var
%hourly inflow
inflow_weekly = [223 232 241 437 308 246 192 77 62 59 63 53 86 129 328 1626 1439 1189 3849 2463 1798 1956 1181 1376 902 445 308 209 188 241 690 1118 1430 854 626 1321 2858 2426 1881 1123 1918 888 1132 503 957 1259 245 465 433 153 203 362];
%time set
t = 1:168:52*168 ;
% interpolation
ti = 1:1:52*168 ;
inflow_hourly = interp1(t,inflow_weekly,ti) ;
%graph
plot(t,inflow_weekly,'.-r')
hold on
plot(ti,inflow_hourly,'b')
legend('Original', 'interpolated')
Here is the inflow as well as the interpolated inflow.

5 Comments

What is hourly inflow? Average or growing/falling?
Hey, I guess growing/falling within a week, like in your first image. Not 100% sure if I got you right.
Let's look at week 15. Week 15 has a lower inflow (328 million m^3) than week 16 (1628). If I were to re-build natrual inflow, I would assume that little inflow is happening at the beginning of the week and much of the 328 million m^3 flows at the end end of week 15. But, in sum, the 168 hours of wek 15 should have no more inflow than 328.
Like with rain. If it rains 2 m^3 in week one and 50 m^3 in week two, I would think that it didn't just start raining heavily on monday morning of week 2, but rather build up during the weekend of week 1.
I might even be interested in understaning how to calculate a spine/non-linear growing/falling function. But, more on that later.
THANKS!
What about this? Interpolate your data as you did and divide it by 168
t = 0:168:51*168;
ti = 0:1:51*168;
a1 = sum(inflow_weekly);
a2 = sum(inflow_hourly)/168;
a1-a2 % summary for year: close to zero
Thank you! This is a hugh step forward.
Do you understand why the difference is still 290 million m3 / 0.65 % of the yearly inflow? It's rather small, but still I wonder why this is. Thank you already!
I think it's not that simple. Imagine
1 + 3 + 7 = 11
You want more points
1 + 2 + 3 + 5 + 7 = 18
But 18/11 doesn't equal to 5/3 (number of points)

Sign in to comment.

 Accepted Answer

The calculation/thoughts of darova did the trick! Thanks again!
t = 0:168:51*168;
ti = 0:1:51*168;
a1 = sum(inflow_weekly);
a2 = sum(inflow_hourly)/168;
a1-a2 % summary for year: close to zero
Sadly, still no idea why the difference between interpolated inflow and non-interpolated inflow.

More Answers (0)

Categories

Products

Release

R2019b

Asked:

on 30 Mar 2020

Answered:

on 3 Apr 2020

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!