-
Notifications
You must be signed in to change notification settings - Fork 20
Description
What's needed?
Currently a gap is defined as one or multiple consecutive samples with None values. If the value is NaN or inf, these are not treated as gaps.
Proposed solution
Include NaN in the definition of a gap.
Use cases
Using formula engine, NaN or inf are converted to None (see
frequenz-sdk-python/src/frequenz/sdk/timeseries/_formula_engine/_formula_evaluator.py
Lines 130 to 131 in cac5473
| if isnan(res) or isinf(res): | |
| return Sample(metric_ts, None) |
When data from the microgrid API is directly injected into the moving window, this behavior is not ensured and would be inconsistent. Also if data from other sources (e.g. trading data) is injected, NaN would not be treated in the gap.
Alternatives and workarounds
- Leave it to the user to check.
- Convert
NaNtoNonewhen adding to the ring buffer.
Additional context
There was the discussion what to do with inf values. To keep it consistent with the logical meter these would also have to be converted. The same is even true for NaN, since they arise in different situations than Nones. However, inf values could be reasonable in certain context and transfer more information over None than NaNs do.