73 lines
2.5 KiB
Python

# %%
import yaml
import logging
import numpy as np
import matplotlib.pyplot as pl
from Utilities.Shading import (
calculate_energy_production_horizontal,
calculate_energy_production_vertical,
)
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, no_of_panels_vertical = optimise_vertical_panel_pitch(c)
logger.info("Energy production for vertical panels calculated successfully.")
logger.debug(f"Vertical Energy Production: {vertical_energy.sum()}")
logger.debug("Number of panels: %d", no_of_panels_vertical)
logger.debug(f"System size: {no_of_panels_vertical * c['panel']['peak_power']/1e3} kWp")
horizontal_energy, no_of_panels_horizontal = calculate_energy_production_horizontal(c)
logger.info("Energy production for horizontal panels calculated successfully.")
logger.debug(f"Horizontal Energy Production: {horizontal_energy.sum()}")
logger.debug("Number of panels: %d", no_of_panels_horizontal)
logger.debug(
f"System size: {no_of_panels_horizontal * c['panel']['peak_power']/1e3} kWp"
)
logger.info("Energy production for horizontal panels scaled down to NOVA requirement.")
logger.info(
f"Energy production for horizontal panels: {np.round(horizontal_energy.sum(),0)} kWh"
)
logger.info(f"No. of panels for horizontal orientation: {int(no_of_panels_horizontal)}")
logger.info(
f"Energy production for vertical panels: {np.round(vertical_energy.sum(),0)} kWh"
)
logger.info(f"No. of panels for vertical orientation: {int(no_of_panels_vertical)}")
# overlay horizontal and vertical energy production
pl.figure(figsize=(10, 6))
pl.plot(
horizontal_energy.index,
horizontal_energy.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()