def sun_rise_set_transit_ephem(times, latitude, longitude,<EOL>next_or_previous='<STR_LIT>',<EOL>altitude=<NUM_LIT:0>,<EOL>pressure=<NUM_LIT>,<EOL>temperature=<NUM_LIT:12>, horizon='<STR_LIT>'):
try:<EOL><INDENT>import ephem<EOL><DEDENT>except ImportError:<EOL><INDENT>raise ImportError('<STR_LIT>')<EOL><DEDENT>if times.tz:<EOL><INDENT>tzinfo = times.tz<EOL><DEDENT>else:<EOL><INDENT>raise ValueError('<STR_LIT>')<EOL><DEDENT>obs, sun = _ephem_setup(latitude, longitude, altitude,<EOL>pressure, temperature, horizon)<EOL>if next_or_previous.lower() == '<STR_LIT>':<EOL><INDENT>rising = obs.next_rising<EOL>setting = obs.next_setting<EOL>transit = obs.next_transit<EOL><DEDENT>elif next_or_previous.lower() == '<STR_LIT>':<EOL><INDENT>rising = obs.previous_rising<EOL>setting = obs.previous_setting<EOL>transit = obs.previous_transit<EOL><DEDENT>else:<EOL><INDENT>raise ValueError("<STR_LIT>" +<EOL>"<STR_LIT>")<EOL><DEDENT>sunrise = []<EOL>sunset = []<EOL>trans = []<EOL>for thetime in times:<EOL><INDENT>thetime = thetime.to_pydatetime()<EOL>obs.date = ephem.Date(thetime - thetime.utcoffset())<EOL>sunrise.append(_ephem_to_timezone(rising(sun), tzinfo))<EOL>sunset.append(_ephem_to_timezone(setting(sun), tzinfo))<EOL>trans.append(_ephem_to_timezone(transit(sun), tzinfo))<EOL><DEDENT>return pd.DataFrame(index=times, data={'<STR_LIT>': sunrise,<EOL>'<STR_LIT>': sunset,<EOL>'<STR_LIT>': trans})<EOL>
Calculate the next sunrise and sunset times using the PyEphem package.

Parameters
----------
time : pandas.DatetimeIndex
    Must be localized
latitude : float
    Latitude in degrees, positive north of equator, negative to south
longitude : float
    Longitude in degrees, positive east of prime meridian, negative to west
next_or_previous : str
    'next' or 'previous' sunrise and sunset relative to time
altitude : float, default 0
    distance above sea level in meters.
pressure : int or float, optional, default 101325
    air pressure in Pascals.
temperature : int or float, optional, default 12
    air temperature in degrees C.
horizon : string, format +/-X:YY
    arc degrees:arc minutes from geometrical horizon for sunrise and
    sunset, e.g., horizon='+0:00' to use sun center crossing the
    geometrical horizon to define sunrise and sunset,
    horizon='-0:34' for when the sun's upper edge crosses the
    geometrical horizon

Returns
-------
pandas.DataFrame
    index is the same as input `time` argument
    columns are 'sunrise', 'sunset', and 'transit'

See also
--------
pyephem