From 7597a999fe62056444342d479d864f04ad40d5b9 Mon Sep 17 00:00:00 2001 From: Jakob Stierhof Date: Sat, 2 Dec 2023 18:28:08 +0100 Subject: [PATCH] Add qualifier to enflux function With this qualifier the normalization value can be retrieve. This is useful to calculate the flux of components --- src/fitting/fit-functions/enflux.sl | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/fitting/fit-functions/enflux.sl b/src/fitting/fit-functions/enflux.sl index 827db823..e113f0a9 100644 --- a/src/fitting/fit-functions/enflux.sl +++ b/src/fitting/fit-functions/enflux.sl @@ -4,6 +4,11 @@ private define enflux_fit(lo, hi, par, y) %!%+ %\function{enflux (fit-function)} %\synopsis{fits the photon flux in a given energy range} +% +%\qualifiers{ +% \qualifier{norm}{If given a reference to a variable, store the +% normalization factor in there.} +%} %\description % This function can be used as a convolution model to determine % the energy flux [keV/s/cm^2] of the model in the energy range @@ -65,12 +70,21 @@ private define enflux_fit(lo, hi, par, y) variable flux = par[0]; variable l1 = _A(par[2]); variable l2 = _A(par[1]); + + variable norm_value; + variable store_norm = qualifier("norm"); + if (Fit_Verbose >= 0 && (l1 < lo[0] or l2 > hi[-1])) vmessage("warning: enflux energy range (%.2e-%.2e keV) not covered by data grid (%.2e-%.2e keV)", par[1],par[2],_A(hi[-1]),_A(lo[0])); variable i = where(l1 <= lo and hi <= l2); variable mean_e = _A(1.)/(0.5*(hi+lo)[i]); - return y * flux / sum( mean_e*y[i] ); + norm_value = sum( mean_e*y[i] ); + + if (typeof(store_norm) == Ref_Type) + @store_norm = norm_value; + + return y * flux / norm_value; } %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -- GitLab