필터 지우기
필터 지우기

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

조회 수: 4 (최근 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에서 MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by