* Change to the `PhotoElectrons[1208]` object: store photoelectrons and amplitudes in 1d-arrays together with an array of pixel ids instead of lists of lists. This brings a considerable performance improvement, both for reading this data from simtel files and for dealing with the data.
See https://numpy.org/doc/stable/reference/generated/numpy.ufunc.at.html for how to do operations on these pairs of indices / values arrays, e.g. to compute the mean arrival time in each pixel, you could use:
python
def mean_at(n, array, indices):
mean = np.zeros(len(n))
np.add.at(mean, indices, array)
avoid divide by zero warning
mask = n > 0
mean[mask] /= n[mask]
mean[~mask] = np.nan
return mean
mean_time = mean_at(pe['photoelectrons'], pe['time'], pe['pixel_id'])
* The `photon_counts` field of the `PhotoElectrons[1208]` object was renamed to `photons`
Thanks watsonjj for implementing this in https://github.com/cta-observatory/pyeventio/pull/207