-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Optionally use negative pulse indices for PPL-only DLD pulses #167
Conversation
b628f4b
to
1f4525e
Compare
When I first glanced at the title, I was thinking of a scenario where all your pump-only pulses come before the first X-ray pulse. In that specific case, it would be natural to use negative indices like:
Obviously that doesn't work neatly in other scenarios, like the one in your tests. But if this scenario does occur, I wonder if it will be confusing to people that the order is:
I don't think there's anything we can do about that, but I thought I'd mention it in case it gives you a great idea. 😉 |
for i, tid, row in zip(range(len(triggers)), train_ids, triggers): | ||
if tid != prev_tid: | ||
prev_tid = tid | ||
only_ppl_index = -1 | ||
with_fel_index = 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's probably a way to do this neatly with itertools.groupby()
to have an outer loop over train IDs. It's also not a big deal, though - I know you want to get this out quickly, and I think this code works fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried
for train_id, vals in groupby(enumerate(triggers), lambda x: train_ids[x[0]]):
only_ppl_index = -1
with_fel_index = 0
for i, trigger in vals:
if trigger['ppl'] and not trigger['fel']:
pulse_indices[i] = only_ppl_index
only_ppl_index -= 1
else:
pulse_indices[i] = with_fel_index
with_fel_index += 1
but it made the overall call to pulse_ids()
about 15% slower. While I suspect the grouping itself is faster, the nested loops seem to end up taking more time due to constructing the necessary generators.
Other than that, LGTM |
1f4525e
to
143e541
Compare
The
PumpProbePulses
component and its spiritual predecessorDldPulses
combine FEL-only, PPL-only and pumped pulses into a single consistent pattern, i.e. may have more pulses than a pure FEL pattern in the presence of PPL-only pulses.While this is useful for analysis, it presents problems when correlating FEL-only data using enumerated indices to label pulses. The XGM component e.g. will only ever look at pulses with FEL (either FEL-only or pumped) and enumerate accordingly, being incompatible with the integrated pattern.
While this can be fixed by using global pulse IDs (i.e. referring to indices in the machine pattern table), the use of pulse indices is still often desired and/or easier to obtain. This PR adds an optional flag to
DldPulses
(only for now, can be ported toPumpProbePulses
) to modify the enumeration behaviour:The resulting indices are again compatible with PPL-unaware pulse indices, while still containing the PPL-only pulses.
Examples:
0, 1, 2, 3, 4, 5
becomes-1, -2, 0, 1, 2, 3
0, 1, 2, 3, 4, 5, 6, 7
becomes-1, -2, 0, 1, 2, 3, -3, -4
Also fixes a minor bug with the preceding #166 to ensure indexes are compatible, and simplifies passing custom arguments to construct the internal pulse information with
DelayLineDetector
.