Skip to content

Commit b45d6d5

Browse files
Merge branch 'main' into intro_text_solar_position_algorithms
2 parents 05004f5 + 044138f commit b45d6d5

File tree

9 files changed

+51
-42
lines changed

9 files changed

+51
-42
lines changed

src/solposx/refraction/archer.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,20 @@ def archer(elevation):
1818
1919
Returns
2020
-------
21-
refraction_correction : array-like
22-
Refraction correction. [degrees]
21+
np.array or pd.Series
22+
Atmospheric refraction angle. [degrees]
2323
2424
Notes
2525
-----
2626
The equation to calculate the refraction correction is given by:
2727
2828
.. math::
2929
30-
C = \text{cos}(Z) + 0.0083 \cdot \left(\frac{1}{0.955 + (20.267 \cdot \text{cos}(Z))} - 0.047121 \right)
31-
32-
Z_a = \text{arccos}(C)
33-
34-
refraction = Z - Z_a
30+
\begin{align}
31+
& C = \text{cos}(Z) + 0.0083 \cdot \left(\frac{1}{0.955 + (20.267 \cdot \text{cos}(Z))} - 0.047121 \right)\\
32+
& Z_a = \text{arccos}(C)\\
33+
& refraction = Z - Z_a\\
34+
\end{align}
3535
3636
where :math:`Z` is the true solar zenith angle and :math:`Z_a` is the
3737
aparent zenith angle.

src/solposx/refraction/bennett.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ def bennett(elevation, pressure=101325., temperature=12.):
1414
elevation : array-like
1515
True solar elevation angle (not accounting for refraction). [degrees]
1616
pressure : numeric, default 101325
17-
Local atmospheric pressure. [Pascal]
17+
Annual average atmospheric pressure. [Pascal]
1818
temperature : numeric, default 12
19-
Local air temperature. [C]
19+
Annaul average air temperature. [C]
2020
2121
Returns
2222
-------
23-
refraction_correction : numeric
24-
Refraction correction. [degrees]
23+
np.array or pd.Series
24+
Atmospheric refraction angle. [degrees]
2525
2626
Notes
2727
-----

src/solposx/refraction/hughes.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,30 +19,27 @@ def hughes(elevation, pressure=101325., temperature=12.):
1919
elevation : array-like
2020
True solar elevation angle (not accounting for refraction). [degrees]
2121
pressure : numeric, default 101325
22-
Local atmospheric pressure. [Pascal]
22+
Annual average atmospheric pressure. [Pascal]
2323
temperature : numeric, default 12
24-
Atmospheric temperature. The default in this code deviates from
24+
Annual average temperature. The default in this code deviates from
2525
[1]_, which used 10 C. [C]
2626
2727
Returns
2828
-------
29-
refraction_correction : array-like
30-
Refraction correction. [degrees]
29+
np.array or pd.Series
30+
Atmospheric refraction angle. [degrees]
3131
3232
Notes
3333
-----
3434
The equation to calculate the refraction correction is given by:
3535
3636
.. math::
3737
38-
\text{For }5° < el <= 90°:
39-
ref = \frac{58.1}{\text{tan}(el)} - \frac{0.07}{\text{tan}(el)^3} + \frac{8.6\cdot 10^{-5}}{tan(el)^5}
40-
41-
\text{For }-0.575° < el <= 5°:
42-
ref = el \cdot (-518.2 + el \cdot (103.4 + el \cdot (-12.79 + el \cdot 0.711))) + 1735
43-
44-
\text{For }el <= -0.575°:
45-
ref = \frac{-20.774}{\text{tan}(el)}
38+
\begin{align}
39+
& \frac{58.1}{\text{tan}(el)} - \frac{0.07}{\text{tan}(el)^3} + \frac{8.6\cdot 10^{-5}}{tan(el)^5} \text{ for } 5° < el <= 90°\\
40+
& el \cdot (-518.2 + el \cdot (103.4 + el \cdot (-12.79 + el \cdot 0.711))) + 1735 \text{ for } -0.575° < el <= 5°\\
41+
& \frac{-20.774}{\text{tan}(el)} \text{ for } el <= -0.575°\\
42+
\end{align}
4643
4744
where :math:`el` is the true (unrefracted) solar elevation angle.
4845

src/solposx/refraction/michalsky.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ def michalsky(elevation):
1515
1616
Returns
1717
-------
18-
refraction_correction : numeric
19-
Refraction correction. [degrees]
18+
np.array or pd.Series
19+
Atmospheric refraction angle. [degrees]
2020
2121
Notes
2222
-----

src/solposx/refraction/sg2.py

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,27 +14,25 @@ def sg2(elevation, pressure=101325., temperature=12.):
1414
elevation : array-like
1515
True solar elevation angle (not accounting for refraction). [degrees]
1616
pressure : numeric, default 101325
17-
Local atmospheric pressure. [Pascal]
17+
Annual average atmospheric pressure. [Pascal]
1818
temperature : numeric, default 12
19-
Local air temperature. [C]
19+
Annual average air temperature. [C]
2020
2121
Returns
2222
-------
23-
refraction_correction : array-like
24-
Refraction correction. [degrees]
23+
np.array or pd.Series
24+
Atmospheric refraction angle. [degrees]
2525
2626
Notes
2727
-----
2828
The equation to calculate the refraction correction is given by:
2929
3030
.. math::
3131
32-
\begin{cases}
33-
34-
\frac{P}{1010} \cdot \frac{283}{273+T} \cdot \frac{2.96706 \cdot 10^{-4}}{\text{tan}(el+0.0031376 \cdot (el+0.089186)^{-1})} & \text{for } el > -0.01 \text{ [rad]}
35-
36-
-\frac{P}{1010} \cdot \frac{283}{273+T} \cdot \frac{1.005516 \cdot 10^{-4}}{\text{tan}(el)} & \text{for } el < -0.01 \text{ [rad]}
37-
\end{cases}
32+
\begin{align}
33+
& \frac{P}{1010} \cdot \frac{283}{273+T} \cdot \frac{2.96706 \cdot 10^{-4}}{\text{tan}(el+0.0031376 \cdot (el+0.089186)^{-1})} & \text{ for } el > -0.01 \text{ [rad]}\\
34+
& -\frac{P}{1010} \cdot \frac{283}{273+T} \cdot \frac{1.005516 \cdot 10^{-4}}{\text{tan}(el)} & \text{ for } el < -0.01 \text{ [rad]}
35+
\end{align}
3836
3937
where :math:`el` is the true solar elevation angle, :math:`P` is the local
4038
air pressure, :math:`T` is the local air temperature.

src/solposx/refraction/spa.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ def spa(elevation, pressure=101325., temperature=12., refraction_limit=-0.5667):
2525
2626
Returns
2727
-------
28-
refraction_correction : numeric
29-
Refraction correction. [degrees]
28+
np.array or pd.Series
29+
Atmospheric refraction angle. [degrees]
3030
3131
Notes
3232
-----

src/solposx/solarposition/noaa.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def noaa(times, latitude, longitude, delta_t=67.0):
3030
longitude : float
3131
Longitude in decimal degrees. Positive east of prime meridian,
3232
negative to west. [degrees]
33-
delta_t : float or array, default 67.0
33+
delta_t : numeric, default 67.0
3434
Difference between terrestrial time and UT1.
3535
If delta_t is None, uses spa.calculate_deltat
3636
using time.year and time.month from pandas.DatetimeIndex.

src/solposx/solarposition/usno.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ def usno(times, latitude, longitude, delta_t=67.0, gmst_option=1):
2222
longitude : float
2323
Longitude in decimal degrees. Positive east of prime meridian,
2424
negative to west. [degrees]
25-
delta_t : float or array, default 67.0
25+
delta_t : numeric, default 67.0
2626
Difference between terrestrial time and UT1.
2727
If delta_t is None, uses spa.calculate_deltat
2828
using time.year and time.month from pandas.DatetimeIndex.
2929
For most simulations the default delta_t is sufficient.
3030
The USNO has historical and forecasted delta_t [2]_. [seconds]
31-
gmst_option : numeric, default 1
32-
Different ways of calculating the Greenwich mean sidereal time. See
33-
[1]_.
31+
gmst_option : int, default 1
32+
Different ways of calculating the Greenwich mean sidereal time.
33+
`gmst_option` needs to be either 1, 2, or 3. See [1]_.
3434
3535
Returns
3636
-------

tests/test_solarposition.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -489,3 +489,17 @@ def test_noaa_refraction_85_degrees():
489489
latitude=0, longitude=0,
490490
)
491491
assert angles['elevation'].iloc[0] == angles['apparent_elevation'].iloc[0]
492+
493+
494+
def test_delta_t_array_input():
495+
# test that delta_t can be specified as either an array or float
496+
times = pd.date_range('2020-03-23 12', periods=10, tz='UTC')
497+
delta_t = np.ones(len(times)) * 67.0
498+
# test noaa
499+
noaa_array = noaa(times, 50, 10, delta_t=delta_t)
500+
noaa_float = noaa(times, 50, 10, delta_t=67.0)
501+
pd.testing.assert_frame_equal(noaa_array, noaa_float)
502+
# test usno
503+
usno_array = usno(times, 50, 10, delta_t=delta_t)
504+
usno_float = usno(times, 50, 10, delta_t=67.0)
505+
pd.testing.assert_frame_equal(usno_array, usno_float)

0 commit comments

Comments
 (0)