Skip to content

Commit 75c114a

Browse files
committed
moved ephem imports to the top of the file
1 parent e65ae6f commit 75c114a

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

pvlib/solarposition.py

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import warnings
1414
from importlib import reload
1515

16+
import ephem
1617
import numpy as np
1718
import pandas as pd
1819
import scipy.optimize as so
@@ -484,7 +485,7 @@ def _ephem_to_timezone(date, tzinfo):
484485

485486
def _ephem_setup(latitude, longitude, altitude, pressure, temperature,
486487
horizon):
487-
import ephem
488+
488489

489490
# initialize a PyEphem observer
490491
obs = ephem.Observer()
@@ -542,11 +543,6 @@ def sun_rise_set_transit_ephem(times, latitude, longitude,
542543
pyephem
543544
"""
544545

545-
try:
546-
import ephem
547-
except ImportError:
548-
raise ImportError('PyEphem must be installed')
549-
550546
# times must be localized
551547
if times.tz:
552548
tzinfo = times.tz
@@ -627,12 +623,6 @@ def pyephem(time, latitude, longitude, altitude=0., pressure=101325.,
627623
spa_python, spa_c, ephemeris
628624
"""
629625

630-
# Written by Will Holmgren (@wholmgren), University of Arizona, 2014
631-
try:
632-
import ephem
633-
except ImportError:
634-
raise ImportError('PyEphem must be installed')
635-
636626
time_utc = tools._pandas_to_utc(time)
637627

638628
sun_coords = pd.DataFrame(index=time)
@@ -933,7 +923,7 @@ def pyephem_earthsun_distance(time):
933923
pd.Series. Earth-sun distance in AU.
934924
"""
935925

936-
import ephem
926+
937927

938928
sun = ephem.Sun()
939929
earthsun = []

0 commit comments

Comments
 (0)