nu-radio / NuRadioReco

reconstruction framework for radio detectors of high-energy neutrinos
GNU General Public License v3.0
5 stars 3 forks source link

Adding traces #263

Closed christophwelling closed 3 years ago

christophwelling commented 3 years ago

With the electric fields and simChannels split up into individual traces per shower, we need an easy way to get the sum of all these traces to see what it all looks like together. With this PR, the + operator is defined for 2 BaseTrace objects to return a new BaseTrace object containing the sum of the two traces. I think using the + operator works well here, since it is convenient, doesn't require importing anything and returns what one would intuitively guess the sum of two trace objects should be. For example, plotting the sum of two traces would look like this: tr = trace_1 + trace_2 ax1.plot(tr.get_times(), tr.get_trace()) ax2.plot(tr.get_frequencies(), abs(tr.get_frequency_spectrum())

christophwelling commented 3 years ago

I managed to remove the code duplication depending on which trace starts first. Calculating the trace length is a bit more subtle (though your way to calculate the start time difference is much easier, no idea how I missed that) since the traces don't necessarily have the same length. So it could be that the length of the first trace is larger than the length of the second trace + the difference in trace start time. I added some more documentation, it should now be easier to follow what is going on. Yes, having some way to return summed traces would be useful. For E-fields it is a bit subtle since direct and reflected E-fields will have different directions so you can't just add them, but having that for the hadronic and EM part of a CC electron neutrino interaction would be really useful.