NormalizerNLD

class ompy.NormalizerNLD(*, nld=None, discrete=None, path=None, norm_pars=None)[source]

Bases: object

Normalizes NLD to empirical data

Normalizes nld/gsf according to:

nld' = nld * A * np.exp(alpha * Ex), and

This is the transformation eq (3), Schiller2000

Takes empirical data in form of an array of discrete levels, neutron separation energy Sn, a model to estimate what the NLD is at Sn, and several parameters for the model as well as bounds on normalization parameters.

As a consequence of a complex problem, this class has a complex interface. Much of the book-keeping associated with normalization has been automated, but there is still a lot of settings and parameters for the user to take care of. Some default values has been seen, but the user must be _EXTREMELY_ careful when evaluating the output.

Variables
  • discrete (Vector) – The discrete NLD at lower energies. [MeV]

  • nld (Vector) – The NLD to normalize. Gets converted to [MeV] from [keV].

  • norm_pars (NormalizationParameters) – Normalization parameters like experimental D₀, and spin(-cut) model

  • bounds (Dict[str, Tuple[float, float]) – The bounds on each of the parameters. Its keys are ‘A’, ‘alpha’, ‘T’, and ‘D0’. The values are on the form (min, max).

  • model (Callable[.., ndarray]) – The model to use at high energies to estimate the NLD. Defaults to constant temperature model.

  • multinest_path (Path) – Where to save the multinest output. defaults to ‘multinest’.

  • multinest_kwargs (dict) – Additional keywords to multinest. Defaults to {“seed”: 65498, “resume”: False}

  • res (ResultsNormalized) – Results of the normalization

  • smooth_levels_fwhm (float) – FWHM with which the discrete levels shall be smoothed when loading from file. Defaults to 0.1 MeV.

  • path (Path) – The path the transformed vectors to.

Normalizes nld ang gSF.

Note

The prefered syntax is Normalizer(nld=…) If neither is given, the nld (and other parameters) can be explicity be set later by:

`normalizer.normalize(..., nld=...)`

or:

`normalizer.nld = ...`

In the later case you might have to send in a copy if it’s a mutable to ensure it is not changed.

Parameters

Todo

  • parameter to limit the number of multinest samples to store. Note that the samples should be shuffled to retain some “random” samples from the pdf (not the importance weighted)

Attributes Summary

discrete

rtype

Optional[Vector]

smooth_levels_fwhm

rtype

Optional[float]

Methods Summary

D0_from_nldSn(nld_model, Sn, Jtarget, …)

Calculate D0 from nld(Sn), assuming equiparity.

__call__(*args, **kwargs)

Wrapper around normalize

const_temperature(E, T, Eshift)

Constant Temperature NLD

errfn(x, nld_low, nld_high, discrete, model, …)

Compute the χ² of the normalization fitting

initial_guess([limit_low, limit_high])

Find an inital guess for the constant, α, T and D₀

load([path])

Load already normalized NLD from path.

nldSn_from_D0(D0, Sn, Jtarget, spincutModel, …)

Calculate nld(Sn) from D0

normalize(*[, limit_low, limit_high, nld, …])

Normalize NLD to a low and high energy region

optimize(num, args, guess)

Find parameters given model constraints and an initial guess

plot(*[, ax, add_label, results, …])

Plot the NLD, discrete levels and result of normalization

save([path, num])

Save results to path.

self_if_none(*args, **kwargs)

wrapper for lib.self_if_none

Attributes Documentation

discrete
Return type

Optional[Vector]

smooth_levels_fwhm
Return type

Optional[float]

Methods Documentation

static D0_from_nldSn(nld_model, Sn, Jtarget, spincutModel, spincutPars, **kwargs)[source]

Calculate D0 from nld(Sn), assuming equiparity.

This is the inverse of nldSn_from_D0

Parameters
  • nld_model (Callable[.., Any]) – Model for nld above data of the from y = nld_model(E) in 1/MeV.

  • Sn (float or [float, float]) – Separation energy [MeV]. If a tuple, it is assumed that it is of the form [value, uncertainty].

  • Jtarget (float) – Target spin

  • spincutModel (str) – Model to for the spincut

  • Dict[str, Any] (spincutPars) – Additional parameters necessary for the spin cut model

  • **kwargs – Description

Returns

D0 in eV

Return type

D0

__call__(*args, **kwargs)[source]

Wrapper around normalize

Return type

None

static const_temperature(E, T, Eshift)[source]

Constant Temperature NLD

Return type

ndarray

static errfn(x, nld_low, nld_high, discrete, model, Sn, nldSn)[source]

Compute the χ² of the normalization fitting

Parameters
  • x (Tuple[float, float, float, float]) – The arguments ordered as A, alpha, T and Eshift

  • nld_low (Vector) – The lower region where discrete levels will be fitted.

  • nld_high (Vector) – The upper region to fit to model.

  • discrete (Vector) – The discrete levels to be used in fitting the lower region.

  • model (Callable[…, ndarray]) – The model to use when fitting the upper region. Must support the keyword arguments model(E=..., T=..., Eshift=...) -> ndarray

Returns

The χ² value

Return type

chi2 (float)

initial_guess(limit_low=None, limit_high=None)[source]

Find an inital guess for the constant, α, T and D₀

Uses differential evolution to perform the guessing.

Parameters
  • limit_low (Optional[Tuple[float, float]]) – The limits (start, stop) where to normalize to discrete levels.

  • limit_high (Optional[Tuple[float, float]]) – The limits (start, stop) where to normalize to a theoretical model and neutron separation energy at high energies.

Return type

Tuple[Tuple[float, float, float, float], Dict[str, float]]

Returns

The arguments used for chi^2 minimization and the minimizer.

load(path=None)[source]

Load already normalized NLD from path.

Parameters

path (Union[str, Path, None]) – The path to the directory containing the files.

Todo

  • Save/LOAD whole Results class

Return type

None

static nldSn_from_D0(D0, Sn, Jtarget, spincutModel, spincutPars, **kwargs)[source]

Calculate nld(Sn) from D0

1/D0 = nld(Sn) * ( g(Jtarget+1/2, pi_target)
  • g(Jtarget1/2, pi_target) )

Here we assume equal parity, g(J,pi) = g(J)/2 and nld(Sn) = 1/D0 * 2/(g(Jtarget+1/2) + g(Jtarget-1/2)) For the case Jtarget = 0, the g(Jtarget-1/2) = 0

Parameters
  • D0 (float or [float, float]) – Average resonance spacing from s waves [eV]. If a tuple, it is assumed that it is of the form [value, uncertainty].

  • Sn (float or [float, float]) – Separation energy [MeV]. If a tuple, it is assumed that it is of the form [value, uncertainty].

  • Jtarget (float) – Target spin

  • spincutModel (str) – Model to for the spincut

  • Dict[str, Any] (spincutPars) – Additional parameters necessary for the spin cut model

  • **kwargs – Description

Returns

Ex=Sn and nld at Sn [MeV, 1/MeV]

Return type

nld

normalize(*, limit_low=None, limit_high=None, nld=None, discrete=None, bounds=None, norm_pars=None, num=0)[source]

Normalize NLD to a low and high energy region

Parameters
  • limit_low (Optional[Tuple[float, float]]) – The limits (start, stop) where to normalize to discrete levels.

  • limit_high (Optional[Tuple[float, float]]) – The limits (start, stop) where to normalize to a theoretical model and neutron separation energy at high energies.

  • nld (Optional[Vector]) – The nuclear level density vector to normalize.

  • discrete (Optional[Vector]) – The discrete level density at low energies to normalize to.

  • bounds (Optional[Dict[str, Tuple[float, float]]]) – The bounds of the parameters

  • norm_pars (NormalizationParameters) – Normalization parameters like

  • D₀, and spin (experimental) –

  • num (optional) – Loop number, defauts to 0

Return type

None

optimize(num, args, guess)[source]

Find parameters given model constraints and an initial guess

Employs Multinest

Parameters
  • num (int) – Loop number

  • args_nld (Iterable) – Additional arguments for the nld errfn

  • guess (Dict[str, float]) – The initial guess of the parameters

Returns

  • popt (Dict[str, Tuple[float, float]]): Median and 1sigma of the

    parameters

  • samples (Dict[str, List[float]]): Multinest samplesø.

    Note: They are still importance weighted, not random draws from the posterior.

Return type

Tuple

Raises

ValueError – Invalid parameters for automatix prior

plot(*, ax=None, add_label=True, results=None, add_figlegend=True, plot_fitregion=True, reset_color_cycle=True, **kwargs)[source]

Plot the NLD, discrete levels and result of normalization

Parameters
  • ax (optional) – The matplotlib axis to plot onto. Creates axis is not provided

  • add_label (bool, optional) – Defaults to True.

  • add_figlegend (bool, optional) – Defaults to True.

  • results (ResultsNormalized, optional) – If provided, nld and model are taken from here instead.

  • plot_fitregion (Optional[bool], optional) – Defaults to True.

  • reset_color_cycle (Optional[bool], optional) – Defaults to True

  • **kwargs – Description

Return type

Tuple[Any, Any]

Returns

fig, ax

save(path=None, num=None)[source]

Save results to path. .. todo:

- Save/LOAD whole Results class
- Currently completely broken
Return type

None

self_if_none(*args, **kwargs)[source]

wrapper for lib.self_if_none

static D0_from_nldSn(nld_model, Sn, Jtarget, spincutModel, spincutPars, **kwargs)[source]

Calculate D0 from nld(Sn), assuming equiparity.

This is the inverse of nldSn_from_D0

Parameters
  • nld_model (Callable[.., Any]) – Model for nld above data of the from y = nld_model(E) in 1/MeV.

  • Sn (float or [float, float]) – Separation energy [MeV]. If a tuple, it is assumed that it is of the form [value, uncertainty].

  • Jtarget (float) – Target spin

  • spincutModel (str) – Model to for the spincut

  • Dict[str, Any] (spincutPars) – Additional parameters necessary for the spin cut model

  • **kwargs – Description

Returns

D0 in eV

Return type

D0

static const_temperature(E, T, Eshift)[source]

Constant Temperature NLD

Return type

ndarray

static errfn(x, nld_low, nld_high, discrete, model, Sn, nldSn)[source]

Compute the χ² of the normalization fitting

Parameters
  • x (Tuple[float, float, float, float]) – The arguments ordered as A, alpha, T and Eshift

  • nld_low (Vector) – The lower region where discrete levels will be fitted.

  • nld_high (Vector) – The upper region to fit to model.

  • discrete (Vector) – The discrete levels to be used in fitting the lower region.

  • model (Callable[…, ndarray]) – The model to use when fitting the upper region. Must support the keyword arguments model(E=..., T=..., Eshift=...) -> ndarray

Returns

The χ² value

Return type

chi2 (float)

initial_guess(limit_low=None, limit_high=None)[source]

Find an inital guess for the constant, α, T and D₀

Uses differential evolution to perform the guessing.

Parameters
  • limit_low (Optional[Tuple[float, float]]) – The limits (start, stop) where to normalize to discrete levels.

  • limit_high (Optional[Tuple[float, float]]) – The limits (start, stop) where to normalize to a theoretical model and neutron separation energy at high energies.

Return type

Tuple[Tuple[float, float, float, float], Dict[str, float]]

Returns

The arguments used for chi^2 minimization and the minimizer.

load(path=None)[source]

Load already normalized NLD from path.

Parameters

path (Union[str, Path, None]) – The path to the directory containing the files.

Todo

  • Save/LOAD whole Results class

Return type

None

static nldSn_from_D0(D0, Sn, Jtarget, spincutModel, spincutPars, **kwargs)[source]

Calculate nld(Sn) from D0

1/D0 = nld(Sn) * ( g(Jtarget+1/2, pi_target)
  • g(Jtarget1/2, pi_target) )

Here we assume equal parity, g(J,pi) = g(J)/2 and nld(Sn) = 1/D0 * 2/(g(Jtarget+1/2) + g(Jtarget-1/2)) For the case Jtarget = 0, the g(Jtarget-1/2) = 0

Parameters
  • D0 (float or [float, float]) – Average resonance spacing from s waves [eV]. If a tuple, it is assumed that it is of the form [value, uncertainty].

  • Sn (float or [float, float]) – Separation energy [MeV]. If a tuple, it is assumed that it is of the form [value, uncertainty].

  • Jtarget (float) – Target spin

  • spincutModel (str) – Model to for the spincut

  • Dict[str, Any] (spincutPars) – Additional parameters necessary for the spin cut model

  • **kwargs – Description

Returns

Ex=Sn and nld at Sn [MeV, 1/MeV]

Return type

nld

normalize(*, limit_low=None, limit_high=None, nld=None, discrete=None, bounds=None, norm_pars=None, num=0)[source]

Normalize NLD to a low and high energy region

Parameters
  • limit_low (Optional[Tuple[float, float]]) – The limits (start, stop) where to normalize to discrete levels.

  • limit_high (Optional[Tuple[float, float]]) – The limits (start, stop) where to normalize to a theoretical model and neutron separation energy at high energies.

  • nld (Optional[Vector]) – The nuclear level density vector to normalize.

  • discrete (Optional[Vector]) – The discrete level density at low energies to normalize to.

  • bounds (Optional[Dict[str, Tuple[float, float]]]) – The bounds of the parameters

  • norm_pars (NormalizationParameters) – Normalization parameters like

  • D₀, and spin (experimental) –

  • num (optional) – Loop number, defauts to 0

Return type

None

optimize(num, args, guess)[source]

Find parameters given model constraints and an initial guess

Employs Multinest

Parameters
  • num (int) – Loop number

  • args_nld (Iterable) – Additional arguments for the nld errfn

  • guess (Dict[str, float]) – The initial guess of the parameters

Returns

  • popt (Dict[str, Tuple[float, float]]): Median and 1sigma of the

    parameters

  • samples (Dict[str, List[float]]): Multinest samplesø.

    Note: They are still importance weighted, not random draws from the posterior.

Return type

Tuple

Raises

ValueError – Invalid parameters for automatix prior

plot(*, ax=None, add_label=True, results=None, add_figlegend=True, plot_fitregion=True, reset_color_cycle=True, **kwargs)[source]

Plot the NLD, discrete levels and result of normalization

Parameters
  • ax (optional) – The matplotlib axis to plot onto. Creates axis is not provided

  • add_label (bool, optional) – Defaults to True.

  • add_figlegend (bool, optional) – Defaults to True.

  • results (ResultsNormalized, optional) – If provided, nld and model are taken from here instead.

  • plot_fitregion (Optional[bool], optional) – Defaults to True.

  • reset_color_cycle (Optional[bool], optional) – Defaults to True

  • **kwargs – Description

Return type

Tuple[Any, Any]

Returns

fig, ax

save(path=None, num=None)[source]

Save results to path. .. todo:

- Save/LOAD whole Results class
- Currently completely broken
Return type

None

self_if_none(*args, **kwargs)[source]

wrapper for lib.self_if_none