DIRINT
This function implements the modified DISC model known as “DIRINT” to predict DNI from measured Global Horizontal Irradiance (GHI).
DIRINT calculates DNI using time-series GHI data and solar zenith angles. It can optionally incorporate dew point temperature for improved accuracy. The stability index is utilized by default to adjust DNI in response to dynamics in the time series.
Excel Usage
=DIRINT(ghi, solar_zenith, times, pressure, use_delta_kt_prime, temp_dew, min_cos_zenith, max_zenith)
ghi(list[list], required): Global horizontal irradiance (W/m^2).solar_zenith(list[list], required): Solar zenith angles (degrees).times(list[list], required): Timestamps corresponding to the observations in ISO8601 format.pressure(float, optional, default: 101325): Site air pressure (Pa).use_delta_kt_prime(bool, optional, default: true): Include stability index delta_kt_prime in the model.temp_dew(list[list], optional, default: null): Optional dew point temperature time series (°C) aligned to ghi observations.min_cos_zenith(float, optional, default: 0.065): Minimum value of cos(zenith) when calculating clearness index.max_zenith(float, optional, default: 87): Maximum value of zenith to allow in DNI calculation (degrees).
Returns (list[list]): 2D list of estimated DNI values (W/m^2), or an error string.
Example 1: Calculate DNI from GHI with default parameters
Inputs:
| ghi | solar_zenith | times | pressure | use_delta_kt_prime |
|---|---|---|---|---|
| 800 | 40 | 2024-01-01T12:00:00Z | 101325 | true |
| 800 | 40 | 2024-01-01T13:00:00Z | ||
| 800 | 40 | 2024-01-01T14:00:00Z | ||
| 800 | 40 | 2024-01-01T15:00:00Z |
Excel formula:
=DIRINT({800;800;800;800}, {40;40;40;40}, {"2024-01-01T12:00:00Z";"2024-01-01T13:00:00Z";"2024-01-01T14:00:00Z";"2024-01-01T15:00:00Z"}, 101325, TRUE)
Expected output:
| Result |
|---|
| 857.709 |
| 857.709 |
| 857.709 |
| 857.709 |
Example 2: DIRINT using dew point corrections
Inputs:
| ghi | solar_zenith | times | temp_dew | pressure | use_delta_kt_prime |
|---|---|---|---|---|---|
| 500 | 65 | 2024-06-21T08:00:00Z | 12 | 100500 | true |
| 700 | 45 | 2024-06-21T10:00:00Z | 14 | ||
| 850 | 25 | 2024-06-21T12:00:00Z | 16 | ||
| 600 | 50 | 2024-06-21T14:00:00Z | 15 |
Excel formula:
=DIRINT({500;700;850;600}, {65;45;25;50}, {"2024-06-21T08:00:00Z";"2024-06-21T10:00:00Z";"2024-06-21T12:00:00Z";"2024-06-21T14:00:00Z"}, {12;14;16;15}, 100500, TRUE)
Expected output:
| Result |
|---|
| 534.527 |
| 776.165 |
| 578.504 |
| 750.125 |
Example 3: DIRINT without stability index adjustment
Inputs:
| ghi | solar_zenith | times | use_delta_kt_prime | min_cos_zenith |
|---|---|---|---|---|
| 300 | 70 | 2024-09-22T07:00:00Z | false | 0.08 |
| 550 | 55 | 2024-09-22T09:00:00Z | ||
| 780 | 35 | 2024-09-22T11:00:00Z | ||
| 520 | 60 | 2024-09-22T13:00:00Z |
Excel formula:
=DIRINT({300;550;780;520}, {70;55;35;60}, {"2024-09-22T07:00:00Z";"2024-09-22T09:00:00Z";"2024-09-22T11:00:00Z";"2024-09-22T13:00:00Z"}, FALSE, 0.08)
Expected output:
| Result |
|---|
| 702.838 |
| 780.042 |
| 653.316 |
| 889.943 |
Example 4: DIRINT with tighter zenith cutoff
Inputs:
| ghi | solar_zenith | times | max_zenith | pressure |
|---|---|---|---|---|
| 200 | 80 | 2024-03-21T06:30:00Z | 80 | 95000 |
| 450 | 68 | 2024-03-21T08:30:00Z | ||
| 650 | 52 | 2024-03-21T10:30:00Z | ||
| 400 | 78 | 2024-03-21T16:30:00Z |
Excel formula:
=DIRINT({200;450;650;400}, {80;68;52;78}, {"2024-03-21T06:30:00Z";"2024-03-21T08:30:00Z";"2024-03-21T10:30:00Z";"2024-03-21T16:30:00Z"}, 80, 95000)
Expected output:
| Result |
|---|
| 630.356 |
| 745.445 |
| 761.993 |
| 420.681 |
Python Code
Show Code
import pandas as pd
import numpy as np
from pvlib.irradiance import dirint as result_func
def dirint(ghi, solar_zenith, times, pressure=101325, use_delta_kt_prime=True, temp_dew=None, min_cos_zenith=0.065, max_zenith=87):
"""
Estimate Direct Normal Irradiance (DNI) from GHI using the DIRINT model.
See: https://pvlib-python.readthedocs.io/en/stable/reference/generated/pvlib.irradiance.dirint.html
This example function is provided as-is without any representation of accuracy.
Args:
ghi (list[list]): Global horizontal irradiance (W/m^2).
solar_zenith (list[list]): Solar zenith angles (degrees).
times (list[list]): Timestamps corresponding to the observations in ISO8601 format.
pressure (float, optional): Site air pressure (Pa). Default is 101325.
use_delta_kt_prime (bool, optional): Include stability index delta_kt_prime in the model. Default is True.
temp_dew (list[list], optional): Optional dew point temperature time series (°C) aligned to ghi observations. Default is None.
min_cos_zenith (float, optional): Minimum value of cos(zenith) when calculating clearness index. Default is 0.065.
max_zenith (float, optional): Maximum value of zenith to allow in DNI calculation (degrees). Default is 87.
Returns:
list[list]: 2D list of estimated DNI values (W/m^2), 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
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 != ""]
ghi_list = flatten_num(ghi)
zen_list = flatten_num(solar_zenith)
time_list = flatten_str(times)
temp_dew_list = None
if temp_dew is not None and temp_dew != "":
td = flatten_num(temp_dew)
if len(td) != len(ghi_list):
return "Error: temp_dew must match the length of ghi"
temp_dew_list = pd.Series(td, index=pd.DatetimeIndex(time_list))
n = len(ghi_list)
if n == 0 or len(zen_list) != n or len(time_list) != n:
return "Error: All input arrays must have the same non-zero length"
idx = pd.DatetimeIndex(time_list)
ghi_s = pd.Series(ghi_list, index=idx)
zen_s = pd.Series(zen_list, index=idx)
p = float(pressure) if pressure is not None else 101325.0
use_kt = bool(use_delta_kt_prime) if use_delta_kt_prime is not None else True
min_cz = float(min_cos_zenith) if min_cos_zenith is not None else 0.065
max_z = float(max_zenith) if max_zenith is not None else 87.0
# dirint requires pandas Series if use_delta_kt_prime is True
dni = result_func(ghi_s, zen_s, idx, pressure=p, use_delta_kt_prime=use_kt, temp_dew=temp_dew_list, min_cos_zenith=min_cz, max_zenith=max_z)
return [[float(v) if not pd.isna(v) else ""] for v in dni]
except Exception as e:
return f"Error: {str(e)}"Online Calculator
Global horizontal irradiance (W/m^2).
Solar zenith angles (degrees).
Timestamps corresponding to the observations in ISO8601 format.
Site air pressure (Pa).
Include stability index delta_kt_prime in the model.
Optional dew point temperature time series (°C) aligned to ghi observations.
Minimum value of cos(zenith) when calculating clearness index.
Maximum value of zenith to allow in DNI calculation (degrees).