Skip to content

Slow autofocus caused by presumed mode switching #5

@drew-sinha

Description

@drew-sinha

Standard (slow) autofocus speeds seem to be improved by sync'ing nominal readout rates in acquisition scripts (i.e. Handler.PIXEL_READOUT_RATE) and autofocus.Autofocus default readout rates in a couple of ways.

  1. Mode switching the readout rate adds on approximately one second of total time for pushing+pop'ing states from the camera.

def switch_readout_rate(my_camera):
readout_rates = ('100 MHz', '280 MHz')
current_state = my_camera.get_readout_rate()
for state in readout_rates:
if state != current_state:
new_state = state
break
t0 = time.time()
my_camera.push_state(**dict(readout_rate=new_state))
t1 = time.time()
my_camera.pop_state()
t2 = time.time()

print(f'Push took {t1-t0} s')
print(f'Pop took {t2-t1} s')

'''
from scope import scope
my_scope = scope.Scope()

In [13]: switch_readout_rate(my_scope.camera)                                                                                                  
Push took 0.45039963722229004 s
Pop took 0.4796559810638428 s

'''

  1. Currently still not well understood issue in which mode switching (readout rate or otherwise) might increase both autofocusing and acquisition_sequencer runs.

(/mnt/9karray/Sinha_Drew/tests/20181121_MovementTesting acquisitions log file)

(Run with 100 MHz in acquisition script and 280 in Autofocus._CAMERA_MODE)

2018-11-28 15:02:05 INFO . Starting timepoint 2018-11-28t1502 (0 minutes after scheduled)
2018-11-28 15:02:05 INFO . Configuring acquisitions
2018-11-28 15:02:40 DEBUG . Configuration done (35.4 seconds)
2018-11-28 15:02:40 DEBUG . Range: 0.05, Steps: 2
...
2018-11-28 15:02:53 INFO . Acquiring Position: 1
2018-11-28 15:02:53 DEBUG . Stage Positioned (0.6 seconds)
2018-11-28 15:02:58 DEBUG . Autofocused (4.4 seconds)
2018-11-28 15:02:58 INFO . Autofocus z: 24.4771224
2018-11-28 15:03:00 DEBUG . Acquisition sequence run (2.7 seconds)
2018-11-28 15:03:01 DEBUG . PIXEL_READOUT_RATE = 100 MHz
2018-11-28 15:03:01 DEBUG . 2 Images Acquired (7.4 seconds)
2018-11-28 15:03:01 DEBUG . Images saved (0.0 seconds)
>2018-11-28 15:03:01 DEBUG . Position done (total: 8.0 seconds)
2018-11-28 15:03:01 INFO . Acquiring Position: 2
...
2018-11-28 15:03:09 DEBUG . Position done (total: 8.1 seconds)

(280 MHz in acquisition script and Autofocus._CAMERA_MODE)

2018-11-28 15:00:37 INFO . Starting timepoint 2018-11-28t1500 (0 minutes after scheduled)
2018-11-28 15:00:37 INFO . Configuring acquisitions
2018-11-28 15:01:15 DEBUG . Configuration done (37.7 seconds)
2018-11-28 15:01:15 DEBUG . Range: 0.05, Steps: 2
...
2018-11-28 15:01:23 INFO . Acquiring Position: 1
2018-11-28 15:01:23 DEBUG . Stage Positioned (0.6 seconds)
2018-11-28 15:01:25 DEBUG . Autofocused (1.5 seconds)
2018-11-28 15:01:25 INFO . Autofocus z: 24.5021226
2018-11-28 15:01:26 DEBUG . Acquisition sequence run (0.7 seconds)
2018-11-28 15:01:26 DEBUG . PIXEL_READOUT_RATE = 280 MHz
2018-11-28 15:01:26 DEBUG . 2 Images Acquired (2.5 seconds)
2018-11-28 15:01:26 DEBUG . Images saved (0.0 seconds)
>2018-11-28 15:01:26 DEBUG . Position done (total: 3.1 seconds)
2018-11-28 15:01:26 INFO . Acquiring Position: 2
...
2018-11-28 15:01:29 DEBUG . Position done (total: 3.2 seconds)

However, note this alternate run after the above where the mode switching should have been happening:

2018-11-28 16:47:11 INFO . Starting timepoint 2018-11-28t1647 (0 minutes after scheduled) YET again.
(DS autofocus.camera_mode=280 MHz)
2018-11-28 16:47:11 INFO . Configuring acquisitions
2018-11-28 16:47:44 DEBUG . Configuration done (33.5 seconds)
2018-11-28 16:47:44 DEBUG . Range: 0.05, Steps: 2
2018-11-28 16:47:44 INFO . Acquiring Position: 0
...
2018-11-28 16:47:52 INFO . Acquiring Position: 1
2018-11-28 16:47:53 DEBUG . Stage Positioned (0.6 seconds)
>2018-11-28 16:47:53 DEBUG . Camera readout rate: 100 MHz
2018-11-28 16:47:54 DEBUG . Autofocused (1.7 seconds)
2018-11-28 16:47:54 INFO . Autofocus z: 24.17737872839587
2018-11-28 16:47:55 DEBUG . Acquisition sequence run (0.8 seconds)
2018-11-28 16:47:55 DEBUG . PIXEL_READOUT_RATE = 100 MHz
2018-11-28 16:47:55 DEBUG . 2 Images Acquired (2.7 seconds)
2018-11-28 16:47:55 DEBUG . Images saved (0.0 seconds)
2018-11-28 16:47:55 DEBUG . Position done (total: 3.3 seconds)
2018-11-28 16:47:55 INFO . Acquiring Position: 2
...
2018-11-28 16:47:59 DEBUG . Position done (total: 3.5 seconds)

The converse has also occurred where readout rate mode switching should not have been occurring and autofocus returns to the nominal 4 sec (+ 2 sec sequencer run). This aspect of the issue still has yet to be understood.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions