pvanalytics.quality.gaps.interpolation_diff(x, window=6, rtol=1e-05, atol=1e-08, mark='tail')#

Identify sequences which appear to be linear.

Sequences are linear if the first difference appears to be constant. For a window of length N, the last value (index N-1) is flagged if all values in the window appear to be a line segment.

Parameters rtol and atol have the same meaning as in numpy.allclose().

  • x (Series) – data to be processed

  • window (int, default 6) – number of sequential values that, if the first difference is constant, are classified as a linear sequence

  • rtol (float, default 1e-5) – tolerance relative to max(abs(x.diff()) for detecting a change

  • atol (float, default 1e-8) – absolute tolerance for detecting a change in first difference

  • mark (str, default 'tail') –

    How much of the window to mark True when a sequence of interpolated values is detected. Can be one of ‘tail’, ‘end’, or ‘all’.

    • If ‘tail’ (the default) then every point in the window except the first point is marked True.

    • If ‘end’ then the first window - 1 values in an interpolated sequence are marked False and all subsequent values in the sequence are marked True.

    • If ‘all’ then every point in the window including the first point is marked True.


True for each value that is part of a linear sequence

Return type



ValueError – If window < 3 or mark is not one of ‘tail’, ‘end’, or ‘all’.


Copyright (c) 2019 SolarArbiter. See the file LICENSES/SOLARFORECASTARBITER_LICENSE at the top level directory of this distribution and at https://github.com/pvlib/pvanalytics/blob/master/LICENSES/SOLARFORECASTARBITER_LICENSE for more information.

Examples using pvanalytics.quality.gaps.interpolation_diff#

Interpolated Data Periods

Interpolated Data Periods