nu-radio / NuRadioMC

A Monte Carlo simulation package for radio neutrino detectors
GNU General Public License v3.0
35 stars 35 forks source link

Unnecessary ffts in BaseTrace class #737

Open fschlueter opened 1 month ago

fschlueter commented 1 month ago

When looking at the base_trace.py class it seems to me that we unnecessarily "resetting" either the time domain trace or frequency spectrum with the goal of "to much security".

In the getter functions get_trace() and get_frequency_spectrum() we set the other representation to None. This of course avoids to store "the same data twice" but unless we perform any operation on either of them we have to perform unnecessary FFTs if we back and forth request both representations. Since we only can change the data with the setter function (we only return copies of the arrays in the getter functions) it would be sufficient to only set the other representation to None in the setter functions.

However, as I said this will increase memory consumption. Is that a limiting factor and the reason for the current implementation or did I miss something? Maybe @cg-laser, @shallmann or @sjoerd-bouma

cg-laser commented 1 month ago

we should loop in @christophwelling . We added more security due to unintended changes by reference that could occur otherwise.

fschlueter commented 1 month ago

I see, but I think the copy calls in the getter functions should prevent this. We could also add unit tests to catch this