irfpy.vels.bible.energy

The energy table for VEX/ELS.

The simplest way of getting energy table is using get_table_128() and get_table_32(). They return a numpy array with element of (nstep, 16), where nstep is the number of energy step (128 and 32 respectively).

>>> etbl128 = get_table_128()
>>> print(etbl128.shape)
(128, 16)
>>> etbl32 = get_table_32()
>>> print(etbl32.shape)
(32, 16)
irfpy.vels.bible.energy.tm2ref_l(tm)[source]

Function converting TM raw value to reference voltage (low).

See equation (3) in VEX/ELS bible.

irfpy.vels.bible.energy.tm2ref_h(tm)[source]

Function converting TM raw value to reference voltage (low).

See equation (3) in VEX/ELS bible.

irfpy.vels.bible.energy.tm2ref(tm)[source]

Convert TM raw value to reference voltage.

To accompany both low and high power supply, a trick is used: For negative tm, low power supply is used and for positive tm, high power supply is used.

Thus, simple logic is used like:

if tm < 0:
    return tm2ref_low(-tm)
else:
    return tm2ref_high(tm)

See also tm2ref_l() and tm2ref_h().

>>> tm2ref(-100) == tm2ref_l(100)
True
>>> tm2ref(100) == tm2ref_h(100)
True
class irfpy.vels.bible.energy.EnergyTable[source]

Bases: object

Base class of energy table.

This class is an implementation of section 7 of VEX/ELS bible.

Note

There is a little bit difference in the table and the calculated value. However the difference is very small, so I do not think it matters our science.

This class is considered as a base class for each implemented ELS energy table. To make the child class, following method should be implemented.

  • self.tmidx(self)

  • self.nstep(self)

energy(estep, anode, fill_flyback=nan)[source]

Return the energy for the specified energy step and anode.

energy_table(fill_flyback=nan)[source]

Return the energy table.

Parameters

fill_flyback – Value to fill the flyback energy step.

Returns

The energy table.

Return type

np.array with nstep x16 elements.

nstep()[source]

Return the number of the energy step.

tmidx()[source]

Return a nstep element nparray of TM value.

Negative for low power suppy is employed to use tm2ref().

class irfpy.vels.bible.energy.EnergyTable128[source]

Bases: irfpy.vels.bible.energy.EnergyTable

Energy table class for 128 energy step mode.

This class is an implementation of section 7 of VEX/ELS bible.

Flyback energy step looks step-0.

Todo

Check the flyback energy step.

A simple usage is

>>> tbl = EnergyTable128()
>>> print("%.3f" % tbl.energy(15, 5))
3.158
>>> print("%.3f" % tbl.energy(100, 10))
3299.235
>>> print(tbl.energy(0, 5))
nan
nstep()[source]

Return the number of the energy step.

tmidx()[source]

Return a 128 element nparray of TM value.

Negative for low power suppy is employed to use tm2ref().

class irfpy.vels.bible.energy.EnergyTable32[source]

Bases: irfpy.vels.bible.energy.EnergyTable

Energy table class for 32 energy step mode.

See EnergyTable128 for details.

>>> tbl = EnergyTable32()
>>> print(tbl.energy_table().shape)
(32, 16)
>>> print('%.2f' % tbl.energy(0, 5))
nan
>>> print('%.2f' % tbl.energy(10, 15))
22.40
nstep()[source]

Return the number of the energy step.

tmidx()[source]

Return a TM reference values for 32 step mode

irfpy.vels.bible.energy.get_table_128(fill_flyback=nan)[source]

Get the energy table for 128 energy step mode.

Parameters

fill_flyback – Value to fill the flyback energy step.

>>> tbl = get_table_128()
>>> print(tbl.shape)
(128, 16)
>>> print('%.3f' % tbl[66, 6])  # Return the energy of anode 6, energy step 66.
215.189
irfpy.vels.bible.energy.get_table_32(fill_flyback=nan)[source]

Get the energy table for 128 energy step mode.

Parameters

fill_flyback – Value to fill the flyback energy step.

>>> tbl = get_table_32()
>>> print(tbl.shape)
(32, 16)
>>> print('%.3f' % tbl[26, 7])  # Return the energy of anode 6, energy step 66.
143.248
irfpy.vels.bible.energy.doctests()[source]