예제 #1
0
def _validate_stale_interpolated(observation, values):
    window = validator.stale_interpolated_window(observation.interval_length)
    stale_flag = validator.detect_stale_values(values, window=window,
                                               _return_mask=True)
    interpolation_flag = validator.detect_interpolation(values, window=window,
                                                        _return_mask=True)
    return stale_flag, interpolation_flag
예제 #2
0
def validate_daily_ac_power(observation, values):
    """
    Run a number of validation checks on a daily timeseries of AC power.

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

    Returns
    -------
    tuple
        Tuple of integer bitmask series of flags from the following tests, in
        order,
        `validator.check_timestamp_spacing`
        `validator.detect_stale_values`
        `validator.detect_interpolation`
        `validator.detect_clipping`
    """
    timestamp_flag = _validate_timestamp(observation, values)
    stale_flag = validator.detect_stale_values(values, _return_mask=True)
    interpolation_flag = validator.detect_interpolation(values,
                                                        _return_mask=True)
    clipping_flag = validator.detect_clipping(values, _return_mask=True)
    return (timestamp_flag, stale_flag, interpolation_flag, clipping_flag)
예제 #3
0
def validate_daily_ghi(observation, values):
    """
    Run validation on a daily timeseries of GHI. First,
    all checks of `validate_ghi` are run in addition to
    detecting stale values and interpolation

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

    Returns
    -------
    tuple
        Tuple of integer bitmask series of flags from the following tests, in
        order,
        tests from `validate_ghi`
        `validator.detect_stale_values`
        `validator.detect_interpolation`
    """
    ghi_flags = validate_ghi(observation, values)
    stale_flag = validator.detect_stale_values(values, _return_mask=True)
    interpolation_flag = validator.detect_interpolation(values,
                                                        _return_mask=True)
    return (*ghi_flags, stale_flag, interpolation_flag)
예제 #4
0
def test_detect_interpolation():
    data = [1.0, 1.001, 1.002001, 1.003, 1.004, 1.001001, 1.001001, 1.001001,
            1.2, 1.3, 1.5, 1.4, 1.5, 1.6, 1.7, 1.8, 2.0]
    x = pd.Series(data=data)
    res1 = validator.detect_interpolation(x, window=3)
    assert_series_equal(res1, pd.Series([False, False, False, False, False,
                                         False, False, True, False, False,
                                         False, False, False, True, True, True,
                                         False]))
    res2 = validator.detect_interpolation(x, window=3, rtol=1e-2)
    assert_series_equal(res2, pd.Series([False, False, True, True, True,
                                         False, False, True, False, False,
                                         False, False, False, True, True, True,
                                         False]))
    res3 = validator.detect_interpolation(x, window=5)
    assert_series_equal(res3, pd.Series([False, False, False, False, False,
                                         False, False, False, False, False,
                                         False, False, False, False, False,
                                         True, False]))
    res4 = validator.detect_interpolation(x, window=3, atol=1e-2)
    assert_series_equal(res4, pd.Series([False, False, True, True, True,
                                         True, True, True, False, False,
                                         False, False, False, True, True, True,
                                         False]))
    data = [0.0, 0.0, 0.0, -0.0, 0.00001, 0.000010001, -0.00000001]
    y = pd.Series(data=data)
    res = validator.detect_interpolation(y, window=3, atol=1e-5)
    assert_series_equal(res, pd.Series([False, False, True, True, True, True,
                                        False]))
    res = validator.detect_stale_values(y, window=3, atol=1e-4)
    assert_series_equal(res, pd.Series([False, False, True, True, True, True,
                                        True]))
    with pytest.raises(ValueError):
        validator.detect_interpolation(x, window=2)