Skip to content

Lag reduction filter

Thomas Nipen edited this page Sep 1, 2021 · 3 revisions

Several authors have reported that temperature measurements from Netatmo stations have a notable temporal lag. That is, when temperature changes rapidly, a corresponding change in the measurements is delayed. Titanlib offers a function to reduce this lag:

import numpy as np                                                                                   
import titanlib                                                                                      
import matplotlib.pylab as mpl                                                                       
                                                                                                     
times = np.arange(0, 86400, 600) / 3600 # Hours                                                      
values = np.sin(times / 24 * 15)                                                                     
a = 0.4                                                                                              
b = 0.5                                                                                              
k1 = k2 = 1/a                                                                                        
corrected_values = titanlib.lag_reduction_filter(times, values, a, b, k1, k2)                        
                                                                                                     
mpl.plot(times, values, label="Raw measurements")                                                    
mpl.plot(times, corrected_values, label="Corrected measurements")                                    
mpl.legend()                                                                                         
mpl.show()

The values of a, b, k1, and k2 should be tuned for the characteristics of the sensor. For Netatmo measurements, the above values work reasonably well, but this has not been studied in details. Image