def pyephem_earthsun_distance(time):
import ephem<EOL>sun = ephem.Sun()<EOL>earthsun = []<EOL>for thetime in time:<EOL><INDENT>sun.compute(ephem.Date(thetime))<EOL>earthsun.append(sun.earth_distance)<EOL><DEDENT>return pd.Series(earthsun, index=time)<EOL>
Calculates the distance from the earth to the sun using pyephem.

Parameters
----------
time : pd.DatetimeIndex

Returns
-------
pd.Series. Earth-sun distance in AU.