Skip to content

Commit

Permalink
implement more review comments, adapt name of ProfitOrLossReporter (s…
Browse files Browse the repository at this point in the history
…ome docs didn't have the 'Or' in there

Signed-off-by: Nicolas Höning <nicolas@seita.nl>
  • Loading branch information
nhoening committed Feb 5, 2024
1 parent a223aba commit ccab5f1
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 22 deletions.
24 changes: 15 additions & 9 deletions documentation/features/reporting.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,12 @@ We believe this infrastructure will become very powerful and enable FlexMeasures
Below are two quick examples, but you can also dive deeper in :ref:`tut_toy_schedule_reporter`.


Example: solar which has not been self-consumed
Example: solar feed-in / self-consumption delta
------------------------------------------------

So here is a glimpse into a reporter we made - it is based on the ``AggregatorReporter`` (which is for the combination of any two sensors). This simplified example reporter calculates how much of your local PV power has not been covered by your own consumption:
So here is a glimpse into a reporter we made - it is based on the ``AggregatorReporter`` (which is for the combination of any two sensors).
This simplified example reporter basically calculates ``pv - consumption`` at grid connection point.
This tells us how much solar power we fed back to the grid (positive values) and/or the amount of grid power within the overall consumption which did not come from local solar panels (negative values).

.. code-block:: json
Expand Down Expand Up @@ -55,10 +57,11 @@ So here is a glimpse into a reporter we made - it is based on the ``AggregatorRe
Example: Profits & losses
---------------------------

A report that should cover a use case right off the shelf for almost everyone using FlexMeasures is the ``ProfitLossReporter`` ― a reporter to compute how profitable your operation has been.
A report that should cover a use case right off the shelf for almost everyone using FlexMeasures is the ``ProfitOrLossReporter`` ― a reporter to compute how profitable your operation has been.
Showing the results of your optimization is a crucial feature, and now easier than ever.

First, reporters can be stored as data sources, so they are easy to be used repeatedly and the data they generate can reference them. Our data source has "ProfitLossReporter" as Model and these attributes (the least a ``ProfitLossReporter`` needs to know is a price):
First, reporters can be stored as data sources, so they are easy to be used repeatedly and the data they generate can reference them.
Our data source has "ProfitOrLossReporter" as Model and these JSON info stored on its ``attribute`` define the reporter (the least a ``ProfitOrLossReporter`` needs to know is a price):

.. code-block:: json
Expand All @@ -70,24 +73,27 @@ First, reporters can be stored as data sources, so they are easy to be used repe
}
}
And here is excerpts from the tutorial in how to configure and create a report:
And here are more excerpts from the tutorial mentioned above.
Here we configure the input and output:

.. code-block:: bash
$ echo "
{
'input' : [{'sensor' : 4}],
'output' : [{'sensor' : 9}]
}" > inflexible-parameters.json
}" > profitorloss-parameters.json
The input sensor stores the power/energy flow, and the output sensor will store the report.

.. code-block:: bash
$ flexmeasures add report --source 6 \
--parameters inflexible-parameters.json \
$ flexmeasures add report\
--source 6 \
--parameters profitorloss-parameters.json \
--start-offset DB,1D --end-offset DB,2D
With these offsets, we indicate that we want the report to encompass the day of tomorrow (see Pandas offset strings).
Here, the ``ProfitOrLossReporter`` used as source (with Id 6) is the one we configured above.
With the offsets, we control the timing ― we indicate that we want the new report to encompass the day of tomorrow (see Pandas offset strings).

The report sensor will now store all costs which we know will be made tomorrow by the schedule.
2 changes: 1 addition & 1 deletion documentation/host/deployment.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Here you can learn how to get FlexMeasures onto a server.
WSGI configuration
------------------

On your own computer, ``flexmeasures run`` is a nice way to start FlexMeasures. On a production web server, you want it done the WSGI way.
On your own computer, ``flexmeasures run`` is a nice way to start FlexMeasures. On a production web server, you want it done the :abbr:`WSGI (Web Server Gateway Interface)` way.

Here, you'd want to hand FlexMeasures' ``app`` object to a WSGI process, as your platform of choice describes.
Often, that requires a WSGI script. Below is a minimal example.
Expand Down
6 changes: 3 additions & 3 deletions documentation/host/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ In addition, we'll explain some basics which you'll need:
Installing and running FlexMeasures
------------------------------------

In a nutshell, how does installation and running look like?
In a nutshell, what does installation and running look like?
Well, there are two major ways:

.. tabs::
Expand All @@ -39,7 +39,7 @@ Well, there are two major ways:
$ docker pull lfenergy/flexmeasures
$ docker run -d lfenergy/flexmeasures # this won't work just yet
The ``-d`` option keeps FlexMeasures running in the backgroubd ("detached"), as it should.
The ``-d`` option keeps FlexMeasures running in the background ("detached"), as it should.

.. note:: For more information, see :ref:`docker-image` and :ref:`docker-compose`.

Expand Down Expand Up @@ -307,7 +307,7 @@ First, you can load in data from a file (CSV or Excel) via the ``flexmeasures``
$ flexmeasures add beliefs --file my-data.csv --skiprows 2 --delimiter ";" --source OurLegacyDatabase --sensor-id 1
This assumes you have a file `my-data.csv` with measurements, which was exported from some legacy database, and that the data is about our sensor with ID 1. This command has many options, so do use its ``--help`` function.
For instance, to add data as forecasts, use the ``--beliefcol`` parameter, to say precisely when these forecasts were made. Or add ``--horizon`` for rolling forecasts if they are all the same.
For instance, to add data as forecasts, use the ``--beliefcol`` parameter, to say precisely when these forecasts were made. Or add ``--horizon`` for rolling forecasts if they all share the same horizon.

Second, you can use the `POST /api/v3_0/sensors/data <../api/v3_0.html#post--api-v3_0-sensors-data>`_ endpoint in the FlexMeasures API to send meter data.

Expand Down
2 changes: 1 addition & 1 deletion documentation/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ A quick glance
:align: center
.. :scale: 40%
A short explanation: This battery is optimized to buy power cheaply and sell it at expensive times - the red-dotted line is what FlexMeasures computed to be the best schedule, given all knowledge (in this case, the prices shown in blue). However, in the example on the right the battery has to store local solar power as well (orange line), which contrains how much it can do with its capacity (that's why the schedule is limited in capcity and thus cycling less energy overall than on the left).
A short explanation: This battery is optimized to buy power cheaply and sell it at expensive times - the red-dotted line is what FlexMeasures computed to be the best schedule, given all knowledge (in this case, the prices shown in blue). However, in the example on the right the battery has to store local solar power as well (orange line), which contrains how much it can do with its capacity (that's why the schedule is limited in capacity and thus cycling less energy overall than on the left).

.. tab:: Example code

Expand Down
2 changes: 1 addition & 1 deletion documentation/tut/flex-model-v2g.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ A storage flex-model tutorial: Vehicle-to-grid

The most powerful concept of FlexMeasures is the flex-model. We feel it is time to pay more attention to it and illustrate its effects.

As a demonstration of how to construct a suitable flex model for a given use case, let us for a moment consider a use case where FlexMeasures is asked (throough API calls) to compute :abbr:`V2G (vehicle-to-grid)` schedules.
As a demonstration of how to construct a suitable flex model for a given use case, let us for a moment consider a use case where FlexMeasures is asked (through API calls) to compute :abbr:`V2G (vehicle-to-grid)` schedules.
(For a more general introduction to flex modeling, see :ref:`describing_flexibility`.)

In this example, the client is interested in the following:
Expand Down
12 changes: 6 additions & 6 deletions documentation/tut/toy-example-reporter.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ In essence, reporters apply arbitrary transformations to data coming from some s
Currently, FlexMeasures comes with the following reporters:
- `PandasReporter`: applies arbitrary `Pandas <https://pandas.pydata.org>`_ methods to sensor data.
- `AggregatorReporter`: combines data from multiple sensors into one using any of the methods supported by the Pandas `aggregate` function (e.g. sum, average, max, min...).
- `ProfitLossReporter`: computes the profit/loss due to an energy flow under a specific tariff.
- `ProfitOrLossReporter`: computes the profit/loss due to an energy flow under a specific tariff.

Moreover, it's possible to implement your custom reporters in plugins. Instructions for this to come.

Now, coming back to the tutorial, we are going to use the `AggregatorReporter` and the `ProfitLossReporter`. In the first part, we'll use the `AggregatorReporter` to compute the (discharge) headroom of the battery in :ref:`tut_toy_schedule_expanded`. That way, we can verify the maximum power at which the battery can discharge at any point of time. In the second part, we'll use the `ProfitLossReporter` to compute the costs of operating the process of Tut. Part III in the different policies.
Now, coming back to the tutorial, we are going to use the `AggregatorReporter` and the `ProfitOrLossReporter`. In the first part, we'll use the `AggregatorReporter` to compute the (discharge) headroom of the battery in :ref:`tut_toy_schedule_expanded`. That way, we can verify the maximum power at which the battery can discharge at any point of time. In the second part, we'll use the `ProfitOrLossReporter` to compute the costs of operating the process of Tut. Part III in the different policies.

Before getting to the meat of the tutorial, we need to set up up all the entities. Instead of having to do that manually (e.g. using commands such as ``flexmeasures add sensor``), we have prepared a command that does that automatically.

Expand All @@ -34,7 +34,7 @@ Just as in previous sections, we need to run the command ``flexmeasures add toy-
Under the hood, this command is adding the following entities:
- A yearly sensor that stores the capacity of the grid connection.
- A power sensor, `headroom`, to store the remaining capacity for the battery. This is where we'll store the report.
- A `ProfitLossReporter` configured to use the prices that we set up in Tut. Part II.
- A `ProfitOrLossReporter` configured to use the prices that we set up in Tut. Part II.
- Three sensors to register the profits/losses from running the three different processes of Tut. Part III.

Let's check it out!
Expand Down Expand Up @@ -72,15 +72,15 @@ Run the command below to show the values for the `grid connection capacity`:
██ grid connection capacity
Moreover, we can check the freshly created source `<Source id=6>` which defines the `ProfitLossReporter` with the required configuration. You'll notice that the `config` is under the `data_generator` field. That's because reporters belong to a bigger category of classes that also contains the `Schedulers` and `Forecasters`.
Moreover, we can check the freshly created source `<Source id=6>` which defines the `ProfitOrLossReporter` with the required configuration. You'll notice that the `config` is under the `data_generator` field. That's because reporters belong to a bigger category of classes that also contains the `Schedulers` and `Forecasters`.

.. code-block:: bash
$ flexmeasures show data-sources --show-attributes --id 5
ID Name Type User ID Model Version Attributes
---- ------------ -------- --------- -------------- --------- -----------------------------------------
6 FlexMeasures reporter ProfitLossReporter {
6 FlexMeasures reporter ProfitOrLossReporter {
"data_generator": {
"config": {
"consumption_price_sensor": 1
Expand Down Expand Up @@ -139,7 +139,7 @@ at noon the battery can only discharge at 280kW max.
Process scheduler profit
-------------------------

For the second part of this tutorial, we are going to use the `ProfitLossReporter` to compute the losses (defined as `cost - revenue`) of operating the
For the second part of this tutorial, we are going to use the `ProfitOrLossReporter` to compute the losses (defined as `cost - revenue`) of operating the
process from Tut. Part III, under the three different policies: INFLEXIBLE, BREAKABLE and SHIFTABLE.

In addition, we'll explore another way to invoke reporters: data generators. Without going too much into detail, data generators
Expand Down
2 changes: 1 addition & 1 deletion documentation/views/asset-data.rst
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Heatmaps are great ways to spot the hotspots of activity. Usually heatmaps are a

We chose the "time map" of weekdays. From our experience, this is where you see the most interesting activity hotspots at a glance. For instance, that mornings often experience peaks. Or that Tuesday afternoons have low energy use, for some reason.

Here is how it looks like for one week of temperature data:
Here is what it looks like for one week of temperature data:

.. image:: https://github.com/FlexMeasures/screenshots/raw/main/heatmap-week-temperature.png
:align: center
Expand Down

0 comments on commit ccab5f1

Please sign in to comment.