Source code for irfpy.jdc.energy0

'''Draft energy module for JDC.

JDC performance in the proposal indicates that the energy range is
1 eV to 41 keV.  For simplicity, the full angle energy 25 keV is not considered
so much here.

The energy resolution is 12% and energy step is 128.
Indeed, these values will give "overlap" of the energy coverage.

Here, as the first example, I just do not consider the energy resolution,
just a "central value".
If the lowest energy step gives 1 eV and the highest 41 keV, the
energy resolution will be 8.65% for 128 steps.
'''
import numpy as np

[docs]def getEnergy(): ''' Return the energy table in eV. :returns: Energy table with (128,) shape :rtype: ``np.array`` >>> jdc_enestep = getEnergy() >>> print(jdc_enestep.shape) (128,) >>> print(jdc_enestep[0]) 1.0 >>> print(np.round(jdc_enestep[127],1)) 41000.0 ''' return np.logspace(0, np.log10(41000), 128)
[docs]def getRange(): ''' Return the upper and lower limit of the energy table. This provides the energy range of the specific energy step. No gap between the energy steps. :returns: Energy range table with (2, 128) shape :rtype: ``np.array`` >>> jdc_enerng = getRange() >>> print(jdc_enerng.shape) (2, 128) >>> print(jdc_enerng[:, 0]) # Energy step 0 range [0.95904599 1.04270286] >>> print(jdc_enerng[:, 1]) # Energy step 1 range [1.04270286 1.13365707] ''' etbl = getEnergy() resol = etbl[1] / etbl[0] hresol = np.sqrt(resol) etbl_l = etbl / hresol etbl_h = etbl * hresol return np.array([etbl_l, etbl_h])
[docs]def getBound(): ''' Return the bounds of the energy table. 129 elements. Energy step 0's lower bound is ``getBound()[0]``. Energy step 0's upper bound, which is identical to energy step 1's lower bound, is ``getBound()[1]``. >>> jdc_bnd = getBound() >>> print(jdc_bnd.shape) (129,) >>> print(jdc_bnd[0]) # Energy step 0 lower bound 0.959045989666 >>> print(jdc_bnd[1]) # Energy step 0 upper bound & 1 lower bound 1.04270286386 ''' r = getRange() tbl = np.zeros([129]) tbl[0] = r[0, 0] tbl[1:] = r[1, :] return tbl
import unittest import doctest
[docs]def doctests(): return unittest.TestSuite(( doctest.DocTestSuite(), ))
if __name__ == '__main__': unittest.main(defaultTest='doctests')