Determining the hourly time series from 5 minutes and 15 minutes time series data

10 visualizaciones (últimos 30 días)
I'm having a time series data of rainfall (5 minutes interval) and temperature (15 minutes interval) in .csv file. I need to determine the hourly rainfall (1hour interval) ie. adding the twelve 5 minutes data together and repeating it for entire time series and save it in another .csv file. Similarly for temperature data, I need to determine the hourly temperature (1hour interval) ie. averaging the four 15 minutes data together and repeating it for entire time series and save it in another .csv file. I'm attaching the time series data in .csv format.

Respuestas (2)

David Hill
David Hill el 3 de Feb. de 2022
It you were not missing data it would be an easy reshape. I think you are going to need to do datenum ranges. Convert first column to datenum values, then run loop summing the entries every hour. You might need to fill in missing data in column 2 with zero. Might take awhile to compute.
c=readcell('Rainfall.csv');
t=zeros(size(c,1)-1,1);
for k=2:size(c,1)
t(k-1)=datenum(c{k,1});
end
ti=t(1);%start time
interVal=0.04167;
rain=cell2mat(c(2:end),2);
count=1;
for k=ti+interVal:interVal:t(end)
rainHourly(count)=sum(rain(t>=ti&t<k));
ti=k;
count=count+1;
end

Lei Hou
Lei Hou el 15 de Feb. de 2022
Hi Manikandan,
You can use timetable to store your data, and use retime to resample your data.
rainfall = readtable('Rainfall.csv');
rainfall.DateTime = datetime(rainfall.DateTime,'InputFormat','dd-MM-uuuu HH:mm');
rainfallTT = table2timetable(rainfall);
rainfallHourly = retime(rainfallTT,'hourly','sum');
temperature = readtable('Temperature.csv');
temperature.DateTime = datetime(temperature.DateTime,'InputFormat','dd-MM-uuuu HH:mm');
temperatureTT = table2timetable(temperature);
temperatureHourly = retime(temperatureTT,'hourly','mean');
writetimetable(rainfallHourly,'RainfallHourly.csv');
writetimetable(temperatureHourly,'TemperatureHourly.csv');
Hoping this is helpful.
Thanks,
Lei

Categorías

Más información sobre Dates and Time 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