Analyzing Rainfall data and sorting the data appropriately

5 visualizaciones (últimos 30 días)
Hello,
I need to know how do I sort the rainfall data attached into monthly data and find out the dry days, maximum rainfall, all event sizes where rainfall is greater than 1mm and 10,50,90 percentile data. The rainfall data has a 6 min time step. Thanks

Respuesta aceptada

Cris LaPierre
Cris LaPierre el 20 de Oct. de 2021
Look into timetables, groupsummary and perhaps grpstats.
  4 comentarios
Priya Joshi
Priya Joshi el 25 de Oct. de 2021
Hey Cris,
No I don't have the csv file, I was just given this spreadsheet :/
Cris LaPierre
Cris LaPierre el 25 de Oct. de 2021
It just gets a little more complicated to read in because the date and number are in double quotes, so they are getting treated as a string, and read in as a single column.
Here's what I had to do in R2021b to get it into MATLAB
data = readtable('Rainfall 1994.xlsx','Range','A:A')
Warning: Column headers from the file were modified to make them valid MATLAB identifiers before creating variable names for the table. The original column headers are saved in the VariableDescriptions property.
Set 'VariableNamingRule' to 'preserve' to use the original column headers as table variable names.
data = 87600×1 table
Date_RainfallMm_6Minutes ____________________________________ {'1/01/1994 00:00, 0.00000000'} {'1/01/1994 00:06, 0.00000000'} {'1/01/1994 00:12, 0.00000000'} {'1/01/1994 00:18, 0.00000000'} {'1/01/1994 00:24, 0.00000000'} {'1/01/1994 00:30, 0.00000000'} {'1/01/1994 00:36, 0.00000000'} {'1/01/1994 00:42, 0.00000000'} {'1/01/1994 00:48, 0.00000000'} {'1/01/1994 00:54, 0.00000000'} {'1/01/1994 01:00, 0.00000000'} {'1/01/1994 01:06, 0.00000000'} {'1/01/1994 01:12, 0.00000000'} {'1/01/1994 01:18, 0.00000000'} {'1/01/1994 01:24, 0.00000000'} {'1/01/1994 01:30, 0.00000000'}
DR = split(data{:,1},',');
Date = datetime(DR(:,1),'InputFormat','M/dd/yyyy HH:mm');
Rainfall = str2double(DR(:,2));
RF = timetable(Date,Rainfall)
RF = 87600×1 timetable
Date Rainfall ____________________ ________ 01-Jan-1994 00:00:00 0 01-Jan-1994 00:06:00 0 01-Jan-1994 00:12:00 0 01-Jan-1994 00:18:00 0 01-Jan-1994 00:24:00 0 01-Jan-1994 00:30:00 0 01-Jan-1994 00:36:00 0 01-Jan-1994 00:42:00 0 01-Jan-1994 00:48:00 0 01-Jan-1994 00:54:00 0 01-Jan-1994 01:00:00 0 01-Jan-1994 01:06:00 0 01-Jan-1994 01:12:00 0 01-Jan-1994 01:18:00 0 01-Jan-1994 01:24:00 0 01-Jan-1994 01:30:00 0
I also turned the data back into the original csv by removing the equation and the double quotes. It's a much simpler import process.
rf = readtimetable('Rainfall 1994.csv')
Warning: Column headers from the file were modified to make them valid MATLAB identifiers before creating variable names for the table. The original column headers are saved in the VariableDescriptions property.
Set 'VariableNamingRule' to 'preserve' to use the original column headers as table variable names.
rf = 87600×1 timetable
Date RainfallMm_6Minutes ________________ ___________________ 01/01/1994 00:00 0 01/01/1994 00:06 0 01/01/1994 00:12 0 01/01/1994 00:18 0 01/01/1994 00:24 0 01/01/1994 00:30 0 01/01/1994 00:36 0 01/01/1994 00:42 0 01/01/1994 00:48 0 01/01/1994 00:54 0 01/01/1994 01:00 0 01/01/1994 01:06 0 01/01/1994 01:12 0 01/01/1994 01:18 0 01/01/1994 01:24 0 01/01/1994 01:30 0
Once the data is imported, process the data however you like. MATLAB has some useful functions you may consider looking into, like retime, quantile, and groupsummary. For example, to turn your 6 minute data set into a daily data set, I might do the following
dailyRF = retime(rf,"daily","sum")
dailyRF = 365×1 timetable
Date RainfallMm_6Minutes ________________ ___________________ 01/01/1994 00:00 0.2 02/01/1994 00:00 0 03/01/1994 00:00 0 04/01/1994 00:00 0 05/01/1994 00:00 0 06/01/1994 00:00 0 07/01/1994 00:00 0 08/01/1994 00:00 0 09/01/1994 00:00 0 10/01/1994 00:00 0.86 11/01/1994 00:00 0 12/01/1994 00:00 0 13/01/1994 00:00 0 14/01/1994 00:00 0.34 15/01/1994 00:00 13.88 16/01/1994 00:00 0

Iniciar sesión para comentar.

Más respuestas (1)

Priya Joshi
Priya Joshi el 25 de Oct. de 2021
Thank you so much Cris!
I needed the data in 6 hour intervals and I was able to do that and plot the the data as well. Although when I use the percentile function it gives me the following error.
Error using internal.stats.dominantType (line 14)
Subscripting into a table using one subscript (as in t(i)) is not supported. Specify a row subscript
and a variable subscript, as in t(rows,vars). To select variables, use t(:,i) or for one variable
t.(i). To select rows, use t(i,:).
Error in prctile (line 77)
yproto = internal.stats.dominantType(x,p); % prototype output
I dont know what exactly what I'm doing wrong. I just want the 10,50 and 90th percentile values.
Also, one last thing: Is this the correct syntax for the Groupstat command. G = grpstats( eventtable, 'RainfallMm_6Minutes', 0)
I just want to have a table with the dry days which have the value 0.
Thank you so so so much :)
  4 comentarios
Cris LaPierre
Cris LaPierre el 18 de Nov. de 2021
Editada: Cris LaPierre el 18 de Nov. de 2021
Perhaps provide a simple example? It is not exactly clear to me what it is you want to do.
How did you create the graph?
Priya Joshi
Priya Joshi el 18 de Nov. de 2021
Basically I need to group rain events and dry events.In other words find the storm period and the interval between the storm periods.
I created the graph using the code below:
plot (event.Date, event.RainfallMm_6Minutes)
ylabel('Mean Rainfall (*mm)');
% Add equally spaced ticks (one every ~30 days)
xData = linspace(event.RainfallMm_6Minutes(1),event.RainfallMm_6Minutes(end),10);
d.XTick = xData;
% Add labels
fsize=12;
tx = get(gca,'XTickLabel'); set(gca,'XTickLabel',tx,'fontsize',fsize,'FontWeight','bold');
ty = get(gca,'XTickLabel'); set(gca,'XTickLabel',ty,'fontsize',fsize,'FontWeight','bold');
datetick('x','dd mmm yy','keeplimits','keepticks');
% Add gridlines
hAx=gca;
set(hAx,'YGrid','on','XGrid','on')
set(hAx,'xminorgrid','on','yminorgrid','on')

Iniciar sesión para comentar.

Categorías

Más información sobre Tables en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by