This commit is contained in:
gac-x11ma
2020-12-15 15:20:00 +01:00
parent caccd1e648
commit b707f89f2b
9 changed files with 277 additions and 210 deletions
+42 -40
View File
@@ -1,17 +1,19 @@
#If running from editor
if get_exec_pars().source == CommandSource.ui:
METHOD = "Two_Pol"
SWITCHING = "Tune_Detune"
SEQUENCE = "A"
MEASUREMENTS = 4
AUTO_SAVE = True
EXPOSURE = 1.0
AVERAGE = 2.0
ENERGY_1 = 850.0
ENERGY_2= 900.0
SWITCH_POL=False
DRY_RUN = get_dry_run()
#SEQUENCE = "A": C+,C-,C-,C+,C+;C-,C-,C+,␍
#SEQUENCE = "B": C+,C-,C+,C-,C+,-;C+,C-.
SHOW_IMAGES = True
SAVE_DIAGS = True
@@ -68,32 +70,12 @@ def getLEEM():
"""
def assert_status_ok():
if DRY_RUN: return
assert_machine_ok()
#assert_beamline_ok()
"""
getbeamline
getLEEM
Rem check status of machine
If checkRing = 3 Then
Close
Exit Sub
End If
Rem check status of the beamline
If checkbeamline = 3 Then
Close
Exit Sub
"""
#Initialize vartiables
if not DRY_RUN and str(get_setting("AUTO_SWITCH_VALVE")).lower() == "true":
if not get_dry_run() and str(get_setting("AUTO_SWITCH_VALVE")).lower() == "true":
open_vg10()
#rbkEnergy=energy_rbk.read()
if METHOD == "Two_Pol":
if METHOD == "Two_Pol" or (SWITCH_POL and (METHOD == "Take_Image")):
init_pol_switch(SWITCHING)
def imageinfo(info):
@@ -112,21 +94,21 @@ def save_image_file(frame, cycle=-1, frame_index=0):
# log("SV:"+Format(startvoltage,"0.000")+" OB:"+Format(objective,"0.00")+" ST:"+Format(LEEMtemp,"0.0"))
init_eiger(exposure=EXPOSURE)
#print "Startup time: " + str(time.time() - start)
try:
#Do the measurement loop
for cycle in range(1, MEASUREMENTS + 1):
frames = []
if MEASUREMENTS > 1:
log("")
log("nround = " + str(cycle) + " / " + str(MEASUREMENTS))
if METHOD == "Two_Energies":
change_energy(ENERGY_1)
for i in range(2):
if (cycle == 1) or (METHOD != "Take_Image"):
if (cycle == 1) or (METHOD != "Take_Image"):
assert_status_ok()
if METHOD == "Two_Energies":
change_energy(ENERGY[i])
print "--- Grabing " + str(AVERAGE)+ " frames - cycle: " + str(cycle) + " step: " + str(i)
#s=time.time()
av = average_eiger_frames(AVERAGE, roi=None, wait_next=True)
@@ -137,21 +119,19 @@ try:
if METHOD == "Take_Image":
break
if METHOD == "Two_Pol":
print "--- Switching polatization..."
switch_pol()
if METHOD == "Two_Energies":
change_energy(ENERGY_2)
if METHOD == "Two_Pol":
if (i==0) or (SEQUENCE == "B"):
switch_pol()
#time.sleep(1)
if (METHOD == "Two_Pol") or (METHOD == "Two_Energies"):
if (METHOD == "Two_Energies") or (get_cur_pol() in (2,3)):
###??? autocontrast???
if (METHOD == "Two_Energies") or (SEQUENCE == "B") or ((cycle%2)==1):
#print "Divide first frame by second"
frames.append(frames[0].copy())
frames[2].div(frames[1])
else:
#print "Divide second frame by first"
frames.append(frames[1].copy())
frames[2].div(frames[0])
save_image_file(frames[2],cycle, 2)
@@ -187,11 +167,33 @@ try:
else:
integration =integrate_ips ([integration, ip], as_float=True)
av=op_const(integration, "divide", float(MEASUREMENTS), in_place=True)
save_image_file(av, -1, i)
save_image_file(av, -1, i)
if SWITCH_POL and (METHOD == "Take_Image"):
switch_pol()
SWITCH_POL = False
set_exec_pars(then_success="run('templates/Eiger2Img')")
"""
get_context().incrementDaySequentialNumber()
set_exec_pars(open=False)
set_exec_pars(open=True)
for cycle in range(1, MEASUREMENTS + 1):
frames = []
if MEASUREMENTS > 1:
log("nround = " + str(cycle) + " / " + str(MEASUREMENTS))
print "--- Grabing " + str(AVERAGE)+ " frames - cycle: " + str(cycle) + " step: " + str(i)
av = average_eiger_frames(AVERAGE, roi=None, wait_next=True)
imageinfo("I")
save_image_file(av, cycle, i)
"""
finally:
for i in range(max_index):
get_context().incrementDaySequentialNumber()
if not DRY_RUN and str(get_setting("AUTO_SWITCH_VALVE")).lower() == "true":
if not get_dry_run() and str(get_setting("AUTO_SWITCH_VALVE")).lower() == "true":
close_vg10()
restore_eiger()
print "Running time: " + str(time.time() - start)
+3 -4
View File
@@ -10,7 +10,6 @@ if get_exec_pars().source == CommandSource.ui:
NUMBER_SCANS =1
RANGES = [[500.0, 1000.0, 100.0]]
DRY_RUN = get_dry_run()
SAVE_DIAGS = True
if SWITCH_POL:
@@ -44,7 +43,7 @@ frames=[]
class SyncEnergy(Writable):
def write(self,pos):
if not DRY_RUN:
if not get_dry_run():
put_energy(pos)
else:
print "Energy=" + str(pos)
@@ -82,7 +81,7 @@ set_device_alias(averager, "Image") #Set display name
sensors.append(averager) #sensors.append(eiger.getDataMatrix())
#Initialize vartiables
if not DRY_RUN and str(get_setting("AUTO_SWITCH_VALVE")).lower() == "true":
if not get_dry_run() and str(get_setting("AUTO_SWITCH_VALVE")).lower() == "true":
open_vg10()
#put_id_offset(1, OFFSET_ID_1) #offset on ID1
@@ -120,7 +119,7 @@ finally:
if AVERAGE>1:
for i in range(len(rois)):
rois[i].parent.monitored = False # Remove listeners on the image
if not DRY_RUN and str(get_setting("AUTO_SWITCH_VALVE")).lower() == "true":
if not get_dry_run() and str(get_setting("AUTO_SWITCH_VALVE")).lower() == "true":
close_vg10()
restore_eiger()
print "Running time: " + str(time.time() - start)
+1 -1
View File
@@ -32,7 +32,7 @@ init_eiger(EXPOSURE_TIME)
try:
lscan(objective, sensors, SCAN_RANGE[0], SCAN_RANGE[1], float(STEP_SIZE), latency=SETTLING_TIME, before_read=trigger_eiger, keep=False)
finally:
if not DRY_RUN and str(get_setting("AUTO_SWITCH_VALVE")).lower() == "true":
if not get_dry_run() and str(get_setting("AUTO_SWITCH_VALVE")).lower() == "true":
close_vg10()
restore_eiger()
print "Running time: " + str(time.time() - start)