NormalizerSimultan¶
- class ompy.NormalizerSimultan(*, gsf=None, nld=None, normalizer_nld=None, normalizer_gsf=None, path='saved_run/normalizers', regenerate=False)[source]¶
Bases:
AbstractNormalizer
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)
path (Path) – The path save the results.
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
Attributes Summary
Methods Summary
Find an inital guess for normalization parameters
lnlike
(x, args_nld)Compute log likelihood of the normalization fitting
load
([path])Loads (pickeled) instance.
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
save
([path, overwrite])Save (pickels) the instance
save_results_txt
([path, nld, gsf, samples, ...])Save results as txt
self_if_none
(*args, **kwargs)wrapper for lib.self_if_none
Attributes Documentation
- LOG = <Logger ompy.normalizer_simultan (WARNING)>¶
Methods Documentation
- initial_guess()[source]¶
Find an inital guess for normalization parameters
Uses guess of normalizer_nld and corresponding normalization of gsf
- Return type:
- Returns:
The arguments used for chi^2 minimization and the minimizer.
- lnlike(x, args_nld)[source]¶
Compute log likelihood of the normalization fitting
This is the result up to the constant, which is irrelevant for the maximization
- load(path=None)¶
Loads (pickeled) instance.
Such that it can be loaded if regenerate = False. Note that if any modifications of the __getstate__ method are present, these will effect what attributes are pickeled.
- Parameters:
path (
Union
[str
,Path
,None
]) – The path to the directoryto load file. If the value is None, ‘self.path’ will be used.- Raises:
FileNotFoundError – If file is not found
- 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:
- optimize(num, args_nld, guess)[source]¶
Find parameters given model constraints and an initial guess
Employs Multinest.
- 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
Note
You might want to adjust the priors for your specific case! Here we just propose a general solution that might often work out of the box.
- plot(ax=None, add_label=True, add_figlegend=True, **kwargs)[source]¶
Plots nld and gsf
- Parameters:
- Return type:
- Returns:
fig, ax
- save(path=None, overwrite=True)¶
Save (pickels) the instance
Such that it can be loaded, and enabling the regenerate later.
- save_results_txt(path=None, nld=None, gsf=None, samples=None, suffix=None)¶
Save results as txt
Uses a folder to save nld, gsf, and the samples (converted to an array)