Calculate daily rainfall from continuously increasing value
Mostrar comentarios más antiguos
So I've made a small weather thingy that reports various data to ThingSpeak. How will I go about making a Matlab Analysis that finds daily rainfall at midnight? The counter and hence the data is an ever growing variable (mm)... I'm in all aspects of the word new to this Matlab thing but I did search for answers before asking this question. Examples or links to existing working code would be much appreciated.
Kind regards, Chris
3 comentarios
dpb
el 20 de Ag. de 2018
How is the data associated with the time? Look at
doc datetime
for handling dates/times in ML
madhan ravi
el 20 de Ag. de 2018
Can you upload your code ?
Adam Danz
el 21 de Ag. de 2018
(I'm still learning about rain thingys) So, you have a tip-count per day and I assume it tips after reaching a somewhat precise, measurable volume. I saw the charts you shared on the web page but what I'd really like to see is a portion of your raw data. I still don't understand if your data is recorded every x minutes or if it's only recorded when the container tips.
Respuestas (3)
I assume you're sampling rainfall (mm) at some temporal interval and storing the rainfall and the timestamp in separate vectors or in a matrix. If your rainfall data are monotonic (ie, the rain never evaporates or leaks from the 'weather thingy' but keeps accumulating, then you could just choose a daily time such as midnight to mark the beginning of a new day and subtract the difference between days at midnight.
Example; sampling every hour
timestamp = [0 1 2 3 4 5 6 7 8 9 10 ... 22 23 0 1 2 3 ...]; %hours
rainfall = [0 0 0 1 1 1 2 2 2 2 3 ... 5 5 5 6 6 7 ...]; %mm
midnightIdx = timestamp == 0;
rainPerDay = diff(rainfall(midnightIdx));
However, if your rainfall data are not monotonic (your device leaks, evaporation), you'll need to differentiate, diff(), the entire rainfall vector which will give you the change every hour (or whatever your sample rate is) and then you'll need to add up all of the positive changes only per day, ignoring any loss in rainwater.
3 comentarios
dpb
el 20 de Ag. de 2018
"rainfall thingies" measure and dump in virtually any consumer product, actually all they do is count tips of the collector; it's just a calibrated cup w/ counterweight that dumps itself when gets full...
The interesting thing is accumulating totals by event (that may occur over the day transition) then by month, year, etc., as are measures of interest.
Adam Danz
el 20 de Ag. de 2018
I see, thanks. I was conceptualizing the data as " an ever growing variable (mm)" from the question. If the data are merely number of dumps, this answer won't work. I'll wait for clarification before removing the answer, though.
dpb
el 20 de Ag. de 2018
The value returned is in mm (or in depending on user preference) but how it's physically measured is by "tips". Now, whether OP is in the data stream where there's just a sequential trail of times and volumes at those times or whether the instrument reports a running total is dependent on its firmware; the original question implies that may be so; it's not clear to me whether it's actually a running total that's being returned or just that each time he gets new data that's more that has been accumulated but the actual data is the new accumulation.
Christoffer Veng
el 21 de Ag. de 2018
Editada: Christoffer Veng
el 21 de Ag. de 2018
Gibier Serge
el 22 de Sept. de 2023
0 votos
Bonjour,
Je suis interréssé par ce code. Pouvez-vous fournir le code complet.
Merci.
Serge
Comunidades de usuarios
Más respuestas en ThingSpeak Community
Categorías
Más información sobre ThingSpeak en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!