Exemple #1
0
def determine_rotation_axis(camera, shutter, flat_motor, rotation_motor, flat_position,
                            radio_position):
    """Determine tomographic rotation axis using *camera*, *shutter*, *rotation_motor* and
    *flat_motor* devices.  *flat_position* is the position for making a flat field, *radio_position*
    is the position with the sample in the field of view.
    """
    dark = acquire_dark(camera, shutter).result().astype(np.float32)
    flat = acquire_image_with_beam(camera, shutter, flat_motor, flat_position).result()
    first = acquire_image_with_beam(camera, shutter, flat_motor, radio_position).result()
    rotation_motor.move(180 * q.deg).join()
    last = acquire_image_with_beam(camera, shutter, flat_motor, radio_position).result()

    # flat correct
    flat_corr_first = flat_correct(first, flat, dark=dark)
    flat_corr_last = flat_correct(last, flat, dark=dark)

    return compute_rotation_axis(flat_corr_first, flat_corr_last)
Exemple #2
0
def determine_rotation_axis(camera, shutter, flat_motor, rotation_motor,
                            flat_position, radio_position):
    """Determine tomographic rotation axis using *camera*, *shutter*, *rotation_motor* and
    *flat_motor* devices.  *flat_position* is the position for making a flat field, *radio_position*
    is the position with the sample in the field of view.
    """
    dark = acquire_dark(camera, shutter).result().astype(np.float32)
    flat = acquire_image_with_beam(camera, shutter, flat_motor,
                                   flat_position).result()
    first = acquire_image_with_beam(camera, shutter, flat_motor,
                                    radio_position).result()
    rotation_motor.move(180 * q.deg).join()
    last = acquire_image_with_beam(camera, shutter, flat_motor,
                                   radio_position).result()

    # flat correct
    flat_corr_first = flat_correct(first, flat, dark=dark)
    flat_corr_last = flat_correct(last, flat, dark=dark)

    return compute_rotation_axis(flat_corr_first, flat_corr_last)
Exemple #3
0
    def get_frames():
        frames = []
        for i in range(num_frames):
            rotation_motor.move(step).join()
            camera.trigger()
            frame = camera.grab().astype(np.float)
            if flat is not None:
                frame = flat_correct(frame, flat, dark=dark)
            if frame_consumer:
                frame_consumer.send(frame)
            frames.append(frame)

        return frames
Exemple #4
0
    def get_frames():
        frames = []
        for i in range(num_frames):
            rotation_motor.move(step).join()
            camera.trigger()
            frame = camera.grab().astype(np.float)
            if flat is not None:
                frame = flat_correct(frame, flat, dark=dark)
            if frame_consumer:
                frame_consumer.send(frame)
            frames.append(frame)

        return frames
Exemple #5
0
async def acquire_frames_360(camera,
                             rotation_motor,
                             num_frames,
                             shutter=None,
                             flat_motor=None,
                             flat_position=None,
                             y_0=0,
                             y_1=None):
    """
    acquire_frames_360(camera, rotation_motor, num_frames, shutter=None, flat_motor=None,
                       flat_position=None, y_0=0, y_1=None)

    Acquire frames around a circle.
    """
    flat = None
    if await camera.get_state() == 'recording':
        await camera.stop_recording()
    await camera['trigger_source'].stash()
    await camera.set_trigger_source(camera.trigger_sources.SOFTWARE)

    try:
        async with camera.recording():
            if shutter:
                if await shutter.get_state() != 'closed':
                    await shutter.close()
                await camera.trigger()
                dark = (await camera.grab())[y_0:y_1]
                await shutter.open()
            if flat_motor and flat_position is not None:
                radio_position = await flat_motor.get_position()
                await flat_motor.set_position(flat_position)
                await camera.trigger()
                flat = (await camera.grab())[y_0:y_1]
                await flat_motor.set_position(radio_position)
            for i in range(num_frames):
                await rotation_motor.move(2 * np.pi / num_frames * q.rad)
                await camera.trigger()
                frame = (await camera.grab())[y_0:y_1].astype(np.float)
                if flat is not None:
                    frame = flat_correct(frame, flat, dark=dark)
                    frame = np.nan_to_num(-np.log(frame))
                    # Huge numbers can also cause trouble
                    frame[np.abs(frame) > 1e6] = 0
                else:
                    frame = frame.max() - frame
                yield frame
    finally:
        # No side effects
        await camera['trigger_source'].restore()