Reference¶
BFASTMonitor Implementation¶

class
bfast.
BFASTMonitor
(start_monitor, freq=365, k=3, hfrac=0.25, trend=True, level=0.05, period=10, verbose=0, backend='opencl', platform_id=0, device_id=0, detailed_results=False, find_magnitudes=True)¶ BFASTMonitor implements the BFASTMonitor approach and provides two backends/implementations:
A pure Python implementation (based on the Numpy package).
An optimized OpenCL implementation suited for massivelyparallel devices.
The interface follows the one of the corresponding R package, see: https://cran.rproject.org/web/packages/bfast
 Parameters
 start_monitordatetime
A datetime object specifying the start of the monitoring phase.
 freqint, default 365
The frequency for the seasonal model.
 kint, default 3
The number of harmonic terms.
 hfracfloat, default 0.25
Float in the interval (0,1) specifying the bandwidth relative to the sample size in the MOSUM/ME monitoring processes.
 trendbool, default True
Whether a tend offset term shall be used or not.
 levelfloat, default 0.05
Significance level of the monitoring (and ROC, if selected) procedure, i.e., probability of type I error.
 verboseint, optional (default=0)
The verbosity level (0=no output, 1=output).
 backendstr, default ‘opencl”
Specifies the implementation that shall be used: backend=’python’ resorts to the nonoptimized Python version; backend=’opencl’ resorts to the optimized massivelyparallel OpenCL implementation.
 platform_idint, default 0
Only relevant if backend=’opencl’. Specifies the OpenCL platform id.
 device_id int, default 0
Only relevant if backend=’opencl’. Specified the OpenCL device id.
 detailed_resultsbool, default False
Only relevant if backend=’opencl’. If detailed results should be returned or not.
 find_magnitudesbool, default True
Only relevant if backend=’opencl’. If magnitudes should be returned or not. Disabling this would improve the performance greatly
 Attributes

fit
(self, data, dates, n_chunks=None, nan_value=0)¶ Fits the models for the ndarray ‘data’
 Parameters
 data: ndarray of shape (N, W, H),
where N is the number of time series points per pixel and W and H the width and the height of the image, respectively.
 dateslist of datetime objects
Specifies the dates of the elements in data indexed by the first axis n_chunks : int or None, default None
 nan_valueint, default 0
Specified the NaN value used in the array data
 Returns
 selfThe BFASTMonitor object.

get_params
(self)¶ Returns the parameters for this model.
 Returns
 dict: Mapping of string to any
parameter names mapped to their values.

set_params
(self, **params)¶ Sets the parameters for this model.
 Parameters
 paramsdict
Dictionary containing the parameters to be used.

property
timers
¶ Returns runtime measurements for the different phases of the fitting process.
 Returns
 dictAn dictionary containing the runtimes
for the different phases.

property
breaks
¶ Returns the breaks that have been computed.
 Returns
 arraylike: An array containing the (first) breaks
detected by BFASTMonitor. A ‘2’ corresponds to pixels (time series) not containing sufficient data and a ‘1’ to pixels without any breaks. All other nonnegative entries correspond to the first break that was detected in the monitor period (i.e., its index).

property
means
¶ Returns the means computed
 Returns
 arraylikeAn array containing the mean values
of the individual MOSUM processes (e.g., a positive mean for a pixel corresponds to an increase of the vegetation in case indices such as NDMI are considered)

property
magnitudes
¶ Returns the magnitudes computed
 Returns
 arraylikeAn array containing the magnitude
values median of the difference between the data and the model prediction in the monitoring period

property
valids
¶ Returns the number of valid values for each pixel
 Returns
 arraylikeAn array containing the number
of valid values for each pixel in the aray data
Helper Functions¶

bfast.monitor.utils.
crop_data_dates
(data, dates, start, end)¶ Crops the input data and the associated dates w.r.t. the provided start and end datetime object.
 Parameters
 data: ndarray of shape (N, W, H)
Here, N is the number of time series points per pixel and W and H are the width and the height of the image, respectively.
 dateslist of datetime objects
Specifies the dates of the elements in data indexed by the first axis n_chunks : int or None, default None
 startdatetime
The start datetime object
 enddatetime
The end datetime object
 Returns
 Returns: data, dates
The cropped data array and the cropped list. Only those images and dates that are with the start/end period are contained in the returned objects.