NormalizerSimultan

class ompy.NormalizerSimultan(*, gsf=None, nld=None, normalizer_nld=None, normalizer_gsf=None)[source]

Bases: object

Simultaneous normalization of nld and gsf. Composed of Normalizer and NormalizerGSF as input, so read more on the normalization there

Variables
  • extractor (Extractor) – Extractor instance

  • gsf (Optional[Vector], optional) – gsf to normalize

  • multinest_path (Path, optional) – Default path where multinest saves files

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

  • nld (Optional[Vector], optional) – nld to normalize

  • normalizer_nld (NormalizerNLD) – NormalizerNLD instance to get the normalization paramters

  • normalizer_gsf (NormalizerGSF) – NormalizerGSF instance to get the normalization paramters

  • res (ResultsNormalized) – Results

  • std_fake_gsf (bool) – Whether the std. deviation is faked (see normalize)

  • std_fake_nld (bool) – Whether the std. deviation is faked (see normalize)

Todo

Work with more general models, too, not just CT for nld

Todo

  • currently have to set arguments here, an cannot set them in “normalize”

Parameters
  • gsf (optional) – see above

  • nld (optional) – see above

  • normalizer_nld (optional) – see above

  • normalizer_gsf (optional) – see above

Methods Summary

errfn(x, args_nld)

Compute the χ² of the normalization fitting

initial_guess()

Find an inital guess for normalization parameters

normalize(*[, num, gsf, nld, …])

Perform normalization and saves results to self.res

optimize(num, args_nld, guess)

Find parameters given model constraints and an initial guess

plot([ax, add_label, add_figlegend])

Plots nld and gsf

self_if_none(*args, **kwargs)

wrapper for lib.self_if_none

Methods Documentation

errfn(x, args_nld)[source]

Compute the χ² of the normalization fitting

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

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

Returns

The χ² value

Return type

chi2 (float)

initial_guess()[source]

Find an inital guess for normalization parameters

Uses guess of normalizer_nld and corresponding normalization of gsf

Return type

None

Returns

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

normalize(*, num=0, gsf=None, nld=None, normalizer_nld=None, normalizer_gsf=None)[source]

Perform normalization and saves results to self.res

Parameters
  • num (int, optional) – Loop number

  • gsf (Optional[Vector], optional) – gsf before normalization

  • nld (Optional[Vector], optional) – nld before normalization

  • normalizer_nld (Optional[NormalizerNLD], optional) – NormalizerNLD instance

  • normalizer_gsf (Optional[NormalizerGSF], optional) – NormalizerGSF instance

Return type

None

optimize(num, args_nld, 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, add_figlegend=True, **kwargs)[source]

Plots nld and gsf

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.

  • Optional[ResultsNormalized] (results) – If provided, gsf and model are taken from here instead.

  • **kwargs – kwargs for plot

Return type

Tuple[Any, Any]

Returns

fig, ax

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

wrapper for lib.self_if_none

errfn(x, args_nld)[source]

Compute the χ² of the normalization fitting

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

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

Returns

The χ² value

Return type

chi2 (float)

initial_guess()[source]

Find an inital guess for normalization parameters

Uses guess of normalizer_nld and corresponding normalization of gsf

Return type

None

Returns

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

normalize(*, num=0, gsf=None, nld=None, normalizer_nld=None, normalizer_gsf=None)[source]

Perform normalization and saves results to self.res

Parameters
  • num (int, optional) – Loop number

  • gsf (Optional[Vector], optional) – gsf before normalization

  • nld (Optional[Vector], optional) – nld before normalization

  • normalizer_nld (Optional[NormalizerNLD], optional) – NormalizerNLD instance

  • normalizer_gsf (Optional[NormalizerGSF], optional) – NormalizerGSF instance

Return type

None

optimize(num, args_nld, 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, add_figlegend=True, **kwargs)[source]

Plots nld and gsf

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.

  • Optional[ResultsNormalized] (results) – If provided, gsf and model are taken from here instead.

  • **kwargs – kwargs for plot

Return type

Tuple[Any, Any]

Returns

fig, ax

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

wrapper for lib.self_if_none