CHECK_GHI_QCRAD
This function tests for lower and upper limits on Global Horizontal Irradiance (GHI) using the QCRad criteria.
The test is applied to each GHI value. A reading passes if it is strictly greater than the lower bound and less than the upper bound. The bounds can be either ‘physical’ or ‘extreme’ criteria.
Excel Usage
=CHECK_GHI_QCRAD(ghi, solar_zenith, dni_extra, limits)
ghi(list[list], required): Global horizontal irradiance (W/m^2).solar_zenith(list[list], required): Solar zenith angle (degrees).dni_extra(list[list], required): Extraterrestrial normal irradiance (W/m^2).limits(str, optional, default: “physical”): QCRAD QC limits.
Returns (list[list]): 2D list of booleans (True if passed limits), or an error string.
Example 1: Check GHI physical limits pass and fail cases
Inputs:
| ghi | solar_zenith | dni_extra | limits |
|---|---|---|---|
| 1000 | 30 | 1367 | physical |
| -10 | 30 | 1367 | |
| 1500 | 90 | 1367 |
Excel formula:
=CHECK_GHI_QCRAD({1000;-10;1500}, {30;30;90}, {1367;1367;1367}, "physical")
Expected output:
| Result |
|---|
| true |
| false |
| false |
Example 2: Evaluate GHI values with extreme limits setting
Inputs:
| ghi | solar_zenith | dni_extra | limits |
|---|---|---|---|
| 200 | 10 | 1367 | extreme |
| 800 | 35 | 1367 | |
| 1300 | 70 | 1367 |
Excel formula:
=CHECK_GHI_QCRAD({200;800;1300}, {10;35;70}, {1367;1367;1367}, "extreme")
Expected output:
| Result |
|---|
| true |
| true |
| false |
Example 3: Handle scalar GHI inputs as single observations
Inputs:
| ghi | solar_zenith | dni_extra | limits |
|---|---|---|---|
| 600 | 40 | 1367 | physical |
Excel formula:
=CHECK_GHI_QCRAD(600, 40, 1367, "physical")
Expected output:
true
Example 4: Process a row vector of GHI observations
Inputs:
| ghi | solar_zenith | dni_extra | limits | ||||||
|---|---|---|---|---|---|---|---|---|---|
| 150 | 450 | 900 | 15 | 25 | 45 | 1367 | 1367 | 1367 | physical |
Excel formula:
=CHECK_GHI_QCRAD({150,450,900}, {15,25,45}, {1367,1367,1367}, "physical")
Expected output:
| Result |
|---|
| true |
| true |
| true |
Python Code
Show Code
import pandas as pd
from pvanalytics.quality.irradiance import check_ghi_limits_qcrad as result_func
def check_ghi_qcrad(ghi, solar_zenith, dni_extra, limits='physical'):
"""
Return a pass/fail QC flag array for each GHI reading against QCRad physical or extreme limits.
See: https://pvanalytics.readthedocs.io/en/stable/generated/pvanalytics.quality.irradiance.check_ghi_limits_qcrad.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 angle (degrees).
dni_extra (list[list]): Extraterrestrial normal irradiance (W/m^2).
limits (str, optional): QCRAD QC limits. Valid options: Physical, Extreme. Default is 'physical'.
Returns:
list[list]: 2D list of booleans (True if passed limits), 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
ghi_s = pd.Series(flatten(ghi))
zenith_s = pd.Series(flatten(solar_zenith))
dni_extra_s = pd.Series(flatten(dni_extra))
n = len(ghi_s)
if not (len(zenith_s) == n and len(dni_extra_s) == n):
return "Error: All input arrays must have the same length"
if n == 0:
return "Error: Arrays cannot be empty"
lim = str(limits) if limits is not None else "physical"
if lim not in ["physical", "extreme"]:
return "Error: limits must be either 'physical' or 'extreme'"
res = result_func(ghi_s, zenith_s, dni_extra_s, limits=lim)
return [[bool(v)] for v in res]
except Exception as e:
return f"Error: {str(e)}"Online Calculator
Global horizontal irradiance (W/m^2).
Solar zenith angle (degrees).
Extraterrestrial normal irradiance (W/m^2).
QCRAD QC limits.