irfpy.cena.empirical_lib
¶
This is a module to support irfpy.cena.empirical
.
This module is a helping module for irfpy.cena.empirical
,
thus users do not need to understand.
There is an interface to fit the observed count rate to the
parameters in irfpy.cena.empirical
.
The module was copied from
110301-Paper-CenaEnergySpectra/script/average_spectra_general/src/scripts/avs5_fitting2.py
.
Then, refactored.
Below is the original comments.
The count data is fitted by any parametric functions.
You can define the parametric functions as you want.
See flux_function_maxwell()
as an example.
- irfpy.cena.empirical_lib.flux_function_maxwell(parameters, energy_in_eV)[source]¶
A general function following maxwell.
The function returns the values corresponding the given parameters and energy. Both parameters should be the np.array or np.ma.array.
Returned is the np.array or np.ma.array.
The formulation in J(E) is:
\[J(E) = p_0^2 E \exp(-\frac{E}{p_1^2})\]The squares limit the parameters positive.
If you compare with the data measured in MKSA,
\[\begin{split}p_0^2 = \frac{2E}{m^2} n (\frac{m}{2 \pi k T})^{3/2} \\ p_1^2 = \frac{2kT}{m}\end{split}\]If converting to eV and cm unit, which may be used more widely in the plasma physics,
\[\begin{split}p_0^2 = \frac{q^2}{m^2} 200 n (\frac{m}{2 \pi q T})^{3/2} \\ p_1^2 = T\end{split}\]or,
\[\begin{split}T \mathrm{[eV]} = p_1^2 \\ n \mathrm{[cm}^{-3}\mathrm{]} = \frac{m^2}{200 q^2} (2 \pi q p_1^2)^{3/2} \times p_0^2\end{split}\]
- irfpy.cena.empirical_lib.maxwell_parameter_to_physical_values(p0, p1)[source]¶
From the best fit paramter, you may get temperateure and density.
- class irfpy.cena.empirical_lib.flux_cena_background(ch)[source]¶
Bases:
object
To make function following the constant background.
This is not physical, but sometimes embedded in the data.
parameter
should be np.array with (1, ) shape. The square of the parameter is the corresponding background.The function should return continuous function as energy_in_eV is arbitrary. However, in a practical use, energy_in_eV only receive the specific values which we get from energy.getEnergyE16() method.
Thus, one count level using cena_flux.Count2Flux() is used, and the linear interpolation is used for the internal values.
- class irfpy.cena.empirical_lib.flux_function_maxwell_bg(ch)[source]¶
Bases:
object
A general function following maxwell, together with flat count rate.
The function returns the values corresponding the given parameters and energy. Both parameters should be the np.array or np.ma.array.
Returned is the np.array or np.ma.array.
- irfpy.cena.empirical_lib.flux_thompson_sigmund_free(parameters, energy_in_eV)[source]¶
Tompson sigmund formulae.
Two parameters, which was defined indeed by the binding energy and the mass ratio between the projectile and the target physically.
However, this function assumes they are parameters.
Coefficient is also a parameter.
\[f(E) = p_0 \frac{E}{(E + p_1^2)^3} (1-\sqrt{\frac{E + p_1^2}{p2^2}})\]This looks the distribution function, not the differential flux.
\[J(E) = \frac{v f(E)}{\sin\alpha}\]so,
\[J(E) = p_0 \frac{E^{3/2}}{(E + p_1^2)^3} (1-\sqrt{\frac{E + p_1^2}{p2^2}})\]For practical reason, p_1 and p2 given are squared to keep the resulting paramters positive.
- irfpy.cena.empirical_lib.flux_function_shifted_maxwell(parameters, energy)[source]¶
A function following “shifted” maxwell.
Three parameters.
\[p_0 \exp( - \frac{(\sqrt{E} - \sqrt{p2})^2}{p_1})\]p0 includes information of temperature and density. p1 is the temperature itself (in the unit of eV). p2 is the bulk energy in eV. It can be converted to the velocity as vb = sqrt(2q/m * p[2]) ~ 13.6 km/s sqrt(E [eV]) in MKSA units for hydrogen.
- irfpy.cena.empirical_lib.flux_bipower(parameters, energy)[source]¶
Bipower law
Four parameters.
\[J(E) = \mathrm{min}(p_0 E^{p_1}, p_2 E^{p_3})\]
- irfpy.cena.empirical_lib.flux_function_linear(parameters, energy_in_eV)[source]¶
A general function following the linear function, as a test.
- irfpy.cena.empirical_lib.run_fitting(cnts, ch, fitfunc, initial_parameter)[source]¶
Main function to run the fitting.
- Parameters
cnts (
np.ma.MaskedArray
) – An array of counts, which is to be fitted.ch (
int
) – The channel observed.fitfunc (
function
orcallable
.) – A parametric function to fit the data.
- Returns
(best_parameter, success_code, bestfit_function, loglikely)
This fit the given counts by the given fitting function.