def spa_python(time, latitude, longitude,<EOL>altitude=<NUM_LIT:0>, pressure=<NUM_LIT>, temperature=<NUM_LIT:12>, delta_t=<NUM_LIT>,<EOL>atmos_refract=None, how='<STR_LIT>', numthreads=<NUM_LIT:4>, **kwargs):
<EOL>lat = latitude<EOL>lon = longitude<EOL>elev = altitude<EOL>pressure = pressure / <NUM_LIT:100>  <EOL>atmos_refract = atmos_refract or <NUM_LIT><EOL>if not isinstance(time, pd.DatetimeIndex):<EOL><INDENT>try:<EOL><INDENT>time = pd.DatetimeIndex(time)<EOL><DEDENT>except (TypeError, ValueError):<EOL><INDENT>time = pd.DatetimeIndex([time, ])<EOL><DEDENT><DEDENT>unixtime = np.array(time.astype(np.int64)/<NUM_LIT:10>**<NUM_LIT:9>)<EOL>spa = _spa_python_import(how)<EOL>delta_t = delta_t or spa.calculate_deltat(time.year, time.month)<EOL>app_zenith, zenith, app_elevation, elevation, azimuth, eot =spa.solar_position(unixtime, lat, lon, elev, pressure, temperature,<EOL>delta_t, atmos_refract, numthreads)<EOL>result = pd.DataFrame({'<STR_LIT>': app_zenith, '<STR_LIT>': zenith,<EOL>'<STR_LIT>': app_elevation,<EOL>'<STR_LIT>': elevation, '<STR_LIT>': azimuth,<EOL>'<STR_LIT>': eot},<EOL>index=time)<EOL>return result<EOL>
Calculate the solar position using a python implementation of the
NREL SPA algorithm described in [1].

If numba is installed, the functions can be compiled to
machine code and the function can be multithreaded.
Without numba, the function evaluates via numpy with
a slight performance hit.

Parameters
----------
time : pandas.DatetimeIndex
    Localized or UTC.
latitude : float
longitude : float
altitude : float, default 0
pressure : int or float, optional, default 101325
    avg. yearly air pressure in Pascals.
temperature : int or float, optional, default 12
    avg. yearly air temperature in degrees C.
delta_t : float, optional, default 67.0
    If delta_t is None, uses spa.calculate_deltat
    using time.year and time.month from pandas.DatetimeIndex.
    For most simulations specifing delta_t is sufficient.
    Difference between terrestrial time and UT1.
    *Note: delta_t = None will break code using nrel_numba,
    this will be fixed in a future version.*
    The USNO has historical and forecasted delta_t [3].
atmos_refrac : None or float, optional, default None
    The approximate atmospheric refraction (in degrees)
    at sunrise and sunset.
how : str, optional, default 'numpy'
    Options are 'numpy' or 'numba'. If numba >= 0.17.0
    is installed, how='numba' will compile the spa functions
    to machine code and run them multithreaded.
numthreads : int, optional, default 4
    Number of threads to use if how == 'numba'.

Returns
-------
DataFrame
    The DataFrame will have the following columns:
    apparent_zenith (degrees),
    zenith (degrees),
    apparent_elevation (degrees),
    elevation (degrees),
    azimuth (degrees),
    equation_of_time (minutes).


References
----------
[1] I. Reda and A. Andreas, Solar position algorithm for solar
radiation applications. Solar Energy, vol. 76, no. 5, pp. 577-589, 2004.

[2] I. Reda and A. Andreas, Corrigendum to Solar position algorithm for
solar radiation applications. Solar Energy, vol. 81, no. 6, p. 838, 2007.

[3] USNO delta T:
http://www.usno.navy.mil/USNO/earth-orientation/eo-products/long-term

See also
--------
pyephem, spa_c, ephemeris