Skip to content

Commit 0ed8898

Browse files
committed
Example at solarposition.hour_angle()
1 parent ec24a16 commit 0ed8898

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

pvlib/solarposition.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
from pvlib import atmosphere, tools
2727
from pvlib.tools import datetime_to_djd, djd_to_datetime
28+
from pvlib._deprecation import renamed_kwarg_warning
2829

2930

3031
def get_solarposition(time, latitude, longitude,
@@ -1340,15 +1341,20 @@ def solar_zenith_analytical(latitude, hourangle, declination):
13401341
)
13411342

13421343

1343-
def hour_angle(times, longitude, equation_of_time):
1344+
@renamed_kwarg_warning("0.11.2", "times", "time", "0.12.0")
1345+
def hour_angle(time, longitude, equation_of_time):
13441346
"""
13451347
Hour angle in local solar time. Zero at local solar noon.
13461348
13471349
Parameters
13481350
----------
1349-
times : :class:`pandas.DatetimeIndex`
1351+
time : :class:`pandas.DatetimeIndex`
13501352
Corresponding timestamps, must be localized to the timezone for the
13511353
``longitude``.
1354+
1355+
.. versionchanged:: 0.11.2
1356+
Renamed from ``times`` to ``time``.
1357+
13521358
longitude : numeric
13531359
Longitude in degrees
13541360
equation_of_time : numeric
@@ -1376,14 +1382,14 @@ def hour_angle(times, longitude, equation_of_time):
13761382
equation_of_time_pvcdrom
13771383
"""
13781384

1379-
# times must be localized
1380-
if not times.tz:
1381-
raise ValueError('times must be localized')
1385+
# time must be localized
1386+
if not time.tz:
1387+
raise ValueError('time must be localized')
13821388

1383-
# hours - timezone = (times - normalized_times) - (naive_times - times)
1384-
tzs = np.array([ts.utcoffset().total_seconds() for ts in times]) / 3600
1389+
# hours - timezone = (time - normalized_time) - (naive_time - time)
1390+
tzs = np.array([ts.utcoffset().total_seconds() for ts in time]) / 3600
13851391

1386-
hrs_minus_tzs = _times_to_hours_after_local_midnight(times) - tzs
1392+
hrs_minus_tzs = _times_to_hours_after_local_midnight(time) - tzs
13871393

13881394
return 15. * (hrs_minus_tzs - 12.) + longitude + equation_of_time / 4.
13891395

0 commit comments

Comments
 (0)