============
MEX ELS data
============

1. Import the modules :mod:`irfpy.mels.scidata` and :mod:`irfpy.mels.calpds`.

.. code-block:: python

        from irfpy.mels import scidata as melsdata    # Science data
        from irfpy.mels import calpds as melscal      # Calibration information

2. Use following functions to get the data.

- :func:`irfpy.mels.scidata.get_counts` for counts per sample (#).
- :func:`irfpy.mels.scidata.get_cps` for count rate (#/s).
- :func:`irfpy.mels.scidata.get_dnf` for differential number flux (#/cm^2 s sr eV)
- :func:`irfpy.mels.scidata.get_def` for differential energy flux (eV/cm^2 s sr eV)

3. Getting the energy 

Use :attr:`irfpy.mels.calpds.simple_energy_table` for the simplest energy table.

.. code-block:: python

        ene_table = melscal.simple_energy_table    # (128,) array
        print(ene_table)
        # -> 
        # [  2.02963250e+04   1.86854999e+04   1.72085074e+04   1.58455004e+04
        #    1.45915427e+04   1.34367108e+04   1.23710885e+04   1.13946903e+04
        # ....
        # ]



The channel dependent energy table (shape of ``(128, 16)``) is obtained 
by :attr:`irfpy.mels.calpds.energy_table`.

.. code-block:: python

        ene_table_chdep = melscal.energy_table     # (128, 16) array


4. How to convert from the count rate to the differential flux manually.

People can usually use the function :func:`irfpy.mels.scidata.get_dnf` to get the differential
number flux of electrons.

Alternatively, to make the conversion from counts to differential flux, one may use
the table at :attr:`irfpy.mels.calpds.cnt2dnf`.


.. note::

        The above functions only support 128 energy step mode, not for 32 energy  step mode.