Skip to content

Commit

Permalink
tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
peterdudfield committed Sep 27, 2023
1 parent b1d4af2 commit 2c1867a
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,17 @@ def format_plevels(national_forecast_value: NationalForecastValue):
:return:
"""
logger.debug(f"{national_forecast_value.plevels}")
power = national_forecast_value.expected_power_generation_megawatts
if (not isinstance(national_forecast_value.plevels, dict)) or (
national_forecast_value.plevels == {}
):
power = national_forecast_value.expected_power_generation_megawatts
national_forecast_value.plevels = {
"plevel_10": round(power * 0.8, 2),
"plevel_90": round(power * 1.2, 2),
}

logger.info(f"plevels set to default: {national_forecast_value.plevels}")

# rename '10' and '90' to plevel_10 and plevel_90
for c in ["10", "90"]:
if c in national_forecast_value.plevels.keys():
Expand All @@ -163,14 +165,10 @@ def format_plevels(national_forecast_value: NationalForecastValue):
)

if national_forecast_value.plevels["plevel_10"] is None:
national_forecast_value.plevels["plevel_10"] = round(
national_forecast_value.expected_power_generation_megawatts * 0.8, 2
)
national_forecast_value.plevels["plevel_10"] = round(power * 0.8, 2)

if national_forecast_value.plevels["plevel_90"] is None:
national_forecast_value.plevels["plevel_90"] = round(
national_forecast_value.expected_power_generation_megawatts * 1.2, 2
)
national_forecast_value.plevels["plevel_90"] = round(power * 1.2, 2)


def filter_forecast_values(
Expand Down

0 comments on commit 2c1867a

Please sign in to comment.