pileup API documentation

A module to study the pile-up of distributions

pileup.count_to_particle_ratio(l)[source]

Return the expected value of the ratio of the number of particles arriving in a detector with the number of counts.

This number is calculated assuming the number of counts per pulse in a detection is a random process conditioned by (number of counts > 0). Thus, the factor is given by \(\frac{\lambda}{1-e^{-\lambda}}\).

pileup.depile(yy, l, method='Fourier', series_order=20, bin_size=None, zero_pad=None, f=None, par_0=None, fit_pars=None, depiled_0=None)[source]

Calculate a depiled spectrum.

Parameters:
  • yy (list of float) – vector defining the piled spectrum.
  • l (float) – poisson piling parameter.
  • method (str) –

    the method used to calculate the depiling. Available methods include:

    • ”series”: A series expansion analogous to the Mercator series. Might not converge.
    • ”fourier”: “Exact” solution in the fourier domain.
    • ”fourier_c”: Same as fourier, using the fft instead of rfft.
    • ”fourier_series”: A series expansion in the fourier domain.
    • ”parametric”: Non-linear least squares fit a function using scipy.optimize.curve_fit.
    • ”nonparametric”: Non-linear least squares vector minimization using scipy.optimize.fmin_l_bfgs_b.
  • series_order (int) – the number of terms used in a series expansion method.
  • f (callable) – if “parametric” is used, the model function, which takes the independent variable as as the first argument and the parameters to fit as separate remaining arguments.
  • par_0 (list of float) – if “parametric” is used, the initial guess for the parameters. If None, then the initial values will all be 1 (if the number of parameters for the function can be determined using introspection, otherwise a ValueError is raised).
  • fit_pars (list) – If “parametric” is used, provide an empty list to recover the best-fit parameters and the covariance estimation. See scipy.optimize.curve_fit.
  • depiled_0 (list of float) – if “nonparametric” is used, the initial guess for the distribution. If None, the uniform distribution will be the starting distribution.
  • bin_size (float) – dE in the spectrum. If None, chosen so it is normalized.
  • zero_pad (int) – Number of zeros to pad to the end of yy.
Returns:

The depiled spectrum.

Return type:

(numpy.ndarray)

Note

“parametric” and “nonparametric” methods might return non-global best-fits. Also, the time taken might be long, specially in “nonparametric”.

pileup.pile(yy, l, method='Fourier', series_order=10, bin_size=None, zero_pad=None)[source]

Calculate a piled spectrum.

Parameters:
  • yy (list of float) – vector defining the original spectrum.
  • l (float) – poisson piling parameter.
  • method (str) –

    the method used to calculate the piling. Available methods include:

    • ”series”: A series expansion of the convolution exponential.
    • ”fourier”: “Exact” solution in the fourier domain.
    • ”fourier_c”: Same as fourier, using the fft instead of rfft.
    • ”fourier_series”: A series expansion in the fourier domain.
  • series_order (int) – the number of terms used in a series expansion method.
  • bin_size (float) – dE in the spectrum. If None, automatically chosen so it is normalized.
  • zero_pad (int) – Number of zeros to pad to the end of yy.
Returns:

The piled spectrum.

Return type:

(numpy.ndarray)

pileup.piled_sample(l, f_sample, size=None)[source]

Sample from a distributions with an added poissonian pile-up

pileup.poisson_lambda(rate)[source]

Return the poisson characteristic parameter, given a rate of counting/pulse frequency