Creating timetable from excel for rainfall data

1 Ansicht (letzte 30 Tage)
NIKIL
NIKIL am 19 Mai 2019
Kommentiert: NIKIL am 20 Mai 2019
Hello,
I am trying to import the excel data on hourly rainfall (attached) to calculate the daily, monthly, and annual rainfall.
Could anybody help me with creating timetable for the above dataset so that it would be possible to apply retime approach to calculate the daily/monthly?
Many thanks.

Akzeptierte Antwort

Guillaume
Guillaume am 19 Mai 2019
Considering that excel has a perfectly working date/time time, one must wonder why you're not using it. At least, encoding the date and time as characters would make more sense than this completely non-standard date and time storage. In particular using hour 24 on the current day instead of hour 0 on the next day makes no sense at all.
badlyformatteddata = readtable('RAINFALL_HOURLY.xlsx');
rainfall = table2timetable(badlyformatteddata(:, 'RainMm'), 'RowTimes', datetime(compose('%d %06d', badlyformatteddata.Date, mod(badlyformatteddata.Time, 240000)), 'InputFormat', 'yyyyMMdd HHmmss'));
rainfall.Time(hour(rainfall.Time) == 0) = rainfall.Time(hour(rainfall.Time) == 0) + days(1) %To account for that stupid hour 24
  5 Kommentare
Guillaume
Guillaume am 20 Mai 2019
Bearbeitet: Guillaume am 20 Mai 2019
Ah, ok, in that case, I would set the time to the beginning of the sampling instead of the end by subtracting 1 hour from all the times. This actually makes the decoding slightly simpler (and saner):
badlyformatteddata = readtable('RAINFALL_HOURLY.xlsx');
rainfall = table2timetable(badlyformatteddata(:, 'RainMm'), 'RowTimes', datetime(compose('%d %06d', badlyformatteddata.Date, badlyformatteddata.Time-10000), 'InputFormat', 'yyyyMMdd HHmmss'))
NIKIL
NIKIL am 20 Mai 2019
Many thanks Guillaume.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Produkte


Version

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by