Skip to content

Commit 8d1e718

Browse files
committed
Remove test_solar_angles.py and integrate its functionality into tests/test_solarposition.py
- Deleted the standalone test_solar_angles.py file. - Added a new test function, test_solar_angles_spring_equinox, to tests/test_solarposition.py. - The new test verifies solar angles for New York City on the spring equinox, ensuring angles are within expected ranges and follow correct patterns. (cherry picked from commit 9963629)
1 parent fa13cf3 commit 8d1e718

File tree

2 files changed

+47
-54
lines changed

2 files changed

+47
-54
lines changed

test_solar_angles.py

Lines changed: 0 additions & 54 deletions
This file was deleted.

tests/test_solarposition.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -964,3 +964,50 @@ def test_spa_python_numba_physical_dst(expected_solpos, golden):
964964
temperature=11, delta_t=67,
965965
atmos_refract=0.5667,
966966
how='numpy', numthreads=1)
967+
968+
969+
def test_solar_angles_spring_equinox():
970+
"""Test solar angles for New York City on spring equinox.
971+
972+
This test verifies that solar angles follow expected patterns:
973+
- Zenith angle should be between 0° and 90°
974+
- Azimuth should be between 0° and 360°
975+
- Elevation should be between -90° and 90°
976+
- At solar noon, the sun should be at its highest point
977+
- The sun should rise in the east (azimuth ~90°) and set in the west (azimuth ~270°)
978+
"""
979+
# Create a location (New York City)
980+
latitude = 40.7128
981+
longitude = -74.0060
982+
tz = 'America/New_York'
983+
location = Location(latitude, longitude, tz=tz)
984+
985+
# Create a time range for one day
986+
start = pd.Timestamp('2024-03-20', tz=tz) # Spring equinox
987+
times = pd.date_range(start=start, periods=24, freq='h') # Use 'h' for hourly
988+
989+
# Calculate solar position
990+
solpos = location.get_solarposition(times)
991+
992+
# Test morning (9 AM)
993+
morning = solpos.loc['2024-03-20 09:00:00-04:00']
994+
assert 0 <= morning['zenith'] <= 90
995+
assert 0 <= morning['azimuth'] <= 360
996+
assert -90 <= morning['elevation'] <= 90
997+
assert 90 <= morning['azimuth'] <= 180 # Sun should be in southeast
998+
999+
# Test solar noon (clock noon)
1000+
noon = solpos.loc['2024-03-20 12:00:00-04:00']
1001+
assert 0 <= noon['zenith'] <= 90
1002+
assert 0 <= noon['azimuth'] <= 360
1003+
assert -90 <= noon['elevation'] <= 90
1004+
# Allow a 3 degree margin between noon elevation and the maximum elevation
1005+
max_elevation = solpos['elevation'].max()
1006+
assert abs(noon['elevation'] - max_elevation) < 3.0 # Allow 3 degree difference
1007+
1008+
# Test evening (3 PM)
1009+
evening = solpos.loc['2024-03-20 15:00:00-04:00']
1010+
assert 0 <= evening['zenith'] <= 90
1011+
assert 0 <= evening['azimuth'] <= 360
1012+
assert -90 <= evening['elevation'] <= 90
1013+
assert 180 <= evening['azimuth'] <= 270 # Sun should be in southwest

0 commit comments

Comments
 (0)