|
24 | 24 | import warnings |
25 | 25 | import datetime |
26 | 26 |
|
27 | | -from pvlib import atmosphere |
| 27 | +from pvlib import atmosphere, tools |
28 | 28 | from pvlib.tools import datetime_to_djd, djd_to_datetime |
29 | 29 |
|
30 | 30 |
|
@@ -200,11 +200,7 @@ def spa_c(time, latitude, longitude, pressure=101325, altitude=0, |
200 | 200 | raise ImportError('Could not import built-in SPA calculator. ' + |
201 | 201 | 'You may need to recompile the SPA code.') |
202 | 202 |
|
203 | | - # if localized, convert to UTC. otherwise, assume UTC. |
204 | | - try: |
205 | | - time_utc = time.tz_convert('UTC') |
206 | | - except TypeError: |
207 | | - time_utc = time |
| 203 | + time_utc = tools._pandas_to_utc(time) |
208 | 204 |
|
209 | 205 | spa_out = [] |
210 | 206 |
|
@@ -645,11 +641,7 @@ def pyephem(time, latitude, longitude, altitude=0, pressure=101325, |
645 | 641 | except ImportError: |
646 | 642 | raise ImportError('PyEphem must be installed') |
647 | 643 |
|
648 | | - # if localized, convert to UTC. otherwise, assume UTC. |
649 | | - try: |
650 | | - time_utc = time.tz_convert('UTC') |
651 | | - except TypeError: |
652 | | - time_utc = time |
| 644 | + time_utc = tools._pandas_to_utc(time) |
653 | 645 |
|
654 | 646 | sun_coords = pd.DataFrame(index=time) |
655 | 647 |
|
@@ -766,11 +758,7 @@ def ephemeris(time, latitude, longitude, pressure=101325, temperature=12): |
766 | 758 | # the SPA algorithm needs time to be expressed in terms of |
767 | 759 | # decimal UTC hours of the day of the year. |
768 | 760 |
|
769 | | - # if localized, convert to UTC. otherwise, assume UTC. |
770 | | - try: |
771 | | - time_utc = time.tz_convert('UTC') |
772 | | - except TypeError: |
773 | | - time_utc = time |
| 761 | + time_utc = tools._pandas_to_utc(time) |
774 | 762 |
|
775 | 763 | # strip out the day of the year and calculate the decimal hour |
776 | 764 | DayOfYear = time_utc.dayofyear |
|
0 commit comments