GET_EXTRA_RADIATION

This function computes extraterrestrial radiation normal to the sun using standard algorithms.

The model returns the estimated global solar constant modulated by earth-sun distance. Users can provide a specific ISO8601 timestamp string and choose the desired estimation method.

Excel Usage

=GET_EXTRA_RADIATION(times, solar_constant, radiation_method, epoch_year)
  • times (list[list], required): Timestamps representing days of the year (ISO8601 format).
  • solar_constant (float, optional, default: 1366.1): The solar constant (W/m^2).
  • radiation_method (str, optional, default: “spencer”): The method by which extraterrestrial radiation should be calculated.
  • epoch_year (int, optional, default: 2014): The reference year. Only applies to DOY input used with numpy/nrel methods.

Returns (list[list]): 2D list of estimated DNI extra values (W/m^2), or an error string.

Example 1: Extraterrestrial radiation at the solstice

Inputs:

times solar_constant radiation_method epoch_year
2024-06-21T12:00:00Z 1366.1 spencer 2014

Excel formula:

=GET_EXTRA_RADIATION({"2024-06-21T12:00:00Z"}, 1366.1, "spencer", 2014)

Expected output:

1321.46

Example 2: Extraterrestrial radiation using the ASCE method

Inputs:

times radiation_method solar_constant
2024-03-20T12:00:00Z asce 1366.1

Excel formula:

=GET_EXTRA_RADIATION({"2024-03-20T12:00:00Z"}, "asce", 1366.1)

Expected output:

1374.78

Example 3: Extraterrestrial radiation using the NREL method

Inputs:

times radiation_method epoch_year
2024-12-21T12:00:00Z nrel 2024

Excel formula:

=GET_EXTRA_RADIATION({"2024-12-21T12:00:00Z"}, "nrel", 2024)

Expected output:

1411.68

Example 4: Extraterrestrial radiation over three representative dates

Inputs:

times radiation_method
2024-01-15T12:00:00Z spencer
2024-06-21T12:00:00Z
2024-09-22T12:00:00Z

Excel formula:

=GET_EXTRA_RADIATION({"2024-01-15T12:00:00Z";"2024-06-21T12:00:00Z";"2024-09-22T12:00:00Z"}, "spencer")

Expected output:

Result
1412.98
1321.46
1356.6

Python Code

Show Code
import pandas as pd
from pvlib.irradiance import get_extra_radiation as result_func

def get_extra_radiation(times, solar_constant=1366.1, radiation_method='spencer', epoch_year=2014):
    """
    Determine extraterrestrial radiation (DNI_extra) for a given day of the year.

    See: https://pvlib-python.readthedocs.io/en/stable/reference/generated/pvlib.irradiance.get_extra_radiation.html

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

    Args:
        times (list[list]): Timestamps representing days of the year (ISO8601 format).
        solar_constant (float, optional): The solar constant (W/m^2). Default is 1366.1.
        radiation_method (str, optional): The method by which extraterrestrial radiation should be calculated. Valid options: Spencer, ASCE, NREL. Default is 'spencer'.
        epoch_year (int, optional): The reference year. Only applies to DOY input used with numpy/nrel methods. Default is 2014.

    Returns:
        list[list]: 2D list of estimated DNI extra values (W/m^2), or an error string.
    """
    try:
        def flatten_str(data):
            if not isinstance(data, list): return [str(data)]
            return [str(val) for row in data for val in (row if isinstance(row, list) else [row]) if val != ""]

        time_list = flatten_str(times)

        if len(time_list) == 0:
            return "Error: input array cannot be empty"

        idx = pd.DatetimeIndex(time_list)

        sc = float(solar_constant) if solar_constant is not None else 1366.1
        meth = str(radiation_method) if radiation_method is not None else "spencer"
        ey = int(epoch_year) if epoch_year is not None else 2014

        if meth not in ["spencer", "asce", "nrel"]:
            return "Error: Invalid method selection"

        res = result_func(idx, solar_constant=sc, method=meth, epoch_year=ey)

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

Online Calculator

Timestamps representing days of the year (ISO8601 format).
The solar constant (W/m^2).
The method by which extraterrestrial radiation should be calculated.
The reference year. Only applies to DOY input used with numpy/nrel methods.