Skip to content

Commit

Permalink
Update IrradiationCalculator outputs and test cases to improve correc…
Browse files Browse the repository at this point in the history
…tness

- Clarified the docstring for the total direct irradiation return value.
- Changed the unit of the optimal orientation (beta) from radians to degrees in both the method return statement and corresponding docstring.
- Adjusted test case values for sunrise and sunset calculations, converting them from radians to degrees for consistency and readability.
  • Loading branch information
aaghamohammadi committed Dec 9, 2023
1 parent 6152505 commit 94894b4
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/pysolorie/numerical_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def calculate_direct_irradiation(
:type panel_orientation: float
:param day_of_year: The day of the year.
:type day_of_year: int
:return: The total direct irradiation (negative because we want to maximize).
:return: The total direct irradiation.
:rtype: float
"""
sunrise_hour_angle, sunset_hour_angle = self._observer.calculate_sunrise_sunset(
Expand All @@ -143,7 +143,7 @@ def find_optimal_orientation(self, day_of_year: int) -> float:
:param day_of_year: The day of the year.
:type day_of_year: int
:return: The optimal orientation (beta) in radians.
:return: The optimal orientation (beta) in degrees.
:rtype: float
"""
betas = np.arange(-math.pi / 2, math.pi / 2, 0.005) # Discretize beta
Expand All @@ -153,4 +153,4 @@ def find_optimal_orientation(self, day_of_year: int) -> float:
optimal_beta = betas[
np.argmax(irradiations)
] # Find beta that gives max irradiation
return optimal_beta
return math.degrees(optimal_beta)
8 changes: 4 additions & 4 deletions tests/test_pysolorie.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,28 +233,28 @@ def test_calculate_sunrise_sunset(
1200,
35.6892,
172,
0.004,
0.241,
), # Tehran Summer, day_of_year=172 (June 21)
(
"MIDLATITUDE WINTER",
1200,
35.6892,
355,
1.114,
63.839,
), # Tehran Winter, day_of_year=355 (Dec 21)
(
"TROPICAL",
26,
3.5952,
100,
-0.116,
-6.635,
), # Medan, day_of_year=100 (April 10)
(
"SUBARCTIC SUMMER",
132,
64.84361,
200,
0.569,
32.613,
), # Fairbanks Summer, day_of_year=200 (July 19)
],
)
Expand Down

0 comments on commit 94894b4

Please sign in to comment.