kotori
kotori copied to clipboard
Improve data export interface
Introduction
Together with @MKO1640 of Hiveeyes fame, we are considering to use the ESP32-e-Paper-Weather-Display by @G6EJD (thanks, David!) in order to display weather and hive information on a Waveshare e-Paper module [1].
We outlined how to use Arduino to acquire beehive data from the HTTP data export interface of Kotori at [2].
Objectives
Therefore, we would like to improve the HTTP export API [3] appropriately.
- Optionally export only the most recent reading.
- Optionally downsample time series data in order to reduce the amount of exported information.
Rationale
We can't know upfront about the original data acquisition frequency, but we have to take care about memory usage when data gets exported to embedded devices with constrained memory. So, we have to use "pandas.resample()" to aggregate time series data by a new time period (e.g. daily to monthly). See also:
- https://machinelearningmastery.com/resample-interpolate-time-series-data-python/
- https://benalexkeen.com/resampling-time-series-data-with-pandas/
- https://www.earthdatascience.org/courses/use-data-open-source-python/use-time-series-data-in-python/date-time-types-in-pandas-python/resample-time-series-data-pandas-python/
- https://ourcodingclub.github.io/tutorials/pandas-time-series/
[1] https://community.hiveeyes.org/t/anzeige-der-daten-auf-einem-e-paper-display/3229 [2] https://github.com/hiveeyes/hiveeyes-epaper-display/tree/master/lib/hiveeyes [3] https://getkotori.org/docs/handbook/export/
In order to downsample a Pandas DataFrame to a fixed number of rows, we can either use the rolling(n) sliding window functionality or use the one-dimensional linear interpolation function interp from NumPy. See also:
- https://stackoverflow.com/questions/44305794/pandas-resample-data-frame-with-fixed-number-of-rows
- https://gist.github.com/TobiasGlaubach/68298acdd637860f115c83ff439ac8b7