-
Notifications
You must be signed in to change notification settings - Fork 38
Add extreme QCRAD QC limits #190
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 9 commits
359a8dc
a290f04
030d132
a72fea2
ff454e0
01bf6c7
b7702e8
2639ebc
26e4312
93cea93
6a47939
8eef26e
5b8391b
8a20782
b995829
48c0e15
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,10 +10,18 @@ | |
from pvanalytics import util | ||
|
||
|
||
QCRAD_LIMITS = {'ghi_ub': {'mult': 1.5, 'exp': 1.2, 'min': 100}, | ||
'dhi_ub': {'mult': 0.95, 'exp': 1.2, 'min': 50}, | ||
'dni_ub': {'mult': 1.0, 'exp': 0.0, 'min': 0}, | ||
'ghi_lb': -4, 'dhi_lb': -4, 'dni_lb': -4} | ||
# QCRAD limits are often also referred to as BSRN limits | ||
QCRAD_LIMITS_PHYSICAL = { # Physically Possible Limits | ||
'ghi_ub': {'mult': 1.5, 'exp': 1.2, 'min': 100}, | ||
'dhi_ub': {'mult': 0.95, 'exp': 1.2, 'min': 50}, | ||
'dni_ub': {'mult': 1.0, 'exp': 0.0, 'min': 0}, | ||
'ghi_lb': -4, 'dhi_lb': -4, 'dni_lb': -4} | ||
|
||
QCRAD_LIMITS_EXTREME = { # Extremely Rare Limis | ||
AdamRJensen marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
'ghi_ub': {'mult': 1.2, 'exp': 1.2, 'min': 50}, | ||
'dhi_ub': {'mult': 0.75, 'exp': 1.2, 'min': 30}, | ||
'dni_ub': {'mult': 0.95, 'exp': 0.2, 'min': 10}, | ||
'ghi_lb': -2, 'dhi_lb': -2, 'dni_lb': -2} | ||
|
||
QCRAD_CONSISTENCY = { | ||
'ghi_ratio': { | ||
|
@@ -42,8 +50,8 @@ def _qcrad_ub(dni_extra, sza, lim): | |
return lim['mult'] * dni_extra * cosd_sza**lim['exp'] + lim['min'] | ||
|
||
|
||
def check_ghi_limits_qcrad(ghi, solar_zenith, dni_extra, limits=None): | ||
r"""Test for physical limits on GHI using the QCRad criteria. | ||
def check_ghi_limits_qcrad(ghi, solar_zenith, dni_extra, limits='physical'): | ||
r"""Test for lower and upper limits on GHI using the QCRad criteria. | ||
|
||
Test is applied to each GHI value. A GHI value passes if value > | ||
lower bound and value < upper bound. Lower bounds are constant for | ||
|
@@ -60,10 +68,11 @@ def check_ghi_limits_qcrad(ghi, solar_zenith, dni_extra, limits=None): | |
Solar zenith angle in degrees | ||
dni_extra : Series | ||
Extraterrestrial normal irradiance in :math:`W/m^2` | ||
limits : dict, default QCRAD_LIMITS | ||
Must have keys 'ghi_ub' and 'ghi_lb'. For 'ghi_ub' value is a | ||
dict with keys {'mult', 'exp', 'min'} and float values. For | ||
'ghi_lb' value is a float. | ||
limits : {'physical', 'extreme'} or dict, default 'physical' | ||
If string, must be either 'physical' or 'extreme', corresponding to the | ||
QCRAD QC limits. If dict, must have keys 'ghi_ub' and 'ghi_lb'. For | ||
'ghi_ub' value is a dict with keys {'mult', 'exp', 'min'} and float | ||
values. For 'ghi_lb' value is a float. | ||
|
||
Returns | ||
------- | ||
|
@@ -79,17 +88,20 @@ def check_ghi_limits_qcrad(ghi, solar_zenith, dni_extra, limits=None): | |
for more information. | ||
|
||
""" | ||
if not limits: | ||
limits = QCRAD_LIMITS | ||
if limits == 'physical': | ||
limits = QCRAD_LIMITS_PHYSICAL | ||
elif limits == 'extreme': | ||
limits = QCRAD_LIMITS_EXTREME | ||
cwhanse marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
ghi_ub = _qcrad_ub(dni_extra, solar_zenith, limits['ghi_ub']) | ||
|
||
ghi_limit_flag = quality.util.check_limits(ghi, limits['ghi_lb'], ghi_ub) | ||
|
||
return ghi_limit_flag | ||
|
||
|
||
def check_dhi_limits_qcrad(dhi, solar_zenith, dni_extra, limits=None): | ||
r"""Test for physical limits on DHI using the QCRad criteria. | ||
def check_dhi_limits_qcrad(dhi, solar_zenith, dni_extra, limits='physical'): | ||
r"""Test for lower and upper limits on DHI using the QCRad criteria. | ||
|
||
Test is applied to each DHI value. A DHI value passes if value > | ||
lower bound and value < upper bound. Lower bounds are constant for | ||
|
@@ -106,10 +118,11 @@ def check_dhi_limits_qcrad(dhi, solar_zenith, dni_extra, limits=None): | |
Solar zenith angle in degrees | ||
dni_extra : Series | ||
Extraterrestrial normal irradiance in :math:`W/m^2` | ||
limits : dict, default QCRAD_LIMITS | ||
Must have keys 'dhi_ub' and 'dhi_lb'. For 'dhi_ub' value is a | ||
dict with keys {'mult', 'exp', 'min'} and float values. For | ||
'dhi_lb' value is a float. | ||
limits : {'physical', 'extreme'} or dict, default 'physical' | ||
If string, must be either 'physical' or 'extreme', corresponding to the | ||
QCRAD QC limits. If dict, must have keys 'ghi_ub' and 'ghi_lb'. For | ||
'ghi_ub' value is a dict with keys {'mult', 'exp', 'min'} and float | ||
values. For 'ghi_lb' value is a float. | ||
AdamRJensen marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
Returns | ||
------- | ||
|
@@ -125,8 +138,10 @@ def check_dhi_limits_qcrad(dhi, solar_zenith, dni_extra, limits=None): | |
for more information. | ||
|
||
""" | ||
if not limits: | ||
limits = QCRAD_LIMITS | ||
if limits == 'physical': | ||
limits = QCRAD_LIMITS_PHYSICAL | ||
elif limits == 'extreme': | ||
limits = QCRAD_LIMITS_EXTREME | ||
AdamRJensen marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
dhi_ub = _qcrad_ub(dni_extra, solar_zenith, limits['dhi_ub']) | ||
|
||
|
@@ -135,8 +150,8 @@ def check_dhi_limits_qcrad(dhi, solar_zenith, dni_extra, limits=None): | |
return dhi_limit_flag | ||
|
||
|
||
def check_dni_limits_qcrad(dni, solar_zenith, dni_extra, limits=None): | ||
r"""Test for physical limits on DNI using the QCRad criteria. | ||
def check_dni_limits_qcrad(dni, solar_zenith, dni_extra, limits='physical'): | ||
r"""Test for lower and upper limits on DNI using the QCRad criteria. | ||
|
||
Test is applied to each DNI value. A DNI value passes if value > | ||
lower bound and value < upper bound. Lower bounds are constant for | ||
|
@@ -153,10 +168,11 @@ def check_dni_limits_qcrad(dni, solar_zenith, dni_extra, limits=None): | |
Solar zenith angle in degrees | ||
dni_extra : Series | ||
Extraterrestrial normal irradiance in :math:`W/m^2` | ||
limits : dict, default QCRAD_LIMITS | ||
Must have keys 'dni_ub' and 'dni_lb'. For 'dni_ub' value is a | ||
dict with keys {'mult', 'exp', 'min'} and float values. For | ||
'dni_lb' value is a float. | ||
limits : {'physical', 'extreme'} or dict, default 'physical' | ||
If string, must be either 'physical' or 'extreme', corresponding to the | ||
QCRAD QC limits. If dict, must have keys 'ghi_ub' and 'ghi_lb'. For | ||
'ghi_ub' value is a dict with keys {'mult', 'exp', 'min'} and float | ||
values. For 'ghi_lb' value is a float. | ||
AdamRJensen marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
Returns | ||
------- | ||
|
@@ -172,8 +188,10 @@ def check_dni_limits_qcrad(dni, solar_zenith, dni_extra, limits=None): | |
for more information. | ||
|
||
""" | ||
if not limits: | ||
limits = QCRAD_LIMITS | ||
if limits == 'physical': | ||
limits = QCRAD_LIMITS_PHYSICAL | ||
elif limits == 'extreme': | ||
limits = QCRAD_LIMITS_EXTREME | ||
|
||
dni_ub = _qcrad_ub(dni_extra, solar_zenith, limits['dni_ub']) | ||
|
||
|
@@ -183,10 +201,10 @@ def check_dni_limits_qcrad(dni, solar_zenith, dni_extra, limits=None): | |
|
||
|
||
def check_irradiance_limits_qcrad(solar_zenith, dni_extra, ghi=None, dhi=None, | ||
dni=None, limits=None): | ||
dni=None, limits='physical'): | ||
r"""Test for physical limits on GHI, DHI or DNI using the QCRad criteria. | ||
|
||
Criteria from [1]_ are used to determine physically plausible | ||
Criteria from [1]_ and [2]_ are used to determine physically plausible | ||
lower and upper bounds. Each value is tested and a value passes if | ||
value > lower bound and value < upper bound. Lower bounds are | ||
constant for all tests. Upper bounds are calculated as | ||
|
@@ -209,10 +227,11 @@ def check_irradiance_limits_qcrad(solar_zenith, dni_extra, ghi=None, dhi=None, | |
Diffuse horizontal irradiance in :math:`W/m^2` | ||
dni : Series or None, default None | ||
Direct normal irradiance in :math:`W/m^2` | ||
limits : dict, default QCRAD_LIMITS | ||
for keys 'ghi_ub', 'dhi_ub', 'dni_ub', value is a dict with | ||
keys {'mult', 'exp', 'min'} and float values. For keys | ||
'ghi_lb', 'dhi_lb', 'dni_lb', value is a float. | ||
limits : {'physical', 'extreme'} or dict, default 'physical' | ||
If string, must be either 'physical' or 'extreme', corresponding to the | ||
QCRAD QC limits. If dict, must have keys 'ghi_ub' and 'ghi_lb'. For | ||
'ghi_ub' value is a dict with keys {'mult', 'exp', 'min'} and float | ||
values. For 'ghi_lb' value is a float. | ||
AdamRJensen marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
||
Returns | ||
------- | ||
|
@@ -233,13 +252,19 @@ def check_irradiance_limits_qcrad(solar_zenith, dni_extra, ghi=None, dhi=None, | |
|
||
References | ||
---------- | ||
.. [1] C. N. Long and Y. Shi, An Automated Quality Assessment and Control | ||
Algorithm for Surface Radiation Measurements, The Open Atmospheric | ||
Science Journal 2, pp. 23-37, 2008. | ||
|
||
""" | ||
if not limits: | ||
limits = QCRAD_LIMITS | ||
.. [1] C. N. Long and Y. Shi, "An Automated Quality Assessment and Control | ||
Algorithm for Surface Radiation Measurements," The Open Atmospheric | ||
Science Journal, vol. 2, no. 1. Bentham Science Publishers Ltd., | ||
pp. 23–37, Apr. 18, 2008. :doi:`10.2174/1874282300802010023`. | ||
.. [2] C. N. Long and E. G. Dutton, "BSRN Global Network recommended QC | ||
tests, V2.0," Baseline Surface Radiation Network (BSRN), | ||
Accessed: Oct. 24, 2024. [Online.] Available: | ||
<https://bsrn.awi.de/fileadmin/user_upload/bsrn.awi.de/Publications/BSRN_recommended_QC_tests_V2.pdf>_ | ||
AdamRJensen marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
""" # noqa: E501 | ||
if limits == 'physical': | ||
limits = QCRAD_LIMITS_PHYSICAL | ||
elif limits == 'extreme': | ||
limits = QCRAD_LIMITS_EXTREME | ||
|
||
if ghi is not None: | ||
ghi_limit_flag = check_ghi_limits_qcrad(ghi, solar_zenith, dni_extra, | ||
|
@@ -289,7 +314,7 @@ def check_irradiance_consistency_qcrad(solar_zenith, ghi, dhi, dni, | |
param=None, outside_domain=False): | ||
r"""Check consistency of GHI, DHI and DNI using QCRad criteria. | ||
|
||
Uses criteria given in [1]_ to validate the ratio of irradiance | ||
Uses criteria given in [1]_, [2]_ to validate the ratio of irradiance | ||
|
||
components. | ||
|
||
.. warning:: Not valid for night time or low irradiance. When the input | ||
|
@@ -342,11 +367,15 @@ def check_irradiance_consistency_qcrad(solar_zenith, ghi, dhi, dni, | |
|
||
References | ||
---------- | ||
.. [1] C. N. Long and Y. Shi, An Automated Quality Assessment and Control | ||
Algorithm for Surface Radiation Measurements, The Open Atmospheric | ||
Science Journal 2, pp. 23-37, 2008. | ||
|
||
""" | ||
.. [1] C. N. Long and Y. Shi, "An Automated Quality Assessment and Control | ||
Algorithm for Surface Radiation Measurements," The Open Atmospheric | ||
Science Journal, vol. 2, no. 1. Bentham Science Publishers Ltd., | ||
pp. 23–37, Apr. 18, 2008. :doi:`10.2174/1874282300802010023`. | ||
.. [2] C. N. Long and E. G. Dutton, "BSRN Global Network recommended QC | ||
tests, V2.0," Baseline Surface Radiation Network (BSRN), | ||
Accessed: Oct. 24, 2024. [Online.] Available: | ||
<https://bsrn.awi.de/fileadmin/user_upload/bsrn.awi.de/Publications/BSRN_recommended_QC_tests_V2.pdf>_ | ||
""" # noqa: E501 | ||
if not param: | ||
param = QCRAD_CONSISTENCY | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.