Source code for irfpy.vels.bible.energy_resolution
''' The module to calculate energy resolution.
Energy resolution is discussed in Section 5 of :ref:`vexelsbible`.
There is also a table 2 showing raw data of the resolution,
but I skipped the implementation.
'''
import math
import numpy as np
def __m0():
''' return the fitting parameter m0 in Table 3.
'''
return np.array([4.969, 4.749, 5.507, 6.063, 4.293, 5.366, 5.780, 5.735,
5.991, 4.928, 5.302, 6.190, 5.141, 5.943, 6.469, 6.347])
def __m1():
''' return the fitting parameter m1 in Table 3.
'''
return np.array([1.211, 0.998, 0.528, 0.555, 1.143, 0.724, 0.585, 0.533,
0.394, 1.098, 0.516, 0.256, 0.805, 0.626, 0.475, 0.339])
[docs]def energy_resolution(anode, energy):
''' Return the energy resolution, Delta(E)/E, for each anode and energy.
:param anode: Integer specifying the anode.
:param energy: Central energy in electron volts (eV).
:returns: Energy resultion. (Fraction. Not per-cent)
>>> print('%.3f' % energy_resolution(7, 970.000))
0.073
>>> print('%.3f' % energy_resolution(0, 11997.000))
0.099
'''
m0 = __m0()[anode]
m1 = __m1()[anode]
loge = math.log10(energy)
return (m0 + m1 * loge) / 100.
import unittest,doctest
[docs]def doctests():
return unittest.TestSuite((
doctest.DocTestSuite(),
))
if __name__=='__main__':
unittest.main(defaultTest='doctests')