Commit 7597a999 authored by Jakob Stierhof's avatar Jakob Stierhof

Add qualifier to enflux function

With this qualifier the normalization value can be retrieve.
This is useful to calculate the flux of components
parent 4814a314
Pipeline #6935 passed with stages
in 42 seconds
......@@ -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;
}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment