qudi.util.fit_models.helpers.correct_offset_histogram

qudi.util.fit_models.helpers.correct_offset_histogram(data, bin_width=None)[source]

Subtracts a constant offset from a copy of given data array and returns it. The offset is assumed to be the most common value in data. This value is determined by creating a histogram of <data> with bin width <bin_width> and taking the value with the most occurrences. If no bin width has been specified, assume bin width of 1/50th of data length (min. 1).

For best results, make sure to filter noisy data beforehand. The used smoothing filter width is a good estimate for optimal bin_width.

Parameters:
dataiterable

Peak data to correct offset for. Must be convertible using numpy.asarray.

bin_widthint, optional

Bin width in samples to use for histogram creation. Default is None, which sets bin width to 1/50th of data length (minimum 1).

Returns:
numpy.ndarray, float

New array with offset-corrected data, the offset value.