How to find maximum value of each event present in a series ?
2 views (last 30 days)
Show older comments
Tapasranjan Das
on 28 Jan 2020
Commented: Tapasranjan Das
on 30 Jan 2020
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).
0 Comments
Accepted Answer
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
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.
More Answers (1)
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.
0 Comments
See Also
Categories
Find more on Arduino Hardware in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!