Closed tlestang closed 1 year ago
Note: I've avoided using NumPy (and potentially SciPy) on purpose. Bringing numpy alone means adding nearly 20MB of dependency to cats
. However I couldn't resist the urge of using numpy.testing
in the test - which brings numpy
as a test dependency only. That I can live with since it will only be required in a dev environment.
This defines a new class
WindowedForecast
representing the moving average (or sliding integration) of forecast data. The class constructor takes both a timeseries data (as a list of tuples) and a time averaging window size in units of time intervals between data points. So the time unit is 30min in the case of carbonintensity.org.uk.Individual evaluations of the moving average can be accessed using indexed notation (
__getitem__
):Individual evaluations of Integrated forecast are returned as a
CarbonIntensityPointEstimate
instance.CarbonIntensityPointEstimate
is defined as a dataclass next toWindowedForecast
. Because it is possivle to compare two instances ofCarbonIntensityPointEstimate
, it is straightforward to retrieve the minimum of the integrated forecastFinally, a
WindowedForecast
is iterable - that is it implements a__iter__
method returning an interator as a generator function.