Skip to content

Commit

Permalink
chore: remove unused method (#357)
Browse files Browse the repository at this point in the history
  • Loading branch information
jsolaas authored Jan 24, 2024
1 parent 4c75352 commit 5a4021d
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 64 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from abc import abstractmethod
from enum import Enum
from typing import List, Literal, NamedTuple, Optional, Union
from typing import List, Literal, Optional, Union

import numpy as np
from numpy.typing import NDArray
Expand All @@ -15,14 +15,6 @@
from libecalc.core.models.results.base import EnergyFunctionResult


class ConditionsAndPowerLossResult(NamedTuple):
condition: NDArray[np.float64]
power_loss_factor: NDArray[np.float64]
energy_usage_after_condition_before_power_loss_factor: NDArray[np.float64]
resulting_energy_usage: NDArray[np.float64]
resulting_power_usage: Optional[NDArray[np.float64]]


class ConsumerFunctionResultBase(BaseModel):
"""Result object for ConsumerFunction.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,65 +4,10 @@
import numpy as np
from numpy.typing import NDArray

from libecalc.core.consumers.legacy_consumer.consumer_function.results import (
ConditionsAndPowerLossResult,
)
from libecalc.dto import VariablesMap
from libecalc.expression import Expression


def calculate_energy_usage_with_conditions_and_power_loss(
variables_map: VariablesMap,
energy_usage: NDArray[np.float64],
condition_expression: Expression,
power_loss_factor_expression: Expression,
power_usage: Optional[NDArray[np.float64]] = None,
) -> ConditionsAndPowerLossResult:
condition = get_condition_from_expression(
variables_map=variables_map,
condition_expression=condition_expression,
)
energy_usage_after_condition_before_power_loss_factor = (
energy_usage * condition if condition is not None else deepcopy(energy_usage)
)
power_usage_after_condition_before_power_loss_factor = (
(power_usage * condition if condition is not None else deepcopy(power_usage))
if power_usage is not None
else None
)

# Apply power loss factor
power_loss_factor = (
power_loss_factor_expression.evaluate(
variables=variables_map.variables, fill_length=len(variables_map.time_vector)
)
if power_loss_factor_expression is not None
else None
)
# Set final energy usage to energy usage after conditioning and power loss factor
resulting_energy_usage = apply_power_loss_factor(
energy_usage=energy_usage_after_condition_before_power_loss_factor,
power_loss_factor=power_loss_factor,
)

resulting_power_usage = (
apply_power_loss_factor(
energy_usage=power_usage_after_condition_before_power_loss_factor,
power_loss_factor=power_loss_factor,
)
if power_usage_after_condition_before_power_loss_factor is not None
else None
)

return ConditionsAndPowerLossResult(
condition=condition,
power_loss_factor=power_loss_factor,
energy_usage_after_condition_before_power_loss_factor=energy_usage_after_condition_before_power_loss_factor,
resulting_energy_usage=resulting_energy_usage,
resulting_power_usage=resulting_power_usage,
)


def get_condition_from_expression(
variables_map: VariablesMap,
condition_expression: Expression,
Expand Down

0 comments on commit 5a4021d

Please sign in to comment.