MPV fit¶
Find the most probable value in a HiSPARC spectrum.
FindMostProbableValueInSpectrum
find the most probable value in a HiSPARC spectrum
- class sapphire.analysis.find_mpv.FindMostProbableValueInSpectrum(n, bins)¶
Find the most probable value (MPV) in a HiSPARC spectrum.
This is a fast algorithm to find the MPV value in a HiSPARC spectrum. The MPV value indicates the position of the minimum-ionizing particles (MIP) peak. The algorithm makes some assumptions about the shape of the spectrum:
the spectrum includes the gamma peak (left-most part of spectrum) which has more counts per bin than the MIP peak.
ignoring the gamma peak, the MIP peak can be bracketed on the left by the numerically largest bin-to-bin increase in the number of counts.
the MIP peak can be approximated by a normal distribution.
Public methods:
find_mpv()
Find the most probable value
find_first_guess_mpv()
Make a first guess of the most probable value
fit_mpv()
Based on a first guess, fit the MIP peak to obtain the MPV
Initialize the class instance
- Parameters:
n,bins – histogram counts and bins, as obtained using
numpy.histogram
.
- find_mpv()¶
Find the most probable value.
First perform a first guess, then use that value to fit the MIP peak.
- Return mpv:
best guess of the most probable value.
- Return boolean is_fitted:
indicates if the fit was successful.
- find_first_guess_mpv()¶
First guess of most probable value.
The algorithm is fast and simple. The following steps are performed:
From the left: find the greatest value and cut off all data to the left of that maximum. We now assume the first datapoint to be the maximum of the gamma peak.
From the right: find the location of the greatest decrease from bin to bin. We assume that this value is where the MIP peak dips before joining the gamma peak.
Find the maximum to the right of this value. We assume this to be the approximate location of the MIP peak.
- Return mpv:
first guess of the most probable value.
- fit_mpv(first_guess, width_factor=0.4)¶
Fit a normal distribution to the MIP peak to obtain the MPV.
A normal distribution is fitted to the spectrum in a restricted domain around the first guess value. The width of the domain can be adjusted by the width_factor parameter.
- Parameters:
first_guess – approximate location of the most probable value.
width_factor – float in the range [0., 1.] to indicate the width of the fit domain. The domain is given by
[(1. - width_factor) * first_guess, (1. + width_factor) * first_guess]
.
- Return mpv:
mpv value obtained from the fit.