How to calculate the number of rainfall events and amount of rainfall per event?

6 次查看(过去 30 天)
I would like to find the number of rainfall events and the amount of rainfall per event from some hourly precipitation data. The criteria is that there must be 6 hours or more of no rainfall between events. I would also like to find the number of runoff events - these start at the same time as the rainfall events but continue for 6 hours after the rainfall event has finished. If someone could help me out with this I'd be very grateful!

回答(1 个)

VINAYAK LUHA
VINAYAK LUHA 2023-10-12
Hi Eleanor,
I understand that you have hourly precipitation data in which you want to determine the number of rainfall events and the amount of rain per-rainfall event in MATLAB.
Besides, as per my understanding, It is also understood that there should be a minimum of 6 dry hours between any two rainfall events.
It is assumed that you have hourly rainfall data for a month stored in an array called "rain" with a size of 24*30. The maximum number of rainfall events in a month occur when rainfall and no-rainfall events alternate every 6 hours. Therefore, as an optimization here, you can pre-allocate an array called "amtRainArr" with a size of (2430)/12 to store the amount of rain received.
Further, to address the issue of determining the number of rainfall events and the rainfall amount per event, you can refer to the below documented code snippet which attempts to solve the problem using the "two pointers approach"
%Hourly rainfall data
rain = zeros(1,24*30);
%iterator over the rain array
curr =1;
%iterator to keep track of last rain hour before current hour
last =-6;
%arr to store rain amount per rain event
amtRainArr =zeros(length(rain)/12);
%iterator over amtRainArr
idx =0;
%Loop over the "rain" array
for curr=1:length(rain)
if(rain(curr)~=0)
%In the hours it rains,
%Check whether the current hour falls in the previous rainfall event.
if(curr-last>5)
%if the duration between two consecutive rain hours is > 5
%The current hour marks the begining of new rainfall event
idx=idx+1;
amtRainArr(idx)=rain(curr);
last=curr;
else
%The current rain hour is a part of previous rainfall event
%Add current rainfall amount to amtRainArr
amtRainArr(idx)=amtRainArr(idx)+rain(curr);
end
end
end
I hope you find the provided solution useful, and this helps you correctly determine the number of rainfall events and the amount of rain per-rainfall event.
Regards,
Vinayak Luha

类别

Help CenterFile Exchange 中查找有关 Dates and Time 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by