Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add PumpProbePulses for combined FEL/PPL pulse patterns #24

Merged
merged 2 commits into from
Dec 5, 2023

Conversation

philsmt
Copy link
Collaborator

@philsmt philsmt commented Jul 21, 2023

The third component in the mix for pump-probe experiments 馃敠

  • Combines FEL and PPL pulses into a single linear pattern
  • Move PPL pulses to their true location by fixed bunch table position or relative bunch table/pulse distance to first FEL pulse
  • Extends the MultiIndex by two boolean fields fel and ppl to distinguish between respective shots

@philsmt
Copy link
Collaborator Author

philsmt commented Aug 15, 2023

Re-implemented this now on top of the new PulsePattern based on Pulse IDs, which made the code much simpler. It still makes use of the in8-view trick, but only ofr the purpose of pattern comparisons.

Ready for review now with tests.

@philsmt philsmt marked this pull request as ready for review August 15, 2023 12:49
Copy link
Member

@JamesWrigley JamesWrigley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly being very nitpicky about typos 馃攳 This should also be documented in components.md and have a changelog entry.

src/extra/components/pulses.py Outdated Show resolved Hide resolved
src/extra/components/pulses.py Outdated Show resolved Hide resolved
src/extra/components/pulses.py Outdated Show resolved Hide resolved
src/extra/components/pulses.py Outdated Show resolved Hide resolved
src/extra/components/pulses.py Outdated Show resolved Hide resolved
src/extra/components/pulses.py Outdated Show resolved Hide resolved
src/extra/components/pulses.py Show resolved Hide resolved
@philsmt
Copy link
Collaborator Author

philsmt commented Aug 17, 2023

Thanks! Somehow I'm still forgetting to document the changes.

Copy link
Member

@JamesWrigley JamesWrigley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd add an internal comment about super() (#24 (comment)), but otherwise LGTM!

@philsmt
Copy link
Collaborator Author

philsmt commented Aug 17, 2023

I hope I didn't get carried away in 24400ea 馃榿

@JamesWrigley
Copy link
Member

A thing of beauty 馃槅

@JamesWrigley
Copy link
Member

I sneakily used this for MID's experiment. It's pretty darn sweet, I found exactly what I was looking for in two lines of code 馃構

Also found some edge-cases:

  • For some runs (e.g. p4451, run 78) there were more laser pulses configured than FEL pulses, which was slightly confusing when plotting the pulse pattern because there would be more points than pulses:
    image

    What I'm typically looking for is the combination of FEL/PPL pulses, so what if peek_pulse_ids() had something like a only_with_fel=True argument to drop PPL pulses without an FEL pulse?

  • PumpProbePulses._get_ppl_offset() fails if the pulse offset is specified and there's only one pulse (e.g. p4451, run 80), because on line 923 it tries to look at the second pulse. I worked around it with:

         elif self._pulse_offset is not None:
    -         return fel[0] + int((fel[1] - fel[0]) * self._pulse_offset)
    +        if len(fel) > 1:
    +            return fel[0] + int((fel[1] - fel[0]) * self._pulse_offset)
    +        else:
    +            return fel[0]

@philsmt
Copy link
Collaborator Author

philsmt commented Aug 28, 2023

Awesome, happy to hear!

  • For some runs (e.g. p4451, run 78) there were more laser pulses configured than FEL pulses, which was slightly confusing when plotting the pulse pattern because there would be more points than pulses:
    [img]
    What I'm typically looking for is the combination of FEL/PPL pulses, so what if peek_pulse_ids() had something like a
    only_with_fel=True argument to drop PPL pulses without an FEL pulse?

Would you have the same result with pp_pulses.peek_pulse_ids()[:, True], i.e. all pulses with fel=True?

  • PumpProbePulses._get_ppl_offset() fails if the pulse offset is specified and there's only one pulse (e.g. p4451, run 80), because on line 923 it tries to look at the second pulse. I worked around it with:
         elif self._pulse_offset is not None:
    -         return fel[0] + int((fel[1] - fel[0]) * self._pulse_offset)
    +        if len(fel) > 1:
    +            return fel[0] + int((fel[1] - fel[0]) * self._pulse_offset)
    +        else:
    +            return fel[0]

Hmm, but that moves the PPL pulses for pulse_offset != 0 to a different position then expected. The offset cannot be inferred in units of pulses if there is always only a single pulse (for intermittent cases there's extrapolate=True), unless we'd add a manual override for repetition rate in such a case.

@JamesWrigley
Copy link
Member

Would you have the same result with pp_pulses.peek_pulse_ids()[:, True], i.e. all pulses with fel=True?

Ah yes that's perfect, NVM then. I didn't realize you could index multiindex's like that.

Hmm, but that moves the PPL pulses for pulse_offset != 0 to a different position then expected. The offset cannot be inferred in units of pulses if there is always only a single pulse (for intermittent cases there's extrapolate=True), unless we'd add a manual override for repetition rate in such a case.

Hmm I see, indeed that didn't matter last week because the pulse offset was always 0. What if the constructor checked for there only being one pulse and pulse_offset != 0 and threw an error if so? The point being to warn the user immediately.

@philsmt
Copy link
Collaborator Author

philsmt commented Dec 5, 2023

I'll take James' earlier LGTM to finally get this in.

@philsmt philsmt merged commit 4be38d2 into master Dec 5, 2023
4 checks passed
@philsmt philsmt deleted the feat/pumpprobe-pulses branch December 5, 2023 11:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants