Commit 3bda4a25 authored by bliss administrator's avatar bliss administrator
Browse files

Plotting as option in alignment methods

parent 4e42fae8
......@@ -20,9 +20,10 @@ from nabu.preproc.alignment import CameraTilt
from bliss.common.plot import plot_image
import matplotlib.pyplot as plt
def tomo_alignxc(tomo, svg="ssvg", shg="sshg", xc_start=100, xc_end=900, save=False):
def tomo_alignxc(tomo, svg="ssvg", shg="sshg", xc_start=100, xc_end=900, save=False, plot=False):
pixel_size = tomo.optic.image_pixel_size
print ("pixel_size in um = %f" % pixel_size)
......@@ -56,21 +57,29 @@ def tomo_alignxc(tomo, svg="ssvg", shg="sshg", xc_start=100, xc_end=900, save=Fa
# the scan positions and the pixel_size must have the same units!
tr_calc = DetectorTranslationAlongBeam()
# enable calculation results plotting
if plot == True:
tr_calc.verbose=True
shifts_v, shifts_h = tr_calc.find_shift(al_array, al_pos)
# pixel size should be im mm
tilt_v_deg = - np.rad2deg(np.arctan(shifts_v * pixel_size / 1000.0))
tilt_h_deg = - np.rad2deg(np.arctan(shifts_h * pixel_size / 1000.0))
print (f"\nVertical tilt in deg (thy): {tilt_v_deg}")
print (f"horizontal tilt in deg (thz): {tilt_h_deg}\n")
print (f"Horizontal tilt in deg (thz): {tilt_h_deg}\n")
# apply to the motors
# needs a real pbject to configure motors!!!!!
# needs a real object to configure motors!!!!!
# Kill the plot window when it was requested
if plot == True:
if click.confirm("Close the plot window?", default=True):
# workaround for nabu plotting problem
plt.close('all')
def tomo_align(tomo, save=False):
def tomo_align(tomo, save=False, plot=False):
# move rotation axis to 0
umv (tomo.rotation_axis, 0)
......@@ -114,6 +123,10 @@ def tomo_align(tomo, save=False):
# calculate the lateral correction for the rotation axis
# and the camera tilt with line by line correlation
tilt_calc = CameraTilt()
# enable calculation results plotting
if plot == True:
tilt_calc.verbose=True
pixel_cor, camera_tilt = tilt_calc.compute_angle(radio0, radio180_flip)
print("CameraTilt: pixel_cor = %f" % pixel_cor)
......@@ -148,16 +161,18 @@ def tomo_align(tomo, save=False):
# apply correction
if click.confirm("Apply the camera tilt?", default=True):
rotc = tomo.optic.rotc_motor()
#umvr (rotc, -1.0*camera_tilt)
umvr (rotc, camera_tilt)
ct(tomo.parameters.exposure_time)
print (f"Moved camera tilt to: {rotc.position}")
# Kill the plot window when it was requested
if plot == True:
# workaround for nabu plotting problem
plt.close('all')
def tomo_dofocus(tomo, save=False):
def tomo_dofocus(tomo, save=False, plot=False):
# prepare the focus scan parameters
scan_pars = tomo.optic.focus_scan_parameters()
......@@ -193,6 +208,10 @@ def tomo_dofocus(tomo, save=False):
#print (foc_pos)
focus_calc = CameraFocus()
# enable calculation results plotting
if plot == True:
focus_calc.verbose = True
focus_pos, focus_ind, tilts_vh = focus_calc.find_scintillator_tilt(foc_array, foc_pos)
#print (focus_pos, focus_ind, tilts_vh)
......@@ -212,7 +231,11 @@ def tomo_dofocus(tomo, save=False):
scr = get_config().get("scr")
umv(scr, -130.0)
# Kill the plot window when it was requested
if plot == True:
# workaround for nabu plotting problem
plt.close('all')
def dofocus(focus_motor, start, stop, steps, expo_time, detector, save=False):
# get motor to move paper
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment