Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add AggregatorReporter #712

Merged
merged 26 commits into from Jun 11, 2023
Merged

Conversation

victorgarcia98
Copy link
Contributor

Description

This PR adds the class AggregatorReporter to compute the aggregation (SUM or MEAN) of different sources' into a single one. This reporter allows to add the aggregate energy flows, costs, emissions, etc... of a system in a time period (e.g hourly).

Details:

  • This reporter makes source a required parameter in beliefs_search_configs.
  • Supports passing weights for the different alias. This can be used to convert a consumption (in absolute value) to a negative flow or to convert a current into power (i.e $P = V \cdot I$ for biphasic and $P = V \cdot I \cdot cos(\theta) \cdot \sqrt{3}$ for triphasic).
  • The (optional) parameter method can be set to SUM or MEAN to chose the aggregation method.

Look & Feel

{
    "beliefs_search_configs": [
        {
            "sensor": 1,
            "source" : 1,
            "alias" : "PV"
        },
        {
            "sensor": 1,
            "source" : 2,
            "alias" : "CONSUMPTION"
        }
    ],
    "method" : "SUM",
    "weights" : {
        "PV" : 1.0,
        "CONSUMPTION" : -1.0
    }
}

Testing Steps

Test for MEAN and SUM cases in flexmeasures/data/models/reporting/tests/test_aggregator.py.

…Error

Signed-off-by: Victor Garcia Reolid <victor@seita.nl>
Signed-off-by: Victor Garcia Reolid <victor@seita.nl>
Signed-off-by: Victor Garcia Reolid <victor@seita.nl>
Signed-off-by: Victor Garcia Reolid <victor@seita.nl>
Copy link
Contributor

@Flix6x Flix6x left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice to have. Are you sure you don't want this to subclass from PandasReporter instead?

flexmeasures/data/models/reporting/aggregatator.py Outdated Show resolved Hide resolved
flexmeasures/data/models/reporting/aggregatator.py Outdated Show resolved Hide resolved
flexmeasures/data/models/reporting/aggregatator.py Outdated Show resolved Hide resolved
flexmeasures/data/models/reporting/aggregatator.py Outdated Show resolved Hide resolved
flexmeasures/data/models/reporting/aggregatator.py Outdated Show resolved Hide resolved
flexmeasures/data/schemas/reporting/aggregation.py Outdated Show resolved Hide resolved
flexmeasures/data/schemas/reporting/aggregation.py Outdated Show resolved Hide resolved
flexmeasures/data/schemas/reporting/aggregation.py Outdated Show resolved Hide resolved
Signed-off-by: Victor Garcia Reolid <victor@seita.nl>
Signed-off-by: Victor Garcia Reolid <victor@seita.nl>
Signed-off-by: Victor Garcia Reolid <victor@seita.nl>
Signed-off-by: Victor Garcia Reolid <victor@seita.nl>
Signed-off-by: Victor Garcia Reolid <victor@seita.nl>
Signed-off-by: Victor Garcia Reolid <victor@seita.nl>
Signed-off-by: Victor Garcia Reolid <victor@seita.nl>
Signed-off-by: Victor Garcia Reolid <victor@seita.nl>
Signed-off-by: Victor Garcia Reolid <victor@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
flexmeasures/data/schemas/reporting/aggregation.py Outdated Show resolved Hide resolved
flexmeasures/data/models/reporting/aggregator.py Outdated Show resolved Hide resolved
flexmeasures/data/schemas/reporting/aggregation.py Outdated Show resolved Hide resolved
Signed-off-by: Victor Garcia Reolid <victor@seita.nl>
Signed-off-by: Victor Garcia Reolid <victor@seita.nl>
Signed-off-by: Victor Garcia Reolid <victor@seita.nl>
Base automatically changed from 683-trigger-scheduler-api-endpoint-fails-to-save-the-results-to-the-database-on-subsequent-calls to main June 9, 2023 15:56
Signed-off-by: Victor Garcia Reolid <victor@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
Signed-off-by: F.N. Claessen <felix@seita.nl>
Copy link
Contributor

@Flix6x Flix6x left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this can even be shipped with 0.14. I added a changelog and moved the relevant entry to the Infrastructure / Support category. I also added an experimental disclaimer, because we are planning to still refactor these classes soon (see #662).

Signed-off-by: F.N. Claessen <felix@seita.nl>
@nhoening
Copy link
Contributor

So can this be merged?

@Flix6x
Copy link
Contributor

Flix6x commented Jun 11, 2023

Yes, but let's give @victorgarcia98 a chance to review my commits first.

@victorgarcia98
Copy link
Contributor Author

Thanks! Nice the addition of the experimental warning.

@victorgarcia98 victorgarcia98 merged commit 583fc87 into main Jun 11, 2023
7 checks passed
@victorgarcia98 victorgarcia98 deleted the feature/aggregation-reporter branch June 11, 2023 20:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants