Savitzky-Golay Filter Plugin¶
The foglamp-filter-savitzky-golay plugin is a module in FogLAMP designed to apply the Savitzky-Golay smoothing algorithm to numeric data. This algorithm is widely used in digital signal processing to reduce noise in data while preserving the structure and features of the original signal. The filter operates on numeric datapoints using a sliding window approach and allows for specific configuration of datapoints or assets to target during filtering.
Savitzky-Golay Smoothing
The Savitzky-Golay filter works by fitting a polynomial to a set of data points within a specified window. It then uses the resulting polynomial to compute a smoothed value for the central point of the window. The coefficients for this polynomial are pre-calculated based on the defined window size and polynomial order.
Configuration of the Savitzky-Golay Plugin
Click on Basic to access the configuration options:
Asset Name Filter: This is a regular expression used to limit the assets that the filter will process. By default, it is set to “.*”, which means the filter will apply to all assets.
Datapoint Name Filter: Similar to the asset filter, this is a regular expression used to specify which datapoints to process. The default “.*” applies the filter to all datapoints.
Enabled: A toggle switch to enable or disable the Savitzky-Golay filter. The filter is disabled (false) by default.
Click on Save to save and activate the configuration.
Window Size¶
This defines the number of datapoints included in the sliding window for smoothing. The filter uses a fixed window size of 5, meaning it processes 5 datapoints at a time to compute the smoothed value.
Polynomial Order¶
This specifies the degree of the polynomial used in the Savitzky-Golay algorithm. The filter employs a quadratic polynomial (order 2) to fit the data within the sliding window.
Coefficients¶
The coefficients required for the Savitzky-Golay smoothing are predefined based on the window size of 5 and polynomial order of 2. These coefficients dictate the weighting of values within the window when computing the smoothed result.
Sliding Window Behavior¶
The filter uses a sliding window buffer for each datapoint. As new values enter the buffer, older values are removed once the buffer exceeds the defined window size. Smoothing begins only after the buffer is fully populated.
Data Caching¶
If the number of incoming readings is less than the window size, the filter temporarily caches the data until the buffer is complete. Once the buffer has enough data, the smoothing process starts, and the processed values are passed to the next stage in the pipeline.
Example Usage¶
To smooth data from an asset named “sensor_01” with a window size of 5 and a polynomial order of 2:
Set Asset Name Filter to “sensor_01”.
Enable the filter by switching Enabled to true.
The filter will then process numeric data from “sensor_01” and apply the Savitzky-Golay algorithm to smooth each datapoint using the configured parameters.