-
Notifications
You must be signed in to change notification settings - Fork 31
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
Add out_of_bounds parameter to irradiance QC tests #214
base: main
Are you sure you want to change the base?
Changes from all commits
b86dfb7
23a3365
6e53fda
ca2b8c0
e59606f
00011d0
9f7067c
00d94f3
62de0ed
2bd8097
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 | ||||
---|---|---|---|---|---|---|
|
@@ -269,21 +269,24 @@ def _get_bounds(bounds): | |||||
|
||||||
|
||||||
def _check_irrad_ratio(ratio, ghi, sza, bounds): | ||||||
# unpack bounds dict | ||||||
# unpack bounds | ||||||
ghi_lb, ghi_ub, sza_lb, sza_ub, ratio_lb, ratio_ub = _get_bounds(bounds) | ||||||
# for zenith set inclusive_lower to handle edge cases, e.g., zenith=0 | ||||||
return ( | ||||||
|
||||||
within_domain = ( | ||||||
quality.util.check_limits( | ||||||
sza, lower_bound=sza_lb, upper_bound=sza_ub, inclusive_lower=True) | ||||||
& quality.util.check_limits( | ||||||
ghi, lower_bound=ghi_lb, upper_bound=ghi_ub) | ||||||
& quality.util.check_limits( | ||||||
ratio, lower_bound=ratio_lb, upper_bound=ratio_ub) | ||||||
ghi, lower_bound=ghi_lb, upper_bound=ghi_ub, inclusive_lower=True) | ||||||
) | ||||||
|
||||||
flag = within_domain & quality.util.check_limits( | ||||||
ratio, lower_bound=ratio_lb, upper_bound=ratio_ub) | ||||||
|
||||||
return flag, within_domain | ||||||
|
||||||
|
||||||
def check_irradiance_consistency_qcrad(solar_zenith, ghi, dhi, dni, | ||||||
param=None): | ||||||
param=None, outside_domain=False): | ||||||
"""Check consistency of GHI, DHI and DNI using QCRad criteria. | ||||||
|
||||||
Uses criteria given in [1]_ to validate the ratio of irradiance | ||||||
|
@@ -309,6 +312,9 @@ def check_irradiance_consistency_qcrad(solar_zenith, ghi, dhi, dni, | |||||
value is a dict with keys 'zenith_bounds', 'ghi_bounds', and | ||||||
'ratio_bounds' and value is an ordered pair [lower, upper] | ||||||
of float. | ||||||
outside_domain : default False | ||||||
Value to return when the tests are not applicable, i.e., when the | ||||||
inputs fall outside the test domain. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think @kandersolar was against listing the specifics. I somewhat agree, as "irradiance values outside the test domain" might be confused as to above/below the threshold. Not a strong feeling though. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK. I'm OK with "data" instead of "inputs". |
||||||
|
||||||
Returns | ||||||
------- | ||||||
|
@@ -319,6 +325,15 @@ def check_irradiance_consistency_qcrad(solar_zenith, ghi, dhi, dni, | |||||
|
||||||
Notes | ||||||
----- | ||||||
The QCRad algorithm checks that the input GHI is consistent with the | ||||||
component sum :math:`DNI \times \cos \( zenith \) + DHI` of input DNI and | ||||||
DHI, and that the ratio :math:`\frac{DHI}{GHI}` is reasonable. | ||||||
|
||||||
In these two parts, the ``ghi_bounds`` are applied differently. In the | ||||||
components test, the bounds are applied to the component sum of diffuse and | ||||||
direct irradiance, whereas in the diffuse ratio test the bounds are applied | ||||||
to the measured ``ghi``. | ||||||
|
||||||
Copyright (c) 2019 SolarArbiter. See the file | ||||||
LICENSES/SOLARFORECASTARBITER_LICENSE at the top level directory | ||||||
of this distribution and at `<https://github.com/pvlib/ | ||||||
|
@@ -341,18 +356,30 @@ def check_irradiance_consistency_qcrad(solar_zenith, ghi, dhi, dni, | |||||
dhi_ratio = dhi / ghi | ||||||
|
||||||
bounds = param['ghi_ratio'] | ||||||
consistent_components = ( | ||||||
_check_irrad_ratio(ratio=ghi_ratio, ghi=component_sum, | ||||||
sza=solar_zenith, bounds=bounds['high_zenith']) | ||||||
| _check_irrad_ratio(ratio=ghi_ratio, ghi=component_sum, | ||||||
sza=solar_zenith, bounds=bounds['low_zenith'])) | ||||||
flag_lz, within_domain_lz = _check_irrad_ratio( | ||||||
ratio=ghi_ratio, ghi=component_sum, sza=solar_zenith, | ||||||
bounds=bounds['low_zenith']) | ||||||
flag_hz, within_domain_hz = _check_irrad_ratio( | ||||||
ratio=ghi_ratio, ghi=component_sum, sza=solar_zenith, | ||||||
bounds=bounds['high_zenith']) | ||||||
|
||||||
consistent_components = ((flag_lz & within_domain_lz) | | ||||||
(flag_hz & within_domain_hz)) | ||||||
consistent_components[~(within_domain_lz | within_domain_hz)] = \ | ||||||
outside_domain | ||||||
|
||||||
bounds = param['dhi_ratio'] | ||||||
diffuse_ratio_limit = ( | ||||||
_check_irrad_ratio(ratio=dhi_ratio, ghi=ghi, sza=solar_zenith, | ||||||
bounds=bounds['high_zenith']) | ||||||
| _check_irrad_ratio(ratio=dhi_ratio, ghi=ghi, sza=solar_zenith, | ||||||
bounds=bounds['low_zenith'])) | ||||||
flag_lz, within_domain_lz = _check_irrad_ratio( | ||||||
ratio=dhi_ratio, ghi=ghi, sza=solar_zenith, | ||||||
bounds=bounds['low_zenith']) | ||||||
flag_hz, within_domain_hz = _check_irrad_ratio( | ||||||
ratio=dhi_ratio, ghi=ghi, sza=solar_zenith, | ||||||
bounds=bounds['high_zenith']) | ||||||
within_domain_hz = within_domain_lz | within_domain_hz | ||||||
diffuse_ratio_limit = ((flag_lz & within_domain_lz) | | ||||||
(flag_hz & within_domain_hz)) | ||||||
diffuse_ratio_limit[~(within_domain_lz | within_domain_hz)] = \ | ||||||
outside_domain | ||||||
|
||||||
return consistent_components, diffuse_ratio_limit | ||||||
|
||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add "r" to the line below so that the math equations render.