Implementation in Lua:
-- Please note: x values must be equidistant!
-- x scale: days
threshold_shower = 20 -- shower, if 1st derivative is above threshold_shower
time_start = 1634374075761000000
x0 = math.huge / math.huge
y0 = math.huge / math.huge
for l in io.lines( 'ts.csv' )
do
_, t, h = string.match( l, '(.*),(.*),(.*)' )
t = ( t - time_start) / 1E9 / 86400 -- convert timestamp to days
dx = t - x0
x0 = t
dy = h - y0
y0 = h
change = dy / dx / 1000 -- scale change for gnuplot ...
if change > threshold_shower
then
print( t, h, t * 86400 )
end
end
Output (grouped for better readability, columns: current time in days, humidity, current time in seconds) and discussion:
2.8380930324089 66.6 245211.23800013
OK.
4.4009757407407 80.7 380244.304
4.4010916898163 84.1 380254.32200013
4.4012079050933 86.5 380264.36300006
OK
Not detected, below threshold.
8.4040727314815 72.6 726111.884
8.4044655787052 80.7 726145.82600013
8.4046975694459 85.4 726165.87000013
OK.
8.8431113888889 70.4 764044.824
8.8432276157422 73.6 764054.86600013
8.8433431712978 76.3 764064.85000013
8.8434590046311 78.7 764074.85800013
8.8435047453719 79.7 764078.81000013
Probably a shower event - OK.
10.845959444444 71.3 937090.896
10.846074988427 73.7 937100.87900006
OK.
11.887368935185 68.1 1027068.676
11.887484293982 72.1 1027078.6430001
Inconclusive - stange event.
12.958152453704 69 1119584.372
12.958268275464 72.6 1119594.3790001
12.958384525464 76 1119604.4230001
First event below threshold, second event OK.
14.051926886575 66.8 1214086.4830001
Detected as shower event. OK?
16.15609494213 69.3 1395886.6030001
16.15621042824 71.7 1395896.5809999
16.156326354166 74.1 1395906.5969999
16.1564425 76.6 1395916.632
Bathtub event followed by a shower event. OK.
Below threshold.
17.862331319446 66 1543305.4260001
17.8624475 68.6 1543315.464
17.862898009259 76.7 1543354.388
17.863013761573 79.1 1543364.3889999
20.177188668981 65.2 1743309.1009999
20.177304050927 68.2 1743319.0700001
20.177420277778 71.4 1743329.112
20.17751244213 74.2 1743337.0750001
20.867646504631 62.9 1802964.6580001
20.867761886575 65.3 1802974.6270001
20.867877650462 67.7 1802984.6289999
20.867993888889 70.6 1802994.672
20.868109247686 73.5 1803004.6390001
23.845237418981 61.3 2060228.5129999
23.84570087963 69.4 2060268.556
23.845816180557 72.1 2060278.5180001
23.84593212963 75 2060288.536
23.846047789351 77.4 2060298.5289999
24.88141204861 65.4 2149754.0009999
24.881527835647 68.6 2149764.0049999
24.881644594907 71.3 2149774.0929999
24.881759421298 74.4 2149784.0140001
24.881875277778 76.9 2149794.024
24.88199164352 79.8 2149804.0780001
24.882107187499 82.4 2149814.0609999
24.882223148148 84.8 2149824.08
24.882339525464 87.2 2149834.1350001
24.882454108797 89.6 2149844.0350001
25.931703368056 67.3 2240499.1710001
25.931819282409 70.3 2240509.1860001
28.22510787037 69.2 2438649.32
28.225223726853 73.7 2438659.3300001
28.225339768519 78.5 2438669.356
28.22545539352 82.5 2438679.3460001
28.225571006945 85.1 2438689.3350001
29.065296423612 62.8 2511241.6110001
29.06587537037 66.4 2511291.632
29.065990173612 69.6 2511301.5510001
29.066338425926 76.2 2511331.64
29.066453877316 78.6 2511341.6150001
29.06648832176 79.3 2511344.5910001
29.06683545139 86.1 2511374.5830001
Quite a nice result …