How to find maximum value of each event present in a series ?

2 views (last 30 days)
I have a series of 30 min interval rainfall data. The data are divided in monthly basis (one month data is attached). The series is consist of various rainfall events (rainfall events are shown in picture attached herewith). Now I would like to find out a series that consist of the maximum value of each rainfall event. (A rainfall event is basically identified by Continuous non zero value).

Accepted Answer

Mohammad Sami
Mohammad Sami on 28 Jan 2020
Edited: Mohammad Sami on 28 Jan 2020
Another option
data = readtable('2000.xlsx');
data.Date = fillmissing(data.Date,'previous'); % assume the data is in ascending order of time
data.Date = data.Date + days(data.Time);
data.Date.Format = 'dd-MM-yy hh:mm';
data.Event_id = cumsum(data.Intensity_cm_hr_ == 0); % create a new event if intensity goes to 0
data_summary = groupsummary(data,{'Event_id'},{'min' 'max'},{'Intensity_cm_hr_' 'Date' 'Date'});
data_summary(data_summary.max_Intensity_cm_hr_==0,:) = []; % remove 'events with 0 intensity
data_summary.Properties.VariableNames(:,5:6) = {'start_Date' 'end_Date'};
  5 Comments
Mohammad Sami
Mohammad Sami on 30 Jan 2020
data_summary=groupsummary(data,{'Event_id'},{'sum','max'},{'ervr','Increment','Intensity_mm_hr_','Date'});
You cannot apply sum to variable Date. If you need the Date variable, you can do groupsummary twice and then join the two outputs.
Tapasranjan Das
Tapasranjan Das on 30 Jan 2020
Thanks again... Now it works fine
data = readtable('2000_new.xlsx');
data.Date = fillmissing(data.Date,'previous'); % assume the data is in ascending order of time
% data.Date = data.Date + days(data.Time);
data.Date.Format = 'dd-MM-yy hh:mm';
data.Event_id = cumsum(data.Intensity_mm_hr_ == 0); % create a new event if intensity goes to 0
data.er=0.29*(1-0.72*exp(-0.05*data.Intensity_mm_hr_));
data.ervr=(data.er).*(data.Increment);
data_summary_1=groupsummary(data,{'Event_id'},{'sum','max'},{'ervr','Increment','Intensity_mm_hr_'});
data_summary_2=groupsummary(data,{'Event_id'},{'max'},{'Date'});
data_summary= join(data_summary_1,data_summary_2);
data_summary(data_summary.sum_Increment<12.7,:) = [];
data_summary.EI30_aug=data_summary.sum_ervr.*data_summary.max_Intensity_mm_hr_;

Sign in to comment.

More Answers (1)

Walter Roberson
Walter Roberson on 28 Jan 2020
T = readtable('2000.xslx');
Inten = T{:,5};
mask = Inten.' > 0; %row
starts = strfind([0 mask], [0 1]);
stops = strfind([mask 0], [1 0]);
event_totals = arrayfun(@(A,B) sum(Inten(A:B)), starts, stops);
[maxintens, maxpos] = max(event_totals);
max_start_time = T{starts(maxpos), 2};
max_stop_time = T{stops(maxpos), 2};
Additional work needs to be done to get the dates right, if your representative sample is correct in most date entries being blank.

Categories

Find more on Arduino Hardware in Help Center and File Exchange

Tags

No tags entered yet.

Community Treasure Hunt

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

Start Hunting!