Beispiel #1
0
def test_detect_clearsky_ghi(ghi_clearsky):
    flags = validator.detect_clearsky_ghi(ghi_clearsky, ghi_clearsky)
    # first 7 and last 6 values are judged not clear due to night (ghi=0)
    # and rapid change in ghi with sunrise and sunset
    assert all(flags[7:-6])
    assert not flags[0:7].any() and not flags[-6:].any()
    ghi_cloud = ghi_clearsky.copy()
    ghi_cloud[12:15] *= 0.5
    flags = validator.detect_clearsky_ghi(ghi_cloud, ghi_clearsky)
    assert all(flags[7:12]) and all(flags[15:-6])
def validate_ghi(observation, values):
    """
    Run validation checks on a GHI observation.

    Parameters
    ----------
    observation : solarforecastarbiter.datamodel.Observation
       Observation object that the data is associated with
    values : pandas.Series
       Series of observation values

    Returns
    -------
    timestamp_flag : pandas.Series
        Bitmask from :py:func:`.validator.check_timestamp_spacing`
    night_flag : pandas.Series
        Bitmask from :py:func:`.validator.check_day_night` or
        :py:func:`.validator.check_day_night_interval`
    ghi_limit_flag : pandas.Series
        Bitmask from :py:func:`.validator.check_ghi_limits_QCRad`
    ghi_clearsky_flag : pandas.Series
        Bitmask from :py:func:`.validator.check_ghi_clearsky`
    cloud_free_flag : pandas.Series
        Bitmask from :py:func:`.validator.detect_clearsky_ghi`
    """
    solar_position, dni_extra, timestamp_flag, night_flag = _solpos_dni_extra(
        observation, values)
    clearsky = pvmodel.calculate_clearsky(observation.site.latitude,
                                          observation.site.longitude,
                                          observation.site.elevation,
                                          solar_position['apparent_zenith'])

    ghi_limit_flag = validator.check_ghi_limits_QCRad(values,
                                                      solar_position['zenith'],
                                                      dni_extra,
                                                      _return_mask=True)
    ghi_clearsky_flag = validator.check_ghi_clearsky(values,
                                                     clearsky['ghi'],
                                                     _return_mask=True)
    cloud_free_flag = validator.detect_clearsky_ghi(values,
                                                    clearsky['ghi'],
                                                    _return_mask=True)
    return (timestamp_flag, night_flag, ghi_limit_flag, ghi_clearsky_flag,
            cloud_free_flag)
Beispiel #3
0
def test_detect_clearsky_ghi_one_val(ghi_clearsky):
    ser = ghi_clearsky[:1]
    assert len(ser) == 1
    with pytest.warns(RuntimeWarning):
        flags = validator.detect_clearsky_ghi(ser, ser)
    assert (flags == 0).all()
Beispiel #4
0
def test_detect_clearsky_ghi_warn_regular_interval(ghi_clearsky):
    with pytest.warns(RuntimeWarning):
        ser = ghi_clearsky[:-2].append(ghi_clearsky[-1:])
        flags = validator.detect_clearsky_ghi(ser, ser)
    assert (flags == 0).all()
Beispiel #5
0
def test_detect_clearsky_ghi_warn_interval_length(ghi_clearsky):
    with pytest.warns(RuntimeWarning):
        flags = validator.detect_clearsky_ghi(ghi_clearsky[::4],
                                              ghi_clearsky[::4])
    assert (flags == 0).all()