60 lines
2.4 KiB
Python
60 lines
2.4 KiB
Python
if (get_exec_pars().source == CommandSource.ui) and (get_exec_pars().script == "AutoFocus") :
|
|
SCAN_TYPE = "all"
|
|
RANGE_OBJ = 2.0
|
|
STEP_OBJ = 0.2
|
|
RANGE_STIG = 20.0
|
|
STEP_STIG = 2.0
|
|
UPDATE_POSITION = True
|
|
AVERAGE = 1
|
|
RUNS = 1
|
|
width, height = eiger.getImageSize()
|
|
RENDERER = None
|
|
ROI = Rectangle(width/3, height/3, width/3, height/3,)
|
|
EXPOSURE = None
|
|
|
|
print "Auto Focus: ", SCAN_TYPE, RANGE_OBJ, STEP_OBJ, RANGE_STIG , STEP_STIG, UPDATE_POSITION, AVERAGE, RUNS, ROI, EXPOSURE
|
|
|
|
initial_state = objective.read(),obj_stig_a.read(),obj_stig_b.read()
|
|
print "Initial state:" , initial_state
|
|
set_focus_scan_roi(ROI, RENDERER)
|
|
|
|
if not get_dry_run() and str(get_setting("AUTO_SWITCH_VALVE")).lower() == "true":
|
|
open_vg10()
|
|
if not get_dry_run() and str(get_setting("AUTO_SWITCH_SHUTTER")).lower() == "true":
|
|
caput(FAST_SHTR, 'Open')
|
|
|
|
former_exposure = None
|
|
try:
|
|
init_eiger(exposure=EXPOSURE)
|
|
if EXPOSURE:
|
|
#former_exposure = eiger.getExposure()
|
|
#if former_exposure!=EXPOSURE:
|
|
# set_exposure_time(EXPOSURE)
|
|
grab_frame(image, None, True) #Update reference image if changing exposure
|
|
|
|
for run_no in range(RUNS):
|
|
if SCAN_TYPE in ("all", "obj"):
|
|
#print "Scan obj"
|
|
r=scan_focus(objective, RANGE_OBJ, STEP_OBJ, average = AVERAGE, update_position = UPDATE_POSITION)
|
|
if SCAN_TYPE in ("all", "stiga"):
|
|
#print "Scan stig a"
|
|
r=scan_focus(obj_stig_a, RANGE_STIG, STEP_STIG, average = AVERAGE, update_position = UPDATE_POSITION)
|
|
if SCAN_TYPE in ("all", "stigb"):
|
|
#print "Scan stig b"
|
|
r=scan_focus(obj_stig_b, RANGE_STIG, STEP_STIG, average = AVERAGE, update_position = UPDATE_POSITION)
|
|
if SCAN_TYPE in ("all"):
|
|
#print "Scan obj"
|
|
r=scan_focus(objective, RANGE_OBJ, STEP_OBJ, average = AVERAGE, update_position = UPDATE_POSITION)
|
|
finally:
|
|
#if EXPOSURE:
|
|
# if (former_exposure is not None) and (former_exposure!=EXPOSURE):
|
|
# set_exposure_time(former_exposure)
|
|
if not get_dry_run() and str(get_setting("AUTO_SWITCH_VALVE")).lower() == "true":
|
|
close_vg10()
|
|
if not get_dry_run() and str(get_setting("AUTO_SWITCH_SHUTTER")).lower() == "true":
|
|
caput(FAST_SHTR, 'Close')
|
|
restore_eiger()
|
|
|
|
final_state = objective.read(),obj_stig_a.read(),obj_stig_b.read()
|
|
print "Final state:" , final_state
|