Nebula electron file format

By "electron file format", we mean both the input format of primary electrons, and the output format of detected electrons. It is a binary file format.

Each electron is described by nine numbers. The first seven are its x,y,z coordinates (in nm), its direction vector (the length is not neccesarily one), and the energy in eV. The last two numbers are integers that can be used to "tag" an electron, and are free to choose by the user. If an electron creates a secondary electron during the simulation, this secondary electron will get the same two tags. For example, these tags can be used for the x and y pixel indices of a SEM image.

The first seven numbers are supplied as 32-bit floating point numbers. The tags are 32-bit signed integers. The endianness is the same as the system you are running on.

If you are working with python, the relevant numpy datatype is the following:

import numpy as np

electron_dtype = np.dtype([
    ('x',  '=f'),
    ('y',  '=f'),
    ('z',  '=f'),
    ('dx', '=f'),
    ('dy', '=f'),
    ('dz', '=f'),
    ('E',  '=f'),
    ('px', '=i'),
    ('py', '=i')])

Example scripts showing how to read and write electron files are provided with the tutorials and in the scripts repository.