コード例 #1
0
    def test_gaussian_fit_length_minimize_trust_constr(self):

        fitOpt = FitOptions(fittingRoutine='minimize', method='trust-constr')
        t0 = time.perf_counter()
        rms_gauss = gaussian_fit(self.time_array,
                                 self.gaussian_dist,
                                 fitOpt=fitOpt)[2]
        t1 = time.perf_counter()

        runtime = t1 - t0
        result = (rms_gauss - self.length_gauss) / self.length_gauss

        return runtime, result
コード例 #2
0
    def test_binomial_amplitudeN_fit_length_minimize_trust_constr(self):

        fitOpt = FitOptions(fittingRoutine='minimize', method='trust-constr')
        t0 = time.perf_counter()
        full_binom, exponent = binomial_amplitudeN_fit(self.time_array,
                                                       self.binom_dist,
                                                       fitOpt=fitOpt)[2:]
        t1 = time.perf_counter()

        runtime = t1 - t0

        rms_binom = _binomial_full_to_rms(full_binom, exponent)
        result = (rms_binom - self.sigma_binom) / self.sigma_binom

        return runtime, result
コード例 #3
0
plotOpt = PlotOptions(figname='FWHM', clf=False)

fwhm_gauss = FWHM(time_array, gaussian_dist, plotOpt=plotOpt)
fwXm_parabamp = FWHM(time_array, parabamp_dist, level=0.8, plotOpt=plotOpt)
fwXm_binom = FWHM(time_array, binom_dist, level=0.2, plotOpt=plotOpt)

# In[6]:

# The FWHM can be obtained, note that the level can be manually set
# The bunchLengthFactor option can be used to rescale the FWHM to another value
# e.g. : to 4sigma assuming Gaussian, or parabolic_line, or parabolic_amplitude

from blond_common.fitting.profile import FWHM, FitOptions

fitOpt = FitOptions(bunchLengthFactor='gaussian')
fwhm_gauss = FWHM(time_array, gaussian_dist, fitOpt=fitOpt)

fitOpt = FitOptions(bunchLengthFactor='parabolic_amplitude')
fwhm_parabamp = FWHM(time_array, parabamp_dist, level=0.2, fitOpt=fitOpt)

print('Gauss: Input ->', [initial_params_gauss[1], sigma_gauss * 4],
      '/ Output ->', fwhm_gauss[0:2])
print('Parab. amp.: Input ->',
      [initial_params_parabamp[1], sigma_parabamp * 4], '/ Output ->',
      fwhm_parabamp[0:2])

# In[7]:

# The width at 2 different levels can give all needed information on the binomial parameters
# The binomialParametersFromRatio function can be used directly