NormalizerGSF¶
-
class
ompy.
NormalizerGSF
(*, normalizer_nld=None, nld=None, nld_model=None, alpha=None, gsf=None, norm_pars=None)[source]¶ Bases:
object
Normalize γSF to a given` <Γγ> (Gg)
Normalizes nld/gsf according to the transformation eq (3), Schiller2000:
gsf' = gsf * B * np.exp(alpha * Eg)
- Variables
gsf_in (Vector) – gsf to normalize
nld (Vector) – nld
normalizer_nld (NormalizerNLD) – NormalizerNLD to retriev parameters.
nld_model (Callable[.., Any]) – Model for nld above data of the from y = nld_model(E)
alpha (float) – tranformation parameter α
model_low (ExtrapolationModelLow) – Extrapolation model for the gsf at low energies (below data)
model_high (ExtrapolationModelHigh) – Extrapolation model for the gsf at high energies (above data)
norm_pars (NormalizationParameters) – Normalization parameters like experimental <Γγ>
method_Gg (str) – Method to use for the <Γγ> integral
res (ResultsNormalized) – Results
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
normalizer_nld (Optional[NormalizerNLD], optional) – NormalizerNLD to retrieve parameters. If nld and/or nld_model are not set, they are taken from normalizer_nld.res in normalize.
nld (Optional[Vector], optional) – NLD. If not set it is taken from normalizer_nld.res in normalize.
nld_model (Optional[Callable[.., Any]], optional) – Model for nld above data of the from y = nld_model(E). If not set it is taken from normalizer_nld.res in normalize.
alpha (Optional[float], optional) – tranformation parameter α
gsf (Optional[Vector], optional) – gsf to normalize.
norm_pars (Optional[NormalizationParameters], optional) – Normalization parameters like experimental <Γγ>
Methods Summary
Compute <Γγ> before normalization
Compute normalization from <Γγ> (Gg) integral, the “standard” way
SpinSum
(Ex, J)Sum of spin distributions of the available states
errfn
()Weighted chi2
extrapolate
([gsf, E])Extrapolate gsf using given models
normalize
(*[, gsf, normalizer_nld, alpha, …])Normalize gsf to a given <Γγ> (Gg).
plot
([ax, add_label, add_figlegend, …])Plot the gsf and extrapolation normalization
Interactive plot to study the impact of different fit regions
self_if_none
(*args, **kwargs)wrapper for lib.self_if_none
spin_dist
(Ex, J)Wrapper for
ompy.SpinFunctions()
curried with model and parsMethods Documentation
-
Gg_before_norm
()[source]¶ Compute <Γγ> before normalization
- Returns
<Γγ> before normalization, in meV
- Return type
Gg (float)
-
Gg_standard
()[source]¶ Compute normalization from <Γγ> (Gg) integral, the “standard” way
Equals “old” (normalization.f) version in the Spin sum get the normaliation, see eg. eq (21) and (26) in Larsen2011; but converted T to gsf.
Assumptions: s-wave (current implementation) and equal parity
# better format in shpinx To derive the calculations, we start with <Γγ(E,J,π)> = 1/(2π ρ(E,J,π)) ∑_XL ∑_Jf,πf ∫dEγ 2π Eγ³ gsf(Eγ) * ρ(E-Eγ, Jf, πf) which leads to (eq 26)** <Γγ> = 1 / (4π ρ(Sₙ, Jₜ± ½, πₜ)) ∫dEγ 2π Eγ³ gsf(Eγ) ρ(Sₙ-Eγ) spinsum = 1 / (2 ρ(Sₙ, Jₜ± ½, πₜ)) ∫dEγ Eγ³ gsf(Eγ) ρ(Sₙ-Eγ) spinsum (= 1 / (ρ(Sₙ, Jₜ± ½, πₜ)) ∫dEγ Eγ³ gsf(Eγ) ρ(Sₙ-Eγ) spinsum(π) ) (= D0 1 ∫dEγ Eγ³ gsf(Eγ) ρ(Sₙ-Eγ) spinsum(π) ) where the integral runs from 0 to Sₙ, and the spinsum selects the available spins in dippole decays j=[-1,0,1]: spinsum = ∑ⱼ g(Sₙ-Eγ, Jₜ± ½+j). and <Gg> is a shorthand for <Γγ(Sₙ, Jₜ± ½, πₜ)> <Γγ(Sₙ, Jₜ± ½, πₜ)> = <<Γγ(Sₙ, Jₜ+ ½, πₜ)> + <Γγ(Sₙ, Jₜ- ½, πₜ)>> ≃ ½ * (<Γγ(Sₙ, Jₜ+ ½, πₜ)> + <Γγ(Sₙ, Jₜ- ½, πₜ)>) [but I'm challenged to derive "additivee" 1/ρ part; this is probably an approximation, although a equal sign is used in the article] We can obtain ρ(Sₙ, Jₜ± ½, πₜ) from eq(19) via D0: ρ(Sₙ, Jₜ± ½, πₜ) = ρ(Sₙ, Jₜ+ ½, πₜ) + ρ(Sₙ, Jₜ+ ½, πₜ) = 1/D₀ = ½ (ρ(Sₙ, Jₜ+ ½) + ρ(Sₙ, Jₜ+ ½)) [equi-parity] Equi-parity means further that g(J,π) = 1/2 * g(J), for the calc. above: spinsum(π) = 1/2 * spinsum. ** We set B to 1, so we get the <Γγ> before normalization. The normalization B is then B = <Γγ>_exp/ <Γγ>_cal
- Return type
- Returns
Calculated Gg from gsf and nld
-
extrapolate
(gsf=None, E=[None, None])[source]¶ Extrapolate gsf using given models
- Parameters
gsf (Optional[Vector]) – If extrapolation is fit, it will be fit to this vector. Default is self._gsf.
E (optional) – extrapolation energies [Elow, Ehigh]
- Return type
- Returns
The extrapolated gSF-vectors on the form [low region, high region]
- Raises
ValueError if the models have any None variables. –
-
normalize
(*, gsf=None, normalizer_nld=None, alpha=None, nld=None, nld_model=None, norm_pars=None, num=0)[source]¶ Normalize gsf to a given <Γγ> (Gg). Saves results to self.res.
- Parameters
normalizer_nld (Optional[NormalizerNLD], optional) – NormalizerNLD to retrieve parameters. If nld and/or nld_model are not set, they are taken from normalizer_nld.res in normalize.
nld (Optional[Vector], optional) – NLD. If not set it is taken from normalizer_nld.res in normalize.
nld_model (Optional[Callable[.., Any]], optional) – Model for nld above data of the from y = nld_model(E). If not set it is taken from normalizer_nld.res in normalize.
alpha (Optional[float], optional) – tranformation parameter α
gsf (Optional[Vector], optional) – gsf to normalize.
norm_pars (Optional[NormalizationParameters], optional) – Normalization parameters like experimental <Γγ>
num (Optional[int], optional) – Loop number, defaults to 0.
- Return type
None
-
plot
(ax=None, *, add_label=True, add_figlegend=True, plot_fitregion=True, results=None, reset_color_cycle=True, **kwargs)[source]¶ Plot the gsf and extrapolation 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.
plot_fitregion (Optional[bool], optional) – Defaults to True.
results (ResultsNormalized, optional) – If provided, gsf and model are taken from here instead.
reset_color_cycle (Optional[bool], optional) – Defaults to True
**kwargs – Additional keyword arguments
- Return type
- Returns
fig, ax
-
plot_interactive
()[source]¶ Interactive plot to study the impact of different fit regions
Note
- This implementation is not the fastest, however helped to reduce
the code quite a lot compared to slider_update
-
spin_dist
(Ex, J)[source]¶ Wrapper for
ompy.SpinFunctions()
curried with model and pars
-
Gg_before_norm
()[source] Compute <Γγ> before normalization
- Returns
<Γγ> before normalization, in meV
- Return type
Gg (float)
-
Gg_standard
()[source] Compute normalization from <Γγ> (Gg) integral, the “standard” way
Equals “old” (normalization.f) version in the Spin sum get the normaliation, see eg. eq (21) and (26) in Larsen2011; but converted T to gsf.
Assumptions: s-wave (current implementation) and equal parity
# better format in shpinx To derive the calculations, we start with <Γγ(E,J,π)> = 1/(2π ρ(E,J,π)) ∑_XL ∑_Jf,πf ∫dEγ 2π Eγ³ gsf(Eγ) * ρ(E-Eγ, Jf, πf) which leads to (eq 26)** <Γγ> = 1 / (4π ρ(Sₙ, Jₜ± ½, πₜ)) ∫dEγ 2π Eγ³ gsf(Eγ) ρ(Sₙ-Eγ) spinsum = 1 / (2 ρ(Sₙ, Jₜ± ½, πₜ)) ∫dEγ Eγ³ gsf(Eγ) ρ(Sₙ-Eγ) spinsum (= 1 / (ρ(Sₙ, Jₜ± ½, πₜ)) ∫dEγ Eγ³ gsf(Eγ) ρ(Sₙ-Eγ) spinsum(π) ) (= D0 1 ∫dEγ Eγ³ gsf(Eγ) ρ(Sₙ-Eγ) spinsum(π) ) where the integral runs from 0 to Sₙ, and the spinsum selects the available spins in dippole decays j=[-1,0,1]: spinsum = ∑ⱼ g(Sₙ-Eγ, Jₜ± ½+j). and <Gg> is a shorthand for <Γγ(Sₙ, Jₜ± ½, πₜ)> <Γγ(Sₙ, Jₜ± ½, πₜ)> = <<Γγ(Sₙ, Jₜ+ ½, πₜ)> + <Γγ(Sₙ, Jₜ- ½, πₜ)>> ≃ ½ * (<Γγ(Sₙ, Jₜ+ ½, πₜ)> + <Γγ(Sₙ, Jₜ- ½, πₜ)>) [but I'm challenged to derive "additivee" 1/ρ part; this is probably an approximation, although a equal sign is used in the article] We can obtain ρ(Sₙ, Jₜ± ½, πₜ) from eq(19) via D0: ρ(Sₙ, Jₜ± ½, πₜ) = ρ(Sₙ, Jₜ+ ½, πₜ) + ρ(Sₙ, Jₜ+ ½, πₜ) = 1/D₀ = ½ (ρ(Sₙ, Jₜ+ ½) + ρ(Sₙ, Jₜ+ ½)) [equi-parity] Equi-parity means further that g(J,π) = 1/2 * g(J), for the calc. above: spinsum(π) = 1/2 * spinsum. ** We set B to 1, so we get the <Γγ> before normalization. The normalization B is then B = <Γγ>_exp/ <Γγ>_cal
- Return type
- Returns
Calculated Gg from gsf and nld
-
SpinSum
(Ex, J)[source] Sum of spin distributions of the available states
-
errfn
()[source] Weighted chi2
-
extrapolate
(gsf=None, E=[None, None])[source] Extrapolate gsf using given models
- Parameters
gsf (Optional[Vector]) – If extrapolation is fit, it will be fit to this vector. Default is self._gsf.
E (optional) – extrapolation energies [Elow, Ehigh]
- Return type
- Returns
The extrapolated gSF-vectors on the form [low region, high region]
- Raises
ValueError if the models have any None variables. –
-
normalize
(*, gsf=None, normalizer_nld=None, alpha=None, nld=None, nld_model=None, norm_pars=None, num=0)[source] Normalize gsf to a given <Γγ> (Gg). Saves results to self.res.
- Parameters
normalizer_nld (Optional[NormalizerNLD], optional) – NormalizerNLD to retrieve parameters. If nld and/or nld_model are not set, they are taken from normalizer_nld.res in normalize.
nld (Optional[Vector], optional) – NLD. If not set it is taken from normalizer_nld.res in normalize.
nld_model (Optional[Callable[.., Any]], optional) – Model for nld above data of the from y = nld_model(E). If not set it is taken from normalizer_nld.res in normalize.
alpha (Optional[float], optional) – tranformation parameter α
gsf (Optional[Vector], optional) – gsf to normalize.
norm_pars (Optional[NormalizationParameters], optional) – Normalization parameters like experimental <Γγ>
num (Optional[int], optional) – Loop number, defaults to 0.
- Return type
None
-
plot
(ax=None, *, add_label=True, add_figlegend=True, plot_fitregion=True, results=None, reset_color_cycle=True, **kwargs)[source] Plot the gsf and extrapolation 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.
plot_fitregion (Optional[bool], optional) – Defaults to True.
results (ResultsNormalized, optional) – If provided, gsf and model are taken from here instead.
reset_color_cycle (Optional[bool], optional) – Defaults to True
**kwargs – Additional keyword arguments
- Return type
- Returns
fig, ax
-
plot_interactive
()[source] Interactive plot to study the impact of different fit regions
Note
- This implementation is not the fastest, however helped to reduce
the code quite a lot compared to slider_update
-
self_if_none
(*args, **kwargs)[source] wrapper for lib.self_if_none
-
spin_dist
(Ex, J)[source] Wrapper for
ompy.SpinFunctions()
curried with model and pars