lentil.detector.cosmic_rays(shape, pixelscale, ts, rate=40000.0, proton_flux=1000000000.0, alpha_flux=4000000000.0)[source]

Cosmic ray generator for simulating cosmic ray hits on a detector.

The default values for cosmic ray rates and electron fluxes are taken from [1]. It is commonly accepted at about 90% of cosmic rays are protons and the majority of the remaining 10% are alpha particles [1], [2].

  • shape (array_like) – Frame size defined as (rows, cols)

  • pixelscale (array_like) – Pixel dimensions as (y,x,z) where z is the pixel depth

  • ts (float) – Integration time in seconds

  • rate (float, optional) – Cosmic ray rate expressed as number of events per square meter of detector area. Default is 40000 hits/m^2.

  • proton_flux (float, optional) – Number of electrons liberated per meter of travel for a proton. Default is 1e9 e-/m.

  • alpha_flux (float, optional) – Number of electrons liberated per meter of travel for an alpha particle. By definition, alpha particles have four times the energy of protons. Default is 4e9 e-/m.


cosmic_e – Array representing the number of electrons in a detector image due to cosmic ray hits

Return type



Simulate the cosmic ray hits for a 2000 second exposure over a 256 x 256 detector patch with 5 um x 5 um x 3 um pixels:

>>> import matplotlib.pyplot as plt
>>> import lentil
>>> cosmic_frame = lentil.detector.cosmic_rays((256,256), (5e-6, 5e-6, 3e-6), 2000)
>>> plt.imshow(cosmic_frame, origin='lower')


[1] Offenberg, J.D. et. al. Multi-Read Out Data Simulator. (2000).

[2] Cosmic ray - Wikipedia