plotting shadow length

This commit is contained in:
Lucas Tan 2025-04-03 20:04:22 +08:00
parent b570ca824f
commit 5792640d30
3 changed files with 13 additions and 3 deletions

View File

@ -128,9 +128,9 @@ def get_solar_data(c):
def sanity_check_minimum_pitch(c):
solar_positions, _ = get_solar_data(c)
zenith = solar_positions["zenith"].values
solar_positions["shadow_length"] = c["panel"]["dimensions"]["length"] * math.tan(
zenith
)
solar_positions["shadow_length"] = (
c["panel"]["dimensions"]["length"] + c["environment"]["height"]
) * np.tan(zenith / 180 * np.pi)
return solar_positions

View File

@ -20,6 +20,7 @@ environment:
width: 40
albedo: 0.2 # % of light reflected from the surface
tilt: 0 # degrees from horizontal
height: 50 # elevation including building height
location:
latitude: 3.1186108758412945
longitude: 101.57639813680093

View File

@ -3,12 +3,14 @@ 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_horizontal,
calculate_energy_production_vertical,
sanity_check_minimum_pitch,
)
from Utilities.Optimisation import optimise_vertical_panel_pitch
import datetime
logging.basicConfig(
level=logging.INFO,
@ -66,6 +68,9 @@ pl.plot(
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)")
@ -74,9 +79,13 @@ 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()