2025-04-02 17:22:59 +08:00

65 lines
2.1 KiB
Python

# %%
import yaml
import logging
import numpy as np
import matplotlib.pyplot as pl
from Utilities.Shading import calculate_energy_production_horizontal
from Utilities.Optimisation import optimise_vertical_panel_pitch
logging.basicConfig(
level=logging.INFO,
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
datefmt="%Y-%m-%d %H:%M:%S",
)
stream_handler = logging.StreamHandler()
stream_handler.setLevel(logging.INFO)
stream_formatter = logging.Formatter("%(levelname)s: %(message)s")
stream_handler.setFormatter(stream_formatter)
logging.getLogger().addHandler(stream_handler)
logger = logging.getLogger(__name__)
config_path = "config.yml"
with open(config_path, "r") as file:
c = yaml.safe_load(file)
logger.info("Configuration loaded successfully.")
logger.debug(f"Configuration: {c}")
# calculate energy production for horizontal and vertical panels
optimal_pitch, vertical_energy = optimise_vertical_panel_pitch(c)
logger.info("Energy production for vertical panels calculated successfully.")
logger.debug(f"Vertical Energy Production: {vertical_energy.sum()}")
horizontal_energy = calculate_energy_production_horizontal(c)
logger.info("Energy production for horizontal panels calculated successfully.")
logger.debug(f"Horizontal Energy Production: {horizontal_energy.sum()}")
NOVA_scaledown = 0.75
horizontal_energy_scaled = horizontal_energy * NOVA_scaledown
logger.info("Energy production for horizontal panels scaled down to NOVA requirement.")
logger.info(
f"Energy production for horizontal panels: {np.round(horizontal_energy_scaled.sum(),0)} kWh"
)
logger.info(
f"Energy production for vertical panels: {np.round(vertical_energy.sum(),0)} kWh"
)
# overlay horizontal and vertical energy production
pl.figure(figsize=(10, 6))
pl.plot(
horizontal_energy_scaled.index,
horizontal_energy_scaled.values,
label="Horizontal Panels",
)
pl.plot(vertical_energy.index, vertical_energy.values, label="Vertical Panels")
pl.title("Energy Production Comparison")
pl.xlabel("Time")
pl.ylabel("Energy Production (kWh)")
pl.legend()
pl.show()