EOT_SPENCER

This function computes the equation of time (EOT), which quantifies the offset between apparent solar time and mean solar time as a function of day of year.

EOT is a key correction used to map civil clock time into solar geometry calculations.

Solar time can be expressed as:

t_{solar} = t_{clock} + \frac{4(\lambda_{std}-\lambda)}{60} + \frac{\mathrm{EOT}}{60}

where longitudes are in degrees and EOT is in minutes.

Excel Usage

=EOT_SPENCER(dayofyear)
  • dayofyear (list[list], required): Day of the year (1 to 366).

Returns (list[list]): 2D list of equation of time offsets (minutes), or an error string.

Example 1: EOT at summer solstice

Inputs:

dayofyear
172

Excel formula:

=EOT_SPENCER({172})

Expected output:

-1.34372

Example 2: EOT near March equinox

Inputs:

dayofyear
80

Excel formula:

=EOT_SPENCER({80})

Expected output:

-7.87367

Example 3: EOT near December solstice

Inputs:

dayofyear
355

Excel formula:

=EOT_SPENCER({355})

Expected output:

2.15509

Example 4: Scalar day-of-year input

Inputs:

dayofyear
1

Excel formula:

=EOT_SPENCER(1)

Expected output:

-2.91968

Python Code

Show Code
import pandas as pd
import numpy as np
from pvlib.solarposition import equation_of_time_spencer71 as result_func

def eot_spencer(dayofyear):
    """
    Compute the equation of time (EOT) using Spencer's (1971) formula.

    See: https://pvlib-python.readthedocs.io/en/stable/reference/generated/pvlib.solarposition.equation_of_time_spencer71.html

    This example function is provided as-is without any representation of accuracy.

    Args:
        dayofyear (list[list]): Day of the year (1 to 366).

    Returns:
        list[list]: 2D list of equation of time offsets (minutes), or an error string.
    """
    try:
        def flatten_num(data):
            if not isinstance(data, list): return [float(data)]
            flat = []
            for row in data:
                row = row if isinstance(row, list) else [row]
                for val in row:
                    if val == "": flat.append(float('nan'))
                    else: flat.append(float(val))
            return flat

        doy_list = flatten_num(dayofyear)
        if len(doy_list) == 0:
            return "Error: input array cannot be empty"

        res = result_func(np.array(doy_list))

        return [[float(v) if not pd.isna(v) else ""] for v in res]
    except Exception as e:
        return f"Error: {str(e)}"

Online Calculator

Day of the year (1 to 366).