Skip to content

Commit

Permalink
bugfix infinite values in dyntar analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Pecinovsky committed Sep 13, 2024
1 parent bc7ea9e commit a23595c
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions openenergyid/dyntar/main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""Main module of the DynTar package."""

import numpy as np
import pandas as pd

from openenergyid.const import (
Expand Down Expand Up @@ -122,18 +123,25 @@ def extend_dataframe_with_heatmap(df: pd.DataFrame, inplace: bool = False) -> pd
if not inplace:
df = df.copy()

heatmap_score_delivered = (
(df[ELECTRICITY_DELIVERED_SMR2] - df[ELECTRICITY_DELIVERED_SMR3])
/ df[ELECTRICITY_DELIVERED_SMR2]
* (df[RLP_WEIGHTED_PRICE_DELIVERED] - df[PRICE_ELECTRICITY_DELIVERED])
/ df[RLP_WEIGHTED_PRICE_DELIVERED]
)
heatmap_score_exported = (
(df[ELECTRICITY_EXPORTED_SMR2] - df[ELECTRICITY_EXPORTED_SMR3])
/ df[ELECTRICITY_EXPORTED_SMR2]
* (df[SPP_WEIGHTED_PRICE_EXPORTED] - df[PRICE_ELECTRICITY_EXPORTED])
/ df[SPP_WEIGHTED_PRICE_EXPORTED]
normalized_energy_delta_delivered = (
df[ELECTRICITY_DELIVERED_SMR2] - df[ELECTRICITY_DELIVERED_SMR3]
) / df[ELECTRICITY_DELIVERED_SMR2]
normalized_price_delta_delivered = (
df[RLP_WEIGHTED_PRICE_DELIVERED] - df[PRICE_ELECTRICITY_DELIVERED]
) / df[RLP_WEIGHTED_PRICE_DELIVERED]
heatmap_score_delivered = normalized_energy_delta_delivered * normalized_price_delta_delivered

normalized_energy_delta_exported = (
df[ELECTRICITY_EXPORTED_SMR2] - df[ELECTRICITY_EXPORTED_SMR3]
) / df[ELECTRICITY_EXPORTED_SMR2]
normalized_energy_delta_exported = normalized_energy_delta_exported.replace(
[np.inf, -np.inf], np.nan
)
normalized_price_delta_exported = (
df[SPP_WEIGHTED_PRICE_EXPORTED] - df[PRICE_ELECTRICITY_EXPORTED]
) / df[SPP_WEIGHTED_PRICE_EXPORTED]
heatmap_score_exported = normalized_energy_delta_exported * normalized_price_delta_exported

heatmap_score_delivered.fillna(0, inplace=True)
heatmap_score_exported.fillna(0, inplace=True)

Expand Down

0 comments on commit a23595c

Please sign in to comment.