93 lines
3.1 KiB
Python
93 lines
3.1 KiB
Python
# %%
|
|
import yaml
|
|
import logging
|
|
import numpy as np
|
|
import matplotlib.pyplot as pl
|
|
import matplotlib.dates as mdates
|
|
from Utilities.Shading import (
|
|
calculate_energy_production,
|
|
sanity_check_minimum_pitch,
|
|
)
|
|
from Utilities.Optimisation import optimise_vertical_panel_pitch
|
|
import datetime
|
|
|
|
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(
|
|
c, "horizontal"
|
|
)
|
|
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.subplot(2, 1, 1)
|
|
pl.plot(
|
|
horizontal_energy.index,
|
|
horizontal_energy.values,
|
|
label="Horizontal Panels",
|
|
)
|
|
pl.plot(vertical_energy.index, vertical_energy.values, label="Vertical Panels")
|
|
pl.gca().xaxis.set_major_formatter(
|
|
mdates.DateFormatter("%H:%M", tz=datetime.timezone(datetime.timedelta(hours=8)))
|
|
)
|
|
pl.title("Energy Production Comparison")
|
|
pl.xlabel("Time")
|
|
pl.ylabel("Energy Production (kWh)")
|
|
pl.legend()
|
|
|
|
solar_positions = sanity_check_minimum_pitch(c)
|
|
pl.subplot(2, 1, 2)
|
|
pl.plot(solar_positions.index, solar_positions["shadow_length"], label="Shadow Length")
|
|
pl.gca().xaxis.set_major_formatter(
|
|
mdates.DateFormatter("%H:%M", tz=datetime.timezone(datetime.timedelta(hours=8)))
|
|
)
|
|
pl.title("Shadow Lengths Throughout the Day")
|
|
pl.xlabel("Time")
|
|
pl.ylabel("Shadow Length (m)")
|
|
pl.legend()
|
|
|
|
pl.tight_layout()
|
|
pl.show()
|