Skip to content

Pre-set beamshift before FastADT to avoid missing first frame#165

Open
Baharis wants to merge 5 commits into
instamatic-dev:mainfrom
Baharis:preset_beamshift
Open

Pre-set beamshift before FastADT to avoid missing first frame#165
Baharis wants to merge 5 commits into
instamatic-dev:mainfrom
Baharis:preset_beamshift

Conversation

@Baharis

@Baharis Baharis commented Jul 18, 2026

Copy link
Copy Markdown
Member

In the current version of FastADT experiment, the loop responsible for collecting the data typically looks something like this (simplification):

movie = self.ctrl.get_movie(n_frames=len(run) - 1, exposure=run.exposure)
with self.ctrl.stage.rotation_speed(speed=rot_speed):
    self.ctrl.stage.set(a=target_alpha, wait=False)
    for step, (image, meta) in zip(run.steps, movie):
        # this code runs only after movie image is collected
        if run.has_beamshifts:
            self.ctrl.beamshift.set(step.beamshift_x, step.beamshift_y)

The beamshifts, collected and extrapolated before diffraction experiment, are applied only after the stage movement and movie collection has already started. This means that the first collected image is never preceded by any beamshift.set statement. Unless the beam randomly happens to be at a correct position, the first frame will be always empty and should be rejected.

This PR adds a new beamshift.set command just before opening the beam blank, which itself introduces small delay, so that the first image already has a beam deflected towards the starting position. Since the beam shifts can now be taken from a file following #159, it also checks if none of the beam shifts is NaN.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant