Skip to content

Commit

Permalink
Backport PR #491: Do not resample data of sensors recording instantan…
Browse files Browse the repository at this point in the history
…eous values (#491)

Do not fail asset page if one of the shown sensors records instantaneous values.

* Do not resample data of sensors recording instantaneous values

Signed-off-by: F.N. Claessen <felix@seita.nl>

* Use linear interpolation for instantaneous sensors

Signed-off-by: F.N. Claessen <felix@seita.nl>

* Changelog entry

Signed-off-by: F.N. Claessen <felix@seita.nl>

* Fix tooltip

Signed-off-by: F.N. Claessen <felix@seita.nl>

* Fix case with only instantaneous sensors

Signed-off-by: F.N. Claessen <felix@seita.nl>

* Fix changelog entry for PR #493 / Issue #492

Signed-off-by: F.N. Claessen <felix@seita.nl>

* Fix changelog date format

Signed-off-by: F.N. Claessen <felix@seita.nl>

* Add release date for 0.11.1

Signed-off-by: F.N. Claessen <felix@seita.nl>

Signed-off-by: F.N. Claessen <felix@seita.nl>
  • Loading branch information
Flix6x committed Sep 5, 2022
1 parent 8bec4f7 commit f0767ce
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 11 deletions.
9 changes: 5 additions & 4 deletions documentation/changelog.rst
Expand Up @@ -2,12 +2,13 @@
FlexMeasures Changelog
**********************

v0.11.1 | September XX, 2022
v0.11.1 | September 5, 2022
============================

Bugfixes
-----------
* Do not fail asset page if none of the sensors has any data [see `PR #492 <http://www.github.com/FlexMeasures/flexmeasures/pull/492>`_]
* Do not fail asset page if none of the sensors has any data [see `PR #493 <http://www.github.com/FlexMeasures/flexmeasures/pull/493>`_]
* Do not fail asset page if one of the shown sensors records instantaneous values [see `PR #491 <http://www.github.com/FlexMeasures/flexmeasures/pull/491>`_]


v0.11.0 | August 28, 2022
Expand Down Expand Up @@ -54,7 +55,7 @@ Bugfixes
-----------
* Fix some UI styling regressions in e.g. color contrast and hover effects [see `PR #441 <http://www.github.com/FlexMeasures/flexmeasures/pull/441>`_]

v0.10.0 | May 08, 2022
v0.10.0 | May 8, 2022
===========================

New features
Expand Down Expand Up @@ -192,7 +193,7 @@ Infrastructure / Support
* Stop automatically triggering forecasting jobs when API calls save nothing new to the database, thereby saving redundant computation [see `PR #303 <http://www.github.com/FlexMeasures/flexmeasures/pull/303>`_]


v0.7.1 | November 08, 2021
v0.7.1 | November 8, 2021
===========================

Bugfixes
Expand Down
17 changes: 12 additions & 5 deletions flexmeasures/data/models/charts/belief_charts.py
@@ -1,6 +1,6 @@
from __future__ import annotations

from datetime import datetime
from datetime import datetime, timedelta

from flexmeasures.data.models.charts.defaults import FIELD_DEFINITIONS
from flexmeasures.utils.flexmeasures_inflection import capitalize
Expand Down Expand Up @@ -72,8 +72,13 @@ def chart_for_multiple_sensors(
**override_chart_specs: dict,
):
sensors_specs = []
min_resolution_in_ms = (
min(sensor.event_resolution for sensor in sensors).total_seconds() * 1000
condition = (
sensor.event_resolution
for sensor in sensors
if sensor.event_resolution > timedelta(0)
)
minimum_non_zero_resolution_in_ms = (
min(condition).total_seconds() * 1000 if any(condition) else 0
)
for sensor in sensors:
unit = sensor.unit if sensor.unit else "a.u."
Expand Down Expand Up @@ -112,7 +117,9 @@ def chart_for_multiple_sensors(
{
"mark": {
"type": "line",
"interpolate": "step-after",
"interpolate": "step-after"
if sensor.event_resolution != timedelta(0)
else "linear",
"clip": True,
},
"encoding": {
Expand Down Expand Up @@ -143,7 +150,7 @@ def chart_for_multiple_sensors(
},
"transform": [
{
"calculate": f"datum.event_start + {min_resolution_in_ms}",
"calculate": f"datum.event_start + {minimum_non_zero_resolution_in_ms}",
"as": "event_end",
},
],
Expand Down
12 changes: 10 additions & 2 deletions flexmeasures/data/models/generic_assets.py
Expand Up @@ -381,10 +381,18 @@ def search_beliefs(
from flexmeasures.data.services.time_series import simplify_index

if sensors:
min_resolution = min(bdf.event_resolution for bdf in bdf_dict.values())
condition = (
bdf.event_resolution
for bdf in bdf_dict.values()
if bdf.event_resolution > timedelta(0)
)
minimum_non_zero_resolution = (
min(condition) if any(condition) else timedelta(0)
)
df_dict = {}
for sensor, bdf in bdf_dict.items():
bdf = bdf.resample_events(min_resolution)
if bdf.event_resolution > timedelta(0):
bdf = bdf.resample_events(minimum_non_zero_resolution)
df = simplify_index(
bdf, index_levels_to_columns=["source"]
).set_index(["source"], append=True)
Expand Down

0 comments on commit f0767ce

Please sign in to comment.