Repository navigation
Conversation
| pulse_index=inputs["pulse_index"], | ||
| pulse_period=inputs["pulse_period"], | ||
| ) | ||
| del inputs |
There was a problem hiding this comment.
Instead of manual memory management, can you extract inputs = ...; wavs = ... into a separate function?
There was a problem hiding this comment.
Is that really easier? That del is just a small optimization
There was a problem hiding this comment.
It's more about clarity. Local variables with a small scope are usually easier to understand than large scopes with variables appearing and disappearing. Plus, there seem to be multiple distinct operations in this function if you can discard part of the data early.
There was a problem hiding this comment.
I've split it into separate functions now.
| .bins.constituents["data"] | ||
| .to(unit=etz_unit, copy=False) | ||
| ) | ||
| da.coords["event_time_zero"] |
There was a problem hiding this comment.
I thought the suggested fix in the related issue was about copying the event_time_zero on every event; something that is done when loading the detector events but not the monitor events?
There was a problem hiding this comment.
I think you're right about that. We can do it like that, but it would increase memory usage unnecessarily in cases that don't need event_time_zero (no wavelength computation, no pulse stride etc).
There was a problem hiding this comment.
I guess your thinking was that the monitor does not have logical dimensions so we can just keep it binned in event_time_zero.
And that is true that we save some memory this way.
However, I think it would make things easier to use if the data from detectors and monitors looked the same? Users wouldn't have to think too hard about whether it's detector or monitor data, and do different operations accordingly.
It would also be easier to write generic code (just like the changes in this PR would not have been needed).
That said, many monitors will record in histogram mode and will look different anyway. So maybe it does not matter too much? But for instruments who plan to often switch between event and histogram mode, it might be nice with only 2 forms of data to deal with instead of 3?
Finally, I think there are one or two monitors that do have more than one pixel?
There was a problem hiding this comment.
I'd be very careful about doing this for every monitor. Event monitors can get massive, so compute/memory impact can be substantial. I thought doing it conditionally only of there is a pulse stride > 1 was a good approach.
Monitors with pixels: Yes, at Loki for example, but iirc that is to judge beam profile and would not need to be handled per pixel in a reduction workflow. But I am probably wrong.
There was a problem hiding this comment.
I thought doing it conditionally only of there is a pulse stride > 1 was a good approach.
So you wanted to go with the current implementation or copy the event_time_zero on the events if pulse stride > 1?
I don't mind ether way, was just curious.
There was a problem hiding this comment.
You mean event_time_zero vs pulse_index? Note sure, my point was about doing it only when actually needed.
But maybe what you say is right after all: We might not needed event_time_zero now, but we might as soon as we need to implement more filtering etc.?
There was a problem hiding this comment.
I didn't think immediately about event filtering... but I guess you are right.
When you are filtering based on time, you often need to filter events based on where they were along the beam path at a given time.
This implies that it would be wavelength-dependent, and you then most probably need a time per event?
Or can you still do that without putting a time zero on every event?
There was a problem hiding this comment.
If we later decide to add event_time_zero to monitor events, possibly conditional on it being required by the workflow, that will also work. This PR just makes sure it works also in case you didn't add event_time_zero to the events. I think that is reasonable.
Fixes #750