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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

umux: phase unwrap should only apply during triggering #177

Open
ggggggggg opened this issue Jan 16, 2020 · 7 comments
Open

umux: phase unwrap should only apply during triggering #177

ggggggggg opened this issue Jan 16, 2020 · 7 comments
Labels

Comments

@ggggggggg
Copy link
Collaborator

In MATTER phase correction could lead to baseline shifts, which are undesirable. In DASTARD currently we have a matter like algorithm with the additional feature of not letting a phase offset persist for a long time. The correct phase offset in a flat pretrigger mean is always zero, so there is no value in keeping track of a phase offset over time. The only time we should consider phase correction is on the rising edge of a pulse, this will both be more computationally efficient and simplify the code.

@joefowler
Copy link
Member

To make this issue a little less confusing, let me point out that "phase correction" here does not refer to the analysis step of correcting for sub-sample arrival time.

It means the addition of integer multiples of 2π in a µMUX system to account for full cycles of 2π that were presumed to be lost due to large slew rates.

Are you suggesting that this algorithm that adds multiples of 2π be run only after the trigger point, and only after trigger criteria have been met? I agree that this would be more efficient, though I am not sure how it would simplify the code. Are you sure that tracking the amount of added phase across long times is truly unnecessary? Let's make sure to discuss with our local expert, @danbek before we conclude this!

@ggggggggg ggggggggg changed the title umux: phase correction should only apply during triggering umux: phase unwrap should only apply during triggering Jan 16, 2020
@joefowler
Copy link
Member

Hey. Just discussed this over cookies with Mazsi and Ben. While your idea seems like a reasonable proposal, Mazsi was keen to do the unwrapping in firmware. Obviously that would be ideal.

If firmware-unwrapping can happen soon, then we don't want to invest any effort in making software unwrapping more efficient, because that would be a dead end.

(On the other hand, no one seemed to think that your idea of unwrapping only after triggering was obviously unworkable. One challenge might be that it makes the trigger computation a lot more branch-y, if we stick to the traditional filters that compare 4 or more samples.)

@DarkTyr
Copy link

DarkTyr commented Jan 17, 2020 via email

@joefowler
Copy link
Member

Don't worry! We already have a working version of phase unwrapping in Dastard. The issue is only that phase unwrapping demands a measurable proportion of Dastard's total CPU load (though with smarter code, we did improve this from a massive load to a modest load back in early or mid-2019). We are worried that this could eventually be an obstacle to running larger arrays with higher sampling rates. (Why isn't this a concern with the NDFB server? I think it will be, if compared at equal array sizes and sample rates.)

One way to avoid this obstacle is to trigger on still-wrapped data (somehow), then unwrap only the triggered records (as Galen proposes here). But in the limit of high photon rates, and potentially with variable-length records, you'd still be unwrapping much of the data, as triggered records comprise an ever-higher fraction of all data.

A different way to avoid it is to unwrap phase in the firmware. Just hoping the electronics team will keep this possibility in mind. Of course we'll make Abaco+Dastard work without waiting for this feature.

@ggggggggg
Copy link
Collaborator Author

This is also looking forward to implementing Kelsey's ideas about how to unwrap in the presence of a high slew rate, and my understanding of the algorithm is that it depends on knowing there was a trigger event. So unwrapping after trigger may be either helpful or required to handle higher slew rates.

@joefowler
Copy link
Member

I just discussed this with Kelsey. I think you're right. As I understand it now, you could consider her idea as a supplement, done after triggering has already been performed. So in the long term, we might have phase unwrapping done in multiple places. The basic, biased unwrapping could be done either in firmware or in Dastard. Kelsey's rising-edge correction could then be an improvement on that, done in software only after triggers are found.

@ggggggggg
Copy link
Collaborator Author

We also talked about in firmware measuring the slew rate at the "mix" step. Then we could test simple algorithm like "if slew rate ? threshold add twopi".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants