Skip to content

Commit 3d7bb18

Browse files
authored
Document modelling choice for storing source types under one or multiple sensors (#2217)
* docs: move subsection on signs of power beliefs to live under Beliefs rather than under Annotations Signed-off-by: F.N. Claessen <claessen@seita.nl> * docs: add (cross-referenced) section for guidance on when to record data on one sensor or separate sensors Signed-off-by: F.N. Claessen <claessen@seita.nl> * docs: changelog entry Signed-off-by: F.N. Claessen <claessen@seita.nl> --------- Signed-off-by: F.N. Claessen <claessen@seita.nl> Signed-off-by: Felix Claessen <30658763+Flix6x@users.noreply.github.com>
1 parent 98d5522 commit 3d7bb18

3 files changed

Lines changed: 72 additions & 40 deletions

File tree

documentation/api/notation.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,12 @@ For the ``GET /api/v3_0/sensors/<id>/data`` endpoint specifically, source filter
289289
- ``source-account``: filter by the account ID linked to data sources
290290
- ``source-type``: filter by the type of data source (e.g. 'forecaster' or 'scheduler')
291291

292+
.. note::
293+
294+
If schedules are recorded on the same sensor as measurements or forecasts, source filtering can be used to distinguish them.
295+
An alternative is to model schedules on dedicated sensors; see :ref:`one_or_multiple_sensors`.
296+
297+
292298
.. _units:
293299

294300
Units

documentation/changelog.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Infrastructure / Support
1717
----------------------
1818
* Upgraded dependencies [see `PR #1485 <https://www.github.com/FlexMeasures/flexmeasures/pull/1485>`_ and `PR #2215 <https://www.github.com/FlexMeasures/flexmeasures/pull/2215>`_]
1919
* Prepare the ``device_scheduler`` to deal with commitments per device group [see `PR #1934 <https://www.github.com/FlexMeasures/flexmeasures/pull/1934>`_]
20+
* Documentation section on the modelling choice for recording measurements, forecasts and schedules under one or multiple sensors [see `PR #2217 <https://www.github.com/FlexMeasures/flexmeasures/pull/2217>`_]
2021

2122
Bugfixes
2223
-----------

documentation/concepts/data-model.rst

Lines changed: 65 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,74 @@ when they said so and how certain they were.
9494

9595
Each belief links to a sensor and a data source. Here are two examples:
9696

97-
9897
- The power sensor of a battery, where we store the schedules, can have two sources: (1) the schedule itself (a data source of type "scheduler", representing how FlexMeasures created this data) and (2) the realized schedule, i.e. the measurements of how the battery responded (or not) to the schedule. The latter might have a data source of type "user" (who sent the measurements to FlexMeasures).
9998
- A thermal demand sensor containing forecasts (data source of type "forecast", e.g. heating usage forecast sent to FlexMeasures or made by FlexMeasures) and measurements (sent into FlexMeasures, data source type "user").
10099

100+
See also :ref:`one_or_multiple_sensors` for guidance on when such beliefs are best recorded on one shared sensor and when separate sensors are preferable.
101+
102+
103+
.. _signs_of_power_beliefs:
104+
105+
About signs of power & energy values
106+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
107+
In short: You can use any sign you want for power data.
108+
What is recorded in the database is exactly as seen in UI charts.
109+
But the scheduler in FlexMeasures needs to know how to apply the signs.
110+
Let us explain.
111+
112+
When beliefs are about power or energy, the sign of the value is important. It indicates whether the asset is consuming or producing.
113+
However, there is no universal standard for this. Some systems use positive values for production and negative values for consumption, while others do the opposite.
114+
115+
FlexMeasures doesn't enforce any perspective (we have a design philosophy of letting users model the system in their own way).
116+
117+
For example, users can create PV power data with positive values indicating production, and they can also create building power data with positive values indicating consumption.
118+
We allow this because we want the UI to match what is in the database, and users often desire both of these datasets to be shown as positive values.
119+
We assume that this is what users send in.
120+
121+
Note that, if forecasts are created, they will have the same sign as the original data.
122+
123+
For schedules, the sign of the power schedule (as :ref:`beliefs <beliefs>`) recorded in the database, and as seen in UI charts, is determined as follows:
124+
125+
- If the flex-model contains the ``sensor`` field, and that sensor has power units (e.g. kW), the ``"consumption_is_positive"`` attribute of the sensor is used to decide the sign of the recorded data.
126+
If `True`, consumption will be saved as positive, otherwise not. To clarify:
127+
- If the attribute is not defined, **by default, scheduled power is recorded with production as positive values** (and consumption as negative values).
128+
- To record scheduled power data with consumption as positive values, set ``sensor.attributes["consumption_is_positive"] = True``.
129+
- To record scheduled power data with production as positive values (already the default, but this makes it explicit), set ``sensor.attributes["consumption_is_positive"] = False``.
130+
- If the flex-model contains the ``consumption`` field, scheduled power is recorded with consumption as positive values.
131+
The ``"consumption_is_positive"`` attribute of the referenced sensor is set automatically to ``True``.
132+
- If the flex-model contains the ``production`` field, scheduled power is recorded with production as positive values.
133+
The ``"consumption_is_positive"`` attribute of the referenced sensor is set automatically to ``False``.
134+
135+
For guidance on when schedules should share a power sensor with measurements and forecasts, and when dedicated output sensors are preferable, see :ref:`one_or_multiple_sensors`.
136+
137+
The ``GET /api/v3_0/sensors/<id>/schedules/<uuid>`` endpoint supports three sign conventions via the ``sign-convention`` query parameter:
138+
139+
- ``consumption-positive`` (default): schedules are always returned with consumption as positive values and production as negative values.
140+
- ``production-positive``: schedules are returned with production as positive values and consumption as negative values.
141+
- ``wysiwyg`` (*what-you-see-is-what-you-get*): schedules are returned with the same sign as database values and as seen in the UI charts, indicating exactly what the scheduler stored.
142+
143+
144+
.. _one_or_multiple_sensors:
145+
146+
147+
Modeling measurements, forecasts and schedules on one or multiple sensors
148+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
149+
150+
A common modeling choice is whether measurements, forecasts and schedules for an asset should all be recorded on a single power sensor, or on separate sensors.
151+
152+
Using a single sensor is advisable when these data represent different beliefs about the same physical quantity at the same connection point.
153+
In that case, keeping them on one sensor makes it explicit that measurements, forecasts and schedules all refer to the same events, and therefore should share the same unit, event resolution and sign convention.
154+
Different origins of the data can still be distinguished through their data source.
155+
156+
Using separate sensors is advisable when scheduled power should be modeled separately from measured or forecast power.
157+
This can be useful when you want to avoid filtering by source in queries, when schedules should use a different sign convention, when they should be stored at a different resolution, or when the scheduled quantity has a different operational meaning from the measured quantity.
158+
159+
For storage scheduling, the ``consumption`` and ``production`` flex-model fields support this second approach by letting FlexMeasures write schedules to dedicated output sensors.
160+
If both are defined, the scheduled power is split into its consumption and production parts.
161+
If only one is defined, the full schedule is written to that sensor using the sign convention implied by that field.
162+
163+
In short: use one sensor when you want multiple sources to express beliefs about the same underlying events; use separate sensors when you want cleaner operational separation between measured, forecast and scheduled data.
164+
101165

102166
Annotations
103167
-----------
@@ -152,45 +216,6 @@ Annotations appear in:
152216
More information, including code examples, is available in :ref:`annotations`.
153217

154218

155-
.. _signs_of_power_beliefs:
156-
157-
About signs of power & energy values
158-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
159-
In short: You can use any sign you want for power data.
160-
What is recorded in the database is exactly as seen in UI charts.
161-
But the scheduler in FlexMeasures needs to know how to apply the signs.
162-
Let us explain.
163-
164-
When beliefs are about power or energy, the sign of the value is important. It indicates whether the asset is consuming or producing.
165-
However, there is no universal standard for this. Some systems use positive values for production and negative values for consumption, while others do the opposite.
166-
167-
FlexMeasures doesn't enforce any perspective (we have a design philosophy of letting users model the system in their own way).
168-
169-
For example, users can create PV power data with positive values indicating production, and they can also create building power data with positive values indicating consumption.
170-
We allow this because we want the UI to match what is in the database, and users often desire both of these datasets to be shown as positive values.
171-
We assume that this is what users send in.
172-
173-
Note that, if forecasts are created, they will have the same sign as the original data.
174-
175-
For schedules, the sign of the power schedule (as :ref:`beliefs <beliefs>`) recorded in the database, and as seen in UI charts, is determined as follows:
176-
177-
- If the flex-model contains the ``sensor`` field, and that sensor has power units (e.g. kW), the ``"consumption_is_positive"`` attribute of the sensor is used to decide the sign of the recorded data.
178-
If `True`, consumption will be saved as positive, otherwise not. To clarify:
179-
- If the attribute is not defined, **by default, scheduled power is recorded with production as positive values** (and consumption as negative values).
180-
- To record scheduled power data with consumption as positive values, set ``sensor.attributes["consumption_is_positive"] = True``.
181-
- To record scheduled power data with production as positive values (already the default, but this makes it explicit), set ``sensor.attributes["consumption_is_positive"] = False``.
182-
- If the flex-model contains the ``consumption`` field, scheduled power is recorded with consumption as positive values.
183-
The ``"consumption_is_positive"`` attribute of the referenced sensor is set automatically to ``True``.
184-
- If the flex-model contains the ``production`` field, scheduled power is recorded with production as positive values.
185-
The ``"consumption_is_positive"`` attribute of the referenced sensor is set automatically to ``False``.
186-
187-
The ``GET /api/v3_0/sensors/<id>/schedules/<uuid>`` endpoint supports three sign conventions via the ``sign-convention`` query parameter:
188-
189-
- ``consumption-positive`` (default): schedules are always returned with consumption as positive values and production as negative values.
190-
- ``production-positive``: schedules are returned with production as positive values and consumption as negative values.
191-
- ``wysiwyg`` (*what-you-see-is-what-you-get*): schedules are returned with the same sign as database values and as seen in the UI charts, indicating exactly what the scheduler stored.
192-
193-
194219
Accounts & Users
195220
----------------
196221

0 commit comments

Comments
 (0)