Closed cwitting closed 7 months ago
Good catch.
Can you clarify what you mean that the first index is not used for the temperature calculation?
I mean that i do not fully understand why the loop needs to start at 1. In the second loop below the temperature are accessed using "i - 1" as index, where as rain/pop is accessed using just "i".
The first loop identifies the range for max/min temperature and max rainfall (lower bound for rain fall is always 0). The first loop starts at 1 since on iteration 0 for temperature, we need to initialize both the max and min temperature to the first hourly for temperature. For rain we wouldn't need to do this since we could use max(0,hourly.rain[i]).
For the second loop, the reason temperature accesses i-1 is because it must draw a line from the previous hour to the current hour. However, this is not necessary for rain/pop since it just draws a bar for each hour and is independent of the pop of any other hour.
Noticed that if the first index of rain values where larger than the rest, the bound calculation would be off, as the loop below starts from 1. I am not sure I understand why the first index does not need to be used for the temperature calculation though.