This commit is contained in:
@@ -7,7 +7,10 @@ class LEEM2000(TcpDevice):
|
||||
self.NUMBER_MNEMONICS = 100
|
||||
self._mnemonics = None
|
||||
self._names = None
|
||||
self.high_voltage = Channel("X11MA-ES1-PEEM:UMON", alias = "PEEM high voltage", monitored=True)
|
||||
try:
|
||||
self.high_voltage = Channel("X11MA-ES1-PEEM:UMON", alias = "PEEM high voltage", monitored=True)
|
||||
except:
|
||||
self.high_voltage = None
|
||||
self.debug = False
|
||||
self.retries = 1
|
||||
self.timeout = 1000
|
||||
@@ -119,10 +122,10 @@ class LEEM2000(TcpDevice):
|
||||
def get_high_voltage(self):
|
||||
return self.high_voltage.get(False)
|
||||
|
||||
def get_child(self, var, name=None):
|
||||
def get_child(self, var, name=None, scale=None):
|
||||
if name is None:
|
||||
name=var
|
||||
ret = LEEM2000Child(name, var, self)
|
||||
ret = LEEM2000Child(name, var, self, scale)
|
||||
ret.initialize()
|
||||
return ret
|
||||
|
||||
@@ -203,15 +206,23 @@ class LEEM2000(TcpDevice):
|
||||
|
||||
|
||||
class LEEM2000Child(RegisterBase):
|
||||
def __init__(self,name, var, microscope):
|
||||
def __init__(self,name, var, microscope, scale=None):
|
||||
RegisterBase.__init__(self,name)
|
||||
self.var = var
|
||||
self.scale = scale
|
||||
self.microscope = microscope
|
||||
|
||||
def doRead(self):
|
||||
return self.microscope.get_value(self.var)
|
||||
ret = self.microscope.get_value(self.var)
|
||||
if ret is not None:
|
||||
if self.scale is not None:
|
||||
ret = float(ret)*self.scale
|
||||
return ret
|
||||
|
||||
def doWrite(self, val):
|
||||
if val is not None:
|
||||
if self.scale is not None:
|
||||
val = float(val)/self.scale
|
||||
self.microscope.set_value(self.var, val)
|
||||
|
||||
class LEEM2000Positioner (PositionerBase):
|
||||
@@ -283,7 +294,7 @@ add_device (microscope.get_tilt('D','U', "tilt_v"), True)
|
||||
add_device (microscope.get_child("MOBJ","objective"), True)
|
||||
add_device (microscope.get_child("OSTIGA","obj_stig_a"), True)
|
||||
add_device (microscope.get_child("OSTIGB","obj_stig_b"), True)
|
||||
add_device (microscope.get_child("MDRIVE","azimuth_rot"), True)
|
||||
add_device (microscope.get_child("MDRIVE","azimuth_rot", 0.01794), True)
|
||||
add_device (microscope.get_child("BOMBV","bv"), True)
|
||||
add_device (microscope.get_child("FIL","fil"), True)
|
||||
add_device (microscope.get_child("STV","start_voltage"), True)
|
||||
@@ -321,8 +332,11 @@ class Fov(ReadonlyRegisterBase):
|
||||
self.position = 0
|
||||
|
||||
def doRead(self):
|
||||
return self.mic.get_preset_label()
|
||||
|
||||
ret = self.mic.get_preset_label()
|
||||
if ret is not None:
|
||||
if ":" in ret:
|
||||
ret = ret[0:ret.rindex(":")]
|
||||
return ret
|
||||
|
||||
|
||||
def init_tilt():
|
||||
@@ -337,6 +351,8 @@ tilt_horizontal.polling=500
|
||||
manip_x.polling=500
|
||||
manip_y.polling=500
|
||||
fov.polling=5000
|
||||
azimuth_rot.precision=2
|
||||
azimuth_rot.polling=5000
|
||||
bv.polling=1000
|
||||
fil.polling=1000
|
||||
|
||||
|
||||
+11
-10
@@ -36,10 +36,15 @@ def load_corr_stack(title="Corr", show=False):
|
||||
file_list.append("{images}/TestObjAligner_corr/i210517_0" + str(index) + "#001.tif")
|
||||
return load_stack(title, file_list, show)
|
||||
|
||||
def instantiate_dynamic_class(name):
|
||||
if get_context().getPluginManager().getDynamicClass(name) is None:
|
||||
get_context().getPluginManager().loadInitializePlugin(name + ".java")
|
||||
return get_context().getClassByName(name).newInstance()
|
||||
|
||||
|
||||
def complex_edge_filtering(imp, complex=True, g_sigma=3.0, g_resolution=1e-4, show=False, java_code=False):
|
||||
if java_code:
|
||||
get_context().getPluginManager().loadInitializePlugin("Align_ComplexEdgeFiltering.java")
|
||||
complex_edge_filter = get_context().getClassByName("Align_ComplexEdgeFiltering").newInstance()
|
||||
complex_edge_filter = instantiate_dynamic_class("Align_ComplexEdgeFiltering")
|
||||
complex_edge_filter.setup(str(g_sigma)+","+str(complex)+","+str(show), imp) #Gaussian blur radius, Complex (True) or Real (False), show dialog = False
|
||||
complex_edge_filter.run(imp.getProcessor())
|
||||
return complex_edge_filter.output
|
||||
@@ -151,8 +156,7 @@ class TranslationFilter(ExtendedPlugInFilter):
|
||||
def translate(stack, shifts, show=False, java_code=False):
|
||||
WindowManager.setTempCurrentImage(stack)
|
||||
if java_code:
|
||||
get_context().getPluginManager().loadInitializePlugin("Align_TranslationFilter.java")
|
||||
translation_filter = get_context().getClassByName("Align_TranslationFilter").newInstance()
|
||||
translation_filter = instantiate_dynamic_class("Align_TranslationFilter")
|
||||
translation_filter.imp = imp
|
||||
translation_filter.shifts = shifts
|
||||
pfr = PlugInFilterRunner(translation_filter, "", "" )
|
||||
@@ -170,13 +174,11 @@ def translate(stack, shifts, show=False, java_code=False):
|
||||
|
||||
|
||||
def load_shifts(filename):
|
||||
get_context().getPluginManager().loadInitializePlugin("ShiftsIO.java")
|
||||
sio = get_context().getClassByName("ShiftsIO").newInstance()
|
||||
sio = instantiate_dynamic_class("ShiftsIO")
|
||||
return sio.load(expand_path(filename), "directshifts")
|
||||
|
||||
def save_shifts(filename, shifts):
|
||||
get_context().getPluginManager().loadInitializePlugin("ShiftsIO.java")
|
||||
sio = get_context().getClassByName("ShiftsIO").newInstance()
|
||||
sio = instantiate_dynamic_class("ShiftsIO")
|
||||
sio.save(expand_path(filename), shifts, "directshifts")
|
||||
|
||||
|
||||
@@ -588,8 +590,7 @@ def calculate_shifts(imp_r, imp_i, roi, upscale_factor=100, reference_slide=1, j
|
||||
if roi is None or roi.bounds.minX <0 or roi.bounds.minY<0 or roi.bounds.maxX>=imp_r.width or roi.bounds.maxY>=imp_r.height:
|
||||
raise Exception("Invalid roi: " + str(roi))
|
||||
if java_code:
|
||||
get_context().getPluginManager().loadInitializePlugin("Align_ComputeShifts.java")
|
||||
compute_shifts_filter = get_context().getClassByName("Align_ComputeShifts").newInstance()
|
||||
compute_shifts_filter = instantiate_dynamic_class("Align_ComputeShifts")
|
||||
compute_shifts_filter.setup(upscale_factor, False, imp_r, imp_i, 1, roi)
|
||||
compute_shifts_filter.run(None)
|
||||
return compute_shifts_filter.shifts
|
||||
|
||||
+11
-1
@@ -834,6 +834,10 @@ def peem_optics_default_15kV():
|
||||
obj_align_y.write(0)
|
||||
start_voltage.write(0)
|
||||
# fov.write(100)
|
||||
microscope.send_receive("sep 100um")
|
||||
microscope.send_receive("mmp 7 -9044.7", 60000)
|
||||
microscope.send_receive("mmp 2 -5998.6", 60000)
|
||||
microscope.send_receive("mmp 1 0.0", 60000)
|
||||
|
||||
def peem_optics_default_10kV():
|
||||
objective.write(1220)
|
||||
@@ -842,12 +846,18 @@ def peem_optics_default_10kV():
|
||||
obj_align_x.write(0)
|
||||
obj_align_y.write(0)
|
||||
start_voltage.write(0)
|
||||
microscope.send_receive("sep 100um")
|
||||
microscope.send_receive("mmp 7 -9044.7", 60000)
|
||||
microscope.send_receive("mmp 2 -5998.6", 60000)
|
||||
microscope.send_receive("mmp 1 0.0", 60000)
|
||||
|
||||
|
||||
|
||||
# x-rays default setup
|
||||
def xrays_default():
|
||||
exit_slit.write(300.0)
|
||||
caput ('X11MA-FE-DSAPER', 0) # close FE-slits
|
||||
set_beamline_setup(id ="ID2", en=800, pol2="Lin_Hor", grat="G3_600", order=1, Cff=2.25)
|
||||
set_beamline_setup(id ="PGM_ID2",en=800, pol2="Lin_Hor", har2 = "1", off2 = "-2.0", grat="G3_600", order="1", Cff=2.25)
|
||||
|
||||
def neutralize_position(retries = 3):
|
||||
for i in range(retries):
|
||||
|
||||
@@ -102,16 +102,16 @@ def scan_contrast(positioner, pos_range, pos_step, roi = None, average = 1, upda
|
||||
positioner.write(mn)
|
||||
else:
|
||||
print "Invalid fit for ", positioner.name, mn, range_scan
|
||||
time.sleep(1.0) # Wait restoring positions
|
||||
time.sleep(SETTLING_TIME) # Wait restoring positions
|
||||
return r
|
||||
|
||||
|
||||
def update_roi_pos(cur_data, former_data):
|
||||
roi=get_focus_scan_roi()
|
||||
calc_roi = Roi(roi.x,roi.y,roi.width, roi.height)
|
||||
try:
|
||||
roi=get_focus_scan_roi()
|
||||
calc_roi = Roi(roi.x,roi.y,roi.width, roi.height)
|
||||
xoff, yoff, error, diffphase, _ = calculate_shift(former_data,cur_data, calc_roi)
|
||||
print "Calculated shift: ", xoff, yoff, error, diffphase
|
||||
print "Calculated shift: ", xoff, yoff, error, diffphase,
|
||||
if (abs(xoff) <= MAX_SHIFT) and (abs(yoff) <= MAX_SHIFT):
|
||||
x,y=int(roi.x - xoff), int(roi.y - yoff)
|
||||
print "Updating ROI location to ", x, y
|
||||
@@ -144,10 +144,11 @@ def scan_focus(positioner, pos_range, pos_step, average = 1, update_position = T
|
||||
|
||||
def before_read(pos,scan):
|
||||
global former_data
|
||||
if str(eiger.grabMode)=="Single":
|
||||
eiger.start()
|
||||
image.waitNext(20000)
|
||||
|
||||
if str(eiger.grabMode)=="Single":
|
||||
eiger.start()
|
||||
else:
|
||||
time.sleep(eiger.exposure)
|
||||
image.waitNext(20000)
|
||||
cur_data = image.data
|
||||
try:
|
||||
print "----- Pos: ", pos
|
||||
@@ -178,7 +179,7 @@ def scan_focus(positioner, pos_range, pos_step, average = 1, update_position = T
|
||||
|
||||
|
||||
r = lscan( positioner, [sensor,], -pos_range, pos_range, pos_step, \
|
||||
latency=eiger.exposure+SETTLING_TIME, relative=True, initial_move=False, restore_position=False, \
|
||||
latency=SETTLING_TIME, relative=True, initial_move=False, restore_position=False, \
|
||||
before_read=before_read, after_read=after_read, before_pass=before_pass)
|
||||
|
||||
ydata, xdata = r[sensor], r[positioner]
|
||||
@@ -206,5 +207,5 @@ def scan_focus(positioner, pos_range, pos_step, average = 1, update_position = T
|
||||
print "Invalid fit for ", positioner.name, mn, range_scan
|
||||
apply_focus_scan_pos(initial_state)
|
||||
if initial_roi_location: roi.location=initial_roi_location
|
||||
time.sleep(1.0) # Wait restoring positions
|
||||
time.sleep(0.) # Wait restoring positions
|
||||
return r
|
||||
|
||||
Reference in New Issue
Block a user