conflux.ConversionEngine ======================== .. py:module:: conflux.ConversionEngine Classes ------- .. autoapisummary:: conflux.ConversionEngine.BetaData conflux.ConversionEngine.VirtualBranch conflux.ConversionEngine.ConversionEngine Functions --------- .. autoapisummary:: conflux.ConversionEngine.HuberZavg conflux.ConversionEngine.rebin Module Contents --------------- .. py:class:: BetaData(inputDB, rel_err=True) Bases: :py:obj:`conflux.Basic.Spectrum` A class to save the beta spectrum data to be converted in the computer memory. ... Attributes ---------- x : list A list of the x-axis bins y : list A list of the y-axis values (bin content) yerr : list A list of the errors on the y-axis (bin error) inputDB : str The filename where the spectrum data is saved spectrum : :class:`numpy.array` An array to store the full beta spectrum uncertainty : :class:`numpy.array` An array to store the full beta spectrum uncertainty Methods ------- LoadConversionDB(self, inputDB, rel_err=True): Load the beta spectrum data .. py:attribute:: x :value: [] .. py:attribute:: y :value: [] .. py:attribute:: yerr :value: [] .. py:attribute:: inputDB .. py:method:: LoadConversionDB(inputDB, rel_err=True) Load the beta spectrum data. :param inputDB: The file name of the beta spectrum data to fit against. :type inputDB: str :param rel_err: Indicate whether the uncertainty of the data is relative (True) or absolute (False), defaults to True :type rel_err: bool, optional .. py:class:: VirtualBranch(fisIstp, Zlist={}, Alist={}, fblist={}, wmlist={}) Bases: :py:obj:`conflux.Basic.Spectrum` A class that creates virtual branch with customized end-point energy and virtual nuclide summarized from nuclides with the similar end-point energy based on nuclear data, and fit the virtual branch against a reference beta spectrum. ... Attributes ---------- fisIstp : :class:`conflux.FPYEngine.FissionIstp` The corresponding fission isotope to fit against. This isotope provides nuclear data to generate a virtual nuclide for the virtual branch. FPYlist : dict A dictionary of fission product yields of the input fission isotope contribute : list Best fit contributions of vitual branches E0 : list Best fit end-point energies of virtual branches slicesize : float The size the energy slices for virtual branch fitting Zlist : dict A dictionary of Z numbers of the virtual nuclide calculated for each virtual branch of corresponding energy slice (end-point energy) Alist : dict A dictionary of A numbers of the virtual nuclide calculated for each virtual branch of corresponding energy slice (end-point energy) fblist : dict A dictionary of forbidden transition fractions of each virtual branch of corresponding energy slice (end-point energy) wmlist : dict A dictionary of weak magnetism correction factor of each virtual branch of corresponding energy slice (end-point energy) Methods ------- LoadFPYList(self): Load the fission products of the input fission isotope CalcZAavg(self, Elow, Ehigh, missing=False): .. py:attribute:: fisIstp .. py:attribute:: Zavg :value: 47 .. py:attribute:: Aavg :value: 117 .. py:attribute:: Zlist .. py:attribute:: Alist .. py:attribute:: fblist .. py:attribute:: wmlist .. py:attribute:: _Zlist_cp .. py:attribute:: _Alist_cp .. py:attribute:: _fblist_cp .. py:attribute:: _wmlist_cp .. py:attribute:: FPYlist .. py:attribute:: istplist .. py:method:: LoadFPYList() Load the fission product yield of the fissile isotope. This is to calculate the average atom numbers of the energy slices. .. py:method:: CalcZAavg(Elow, Ehigh, missing=False) Calculate the average Z and A number of the slice of the virtual beta spectrum. :param Elow: lower bondary of the spectrum energy slice :type Elow: float :param Ehigh: igher bondary of the spectrum energy slice :type Ehigh: float :param missing: whether to count missing contributions in the beta DB, defaults to False :type missing: bool, optional .. py:method:: BetaSpectrum(x, E0, contribute, Zavg=None, Aavg=None, nu_spectrum=False, forbiddenness=0, bAc=4.7, norm=True) Calculate the theoretical beta/neutrino spectrum shape. :param x: Energy of the beta/neutrino (x values) :type x: float :param E0: End-point energy of the spectrum :type E0: float :param contribute: The normalization or contribution of this spectrum to the summed entire beta spectrum :type contribute: float :param Zavg: The Z number of the vitual nuclide for a virtual branch beta spectrum calculation, defaults to None :type Zavg: int, optional :param Aavg: The Z number of the vitual nuclide for a virtual branch beta spectrum calculation, defaults to None :type Aavg: int, optional :param nu_spectrum: whether to calculate neutrino (True) or beta (False) spectrum, defaults to False :type nu_spectrum: bool, optional :param forbiddenness: type of forbidden/allowed transitions , defaults to 0 :type forbiddenness: int, optional :param bAc: Weak magnetism correction factor, defaults to 4.7 :type bAc: float, optional :param norm: Whether to normalize the beta spectrum integral to 1, defaults to True :type norm: bool, optional .. py:method:: FitData(betadata, slicesize=0.5) Fits the reference beta spectrum with virtual brances data. The virtual branches are defined as single beta decay spectra. The virtual branches are fitted to slices of the reference data spectra in a short range from the highest energy to the lowest, each bestfit virtual branch spectrum is subtracted from the reference data to let the next virtual branch to fit the updated spectrum in the consequential energy slice. :param betadata: The input BetaData object that provides the reference beta spectrum to fit. :type betadata: :class:`conflux.ConversionEngine.BetaData` :param slicesize: The size of the energy range, should be greater than 0.2 (MeV) and smaller than 2 (MeV), defaults to 0.5 :type slicesize: float .. py:method:: FitDataNNLS(betadata, slicesize, seeds=2000) Fit virtual beta branches to the input beta data using the :meth:`scipy.optimize.nnls` method (maybe obsolete). :param betadata: The input BetaData object that provides the reference beta spectrum to fit. :type betadata: :class:`conflux.ConversionEngine.BetaData` :param slicesize: The size of the energy range, should be greater than 0.2 (MeV) and smaller than 2 (MeV), defaults to 0.5 :type slicesize: float :param seeds: number of MC samples for this calculation, defaults to 2000 :type seeds: int, optional .. py:method:: SumBranches(x, thresh=0, nu_spectrum=False) Sum the best fit vitual branch spectra to form the best fit beta/neutrino model spectrum. :param x: energy of the particle (the x value of spectrum) :type x: ndarray :param thresh: Overrides the threshold. If threhold > 0, only add branch whose energy range is above the threshold, defaults to 0 :type thresh: float, optional :param nu_spectrum: whether to calculate neutrino (True) or beta (False) spectrum, defaults to False :type nu_spectrum: bool, optional :return: summed spectrum :rtype: ndarray .. py:method:: Covariance(betadata, x, samples=50, thresh=0, nu_spectrum=True) Calculate the covariance of the conversion/fitting result by creating MC samples of beta data with varied bin content from the original spectrum within its uncertainty. :param betadata: The input BetaData object that provides the reference beta spectrum to fit. :type betadata: :class:`conflux.ConversionEngine.BetaData` :param x: energy of the particle (the x value of spectrum) :type x: ndarray :param samples: the amount of MC samples, defaults to 50 :type samples: int, optional :param thresh: Overrides the threshold. If threhold > 0, only add branch whose energy range is above the threshold, defaults to 0 :type thresh: float, optional :param nu_spectrum: whether to calculate neutrino (True) or beta (False) spectrum, defaults to True :type nu_spectrum: bool, optional :return: the covariance matrix of the virtual branch fitting or conversion result :rtype: ndarray .. py:class:: ConversionEngine Bases: :py:obj:`conflux.Basic.Spectrum` Class that search for best fit vertual branch and sum the converted total neutrino flux. ... Attributes ---------- betadata : dict A dictionary of beta spectra of fission isotopes fission_frac : dict A dictionary of the fission isotope fractions fission_dfrac : dict A dictionary of the fission isotope fraction uncertainties fisIstp : dict A dictionary of the fission isotope in the conversion model vblist: dict A dictionary of the virtual branches spectrum : :class:`numpy.array` An array to store the full beta spectrum uncertainty : :class:`numpy.array` An array to store the full beta spectrum uncertainty covariance : :class:`numpy.array` The covariance matrix of the best fit spectrum or converted spectrum Methods ------- AddBetaData(self, betadata, fisIstp, name, frac, dfrac=0): Add beta spectrum data as fitting reference into the dictionaries VBfitbeta(self, istp, slicesize = 0.5, Ei = 0, Zlist={}, Alist={}): Let vitual branches to fit against beta data with user chosen slice size. SummedSpectrum(self, x, nu_spectrum=True, cov_samp=20): Function to sum all best fit spectra calculated in the conversion engine. .. py:attribute:: betadata .. py:attribute:: fission_count .. py:attribute:: fission_dcount .. py:attribute:: fisIstp .. py:attribute:: vblist .. py:method:: AddBetaData(betadata, fisIstp, name, count, d_count=0) Add beta spectrum data as fitting reference into the dictionaries. :param betadata: The input BetaData object that provides the reference beta spectrum to fit. :type betadata: :class:`conflux.ConversionEngine.BetaData` :param istp: The corresponding fission isotope to fit against. This isotope provides nuclear data to generate a virtual nuclide for the virtual branch. :type istp: :class:`conflux.FPYEngine.FissionIstp` :param istp: The unique name of the fission isotope and spectrum that will be fitted. :type istp: str :param count: The fraction of the fission isotope in the conversion model :type count: float :param d_count: The fraction uncertainty of the fission isotope in the conversion model :type d_count: float .. py:method:: VBfitbeta(istp, slicesize=0.5, Zlist={}, Alist={}) Let vitual branches to fit against beta data with user chosen slice size. :param istp: The corresponding fission isotope to fit against. This isotope provides nuclear data to generate a virtual nuclide for the virtual branch. :type istp: :class:`conflux.FPYEngine.FissionIstp` :param slicesize: The size of the energy range, should be greater than 0.2 (MeV) and smaller than 2 (MeV), defaults to 0.5 :type slicesize: float :param Zlist: The mapping between the beta energy and input average Z number, defaults to {} :type Zlist: dict, optional :param Alist: The mapping between the beta energy and input average A number, defaults to {} :type Alist: dict, optional .. py:method:: SummedSpectrum(x, nu_spectrum=True, cov_samp=50) Sum all best fit or converted spectra calculated in the conversion engine based on the fractions and uncertainties. :param x: Particle energy (x values of the specrrum) :type x: ndarray :param nu_spectrum: whether to calculate beta (False) or netutrino (True) spectrum, defaults to True :type nu_spectrum: bool, optional :param cov_samp: the amount of MC samples for covariance matrix calculation, defaults to 50 :type cov_samp: int, optional Returns ------- spectrum: ndarray The summed spectrum in the form of ndarray uncertainty: ndarray The uncertainty array of the summed spectrum covariance: ndarray The covariance matrix of the of the spectrum on given energy bin .. py:function:: HuberZavg(x, c0, c1, c2) .. py:function:: rebin(data, bins)