def pyephem_earthsun_distance(time):
    pvl_logger.debug('solarposition.pyephem_earthsun_distance()')

    import ephem

    sun = ephem.Sun()
    earthsun = []
    for thetime in time:
        sun.compute(ephem.Date(thetime))
        earthsun.append(sun.earth_distance)

    return pd.Series(earthsun, index=time)
Calculates the distance from the earth to the sun using pyephem.
dataset/ETHPy150Open pvlib/pvlib-python/pvlib/solarposition.py/pyephem_earthsun_distance