CHECK_IRRAD_QCRAD

This function checks the consistency of GHI, DHI, and DNI using the QCRad criteria.

The algorithm validates that the measured GHI is consistent with the calculated component sum (DNI * cos(zenith) + DHI) and verifies that the ratio of DHI to GHI falls within reasonable bounds. The output is a 2D array with two columns for each point: the first representing component consistency, the second representing diffuse ratio limits.

Excel Usage

=CHECK_IRRAD_QCRAD(solar_zenith, ghi, dhi, dni, outside_domain)
  • solar_zenith (list[list], required): Solar zenith angle (degrees).
  • ghi (list[list], required): Global horizontal irradiance (W/m^2).
  • dhi (list[list], required): Diffuse horizontal irradiance (W/m^2).
  • dni (list[list], required): Direct normal irradiance (W/m^2).
  • outside_domain (bool, optional, default: false): Value to return when tests are not applicable (e.g. night time).

Returns (list[list]): 2D list [[components_consistent, diffuse_ratio_pass]], or an error string.

Example 1: Check irradiance component consistency

Inputs:

solar_zenith ghi dhi dni outside_domain
30 1000 100 1039.23 false
30 0 0 0
90 1000 10 900

Excel formula:

=CHECK_IRRAD_QCRAD({30;30;90}, {1000;0;1000}, {100;0;10}, {1039.23;0;900}, FALSE)

Expected output:

Result
true true
false false
false true
Example 2: Use outside domain flag for non-applicable points

Inputs:

solar_zenith ghi dhi dni outside_domain
95 0 0 0 true
92 5 3 5
89 20 10 50

Excel formula:

=CHECK_IRRAD_QCRAD({95;92;89}, {0;5;20}, {0;3;10}, {0;5;50}, TRUE)

Expected output:

Result
true true
true true
true true
Example 3: Handle scalar irradiance consistency inputs

Inputs:

solar_zenith ghi dhi dni outside_domain
30 900 100 923.76 false

Excel formula:

=CHECK_IRRAD_QCRAD(30, 900, 100, 923.76, FALSE)

Expected output:

Result
true true
Example 4: Process row-vector irradiance consistency input

Inputs:

solar_zenith ghi dhi dni outside_domain
20 40 60 900 700 400 120 150 180 830 720 440 false

Excel formula:

=CHECK_IRRAD_QCRAD({20,40,60}, {900,700,400}, {120,150,180}, {830,720,440}, FALSE)

Expected output:

Result
true true
true true
true true

Python Code

Show Code
import pandas as pd
from pvanalytics.quality.irradiance import check_irradiance_consistency_qcrad as result_func

def check_irrad_qcrad(solar_zenith, ghi, dhi, dni, outside_domain=False):
    """
    Return consistency flags for irradiance-component balance from GHI, DNI, DHI, and zenith ranges.

    See: https://pvanalytics.readthedocs.io/en/stable/generated/pvanalytics.quality.irradiance.check_irradiance_consistency_qcrad.html

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

    Args:
        solar_zenith (list[list]): Solar zenith angle (degrees).
        ghi (list[list]): Global horizontal irradiance (W/m^2).
        dhi (list[list]): Diffuse horizontal irradiance (W/m^2).
        dni (list[list]): Direct normal irradiance (W/m^2).
        outside_domain (bool, optional): Value to return when tests are not applicable (e.g. night time). Default is False.

    Returns:
        list[list]: 2D list [[components_consistent, diffuse_ratio_pass]], or an error string.
    """
    try:
        def flatten(data):
            if not isinstance(data, list):
                return [float(data)]
            flat = []
            for row in data:
                if isinstance(row, list):
                    for val in row:
                        if val != "":
                            flat.append(float(val))
                elif row != "":
                    flat.append(float(row))
            return flat

        zenith_s = pd.Series(flatten(solar_zenith))
        ghi_s = pd.Series(flatten(ghi))
        dhi_s = pd.Series(flatten(dhi))
        dni_s = pd.Series(flatten(dni))

        n = len(zenith_s)
        if not (len(ghi_s) == n and len(dhi_s) == n and len(dni_s) == n):
            return "Error: All input arrays must have the same length"
        if n == 0:
            return "Error: Arrays cannot be empty"

        out_dom = bool(outside_domain) if outside_domain is not None else False

        comp, ratio = result_func(zenith_s, ghi_s, dhi_s, dni_s, outside_domain=out_dom)

        result = []
        for c, r in zip(comp, ratio):
            result.append([bool(c), bool(r)])
        return result
    except Exception as e:
        return f"Error: {str(e)}"

Online Calculator

Solar zenith angle (degrees).
Global horizontal irradiance (W/m^2).
Diffuse horizontal irradiance (W/m^2).
Direct normal irradiance (W/m^2).
Value to return when tests are not applicable (e.g. night time).