Commit 1872dace authored by bliss administrator's avatar bliss administrator
Browse files

xas xes changes

parent 362b17a8
Pipeline #74596 failed
......@@ -60,6 +60,25 @@ def empty_serial_line():
except:
pass
def move_undulators(energy_target):
#umv(eneund, energy_target) # this would move also mono, not needed
# we need only to move "tracked" undulators to positions corresponding to "energy_target"
xas_pos = PositionInstances('start_energy',U35A, U35B, U35C)
# get a list of "tracked" undulators:
undu_list = []
motion = ()
for one_undu in setup_globals.get_available_undulators():
print(one_undu.name)
if (one_undu.name[0] == 'u' and one_undu.track() == True):
undu_list = undu_list+ [one_undu.name]
# calculate desired gap openings for each "tracked" undulator and save into "xas_pos" Position Instance
for undname in undu_list:
pos = setup_globals.name_to_obj(undname).position
calc_position = ENEUND.controller.undu.energy2undulator(setup_globals.name_to_obj(undname),energy_target)
if abs(calc_position-pos) > ENEUND.controller.approx:
xas_pos.position(setup_globals.name_to_obj(undname),calc_position)
motion += (setup_globals.name_to_obj(undname), calc_position)
xas_pos.move(*motion)
class ID26Measurement(ID26Settings):
def __init__(self, name, position_manager = None):
......@@ -298,24 +317,7 @@ class ID26XAS(ID26Measurement):
# TODO: make sure the move moves all real axis in the xes_en!!!
XES_EN.move(xes_energy)
def move_undulators(self, energy_target):
#umv(eneund, energy_target) # this would move also mono, not needed
# we need only to move "tracked" undulators to positions corresponding to "energy_target"
xas_pos = PositionInstances('xas_start',U35A, U35B, U35C)
# get a list of "tracked" undulators:
undu_list = []
motion = ()
for one_undu in setup_globals.get_available_undulators():
print(one_undu.name)
if (one_undu.name[0] == 'u' and one_undu.track() == True):
undu_list = undu_list+ [one_undu.name]
# calculate desired gap openings for each "tracked" undulator and save into "xas_pos" Position Instance
for undname in undu_list:
calc_position = ENEUND.controller.undu.energy2undulator(setup_globals.name_to_obj(undname),energy_target)
xas_pos.position(setup_globals.name_to_obj(undname),calc_position)
motion += (setup_globals.name_to_obj(undname), calc_position)
xas_pos.move(*motion)
def auto_offset (self):
print("NOT IMPLEMENTED YET auto_offset")
......@@ -335,7 +337,7 @@ class Xanes(ID26XAS):
def hook_pre_fscanloop(self):
super().hook_pre_fscanloop()
if self['energy_edge'] is not None:
self.move_undulators(self.get_param('energy_edge'))
move_undulators(self.get_param('energy_edge'))
# self.auto_offset() # not done here
FSCAN_PAR['id_linked'] = 0
FSCAN_PAR['id_sync'] = 0
......@@ -364,7 +366,7 @@ class Exafs(ID26XAS):
# @switch_instance
def rocking_curve(self):
print ("EXAFS NOT IMPLEMENTED YET rc: mv energy end_energy") #rc includes beamcheck
self.move_undulators (self['end_energy'])
move_undulators(self['end_energy'])
print ("EXAFS NOT IMPLEMENTED YET rc: rc") #rc includes beamcheck
# @switch_instance
......@@ -579,29 +581,7 @@ class ID26StepXAS(ID26Measurement):
def move_undulators(self, energy_target):
#umv(eneund, energy_target) # this would move also mono, not needed
# we need only to move "tracked" undulators to positions corresponding to "energy_target"
xas_pos = PositionInstances('start_energy',U35A, U35B, U35C)
# get a list of "tracked" undulators:
undu_list = []
motion = ()
for one_undu in setup_globals.get_available_undulators():
print(one_undu.name)
if (one_undu.name[0] == 'u' and one_undu.track() == True):
undu_list = undu_list+ [one_undu.name]
# calculate desired gap openings for each "tracked" undulator and save into "xas_pos" Position Instance
for undname in undu_list:
pos = setup_globals.name_to_obj(undname).position
calc_position = ENEUND.controller.undu.energy2undulator(setup_globals.name_to_obj(undname),energy_target)
if abs(calc_position-pos) > ENEUND.controller.approx:
xas_pos.position(setup_globals.name_to_obj(undname),calc_position)
motion += (setup_globals.name_to_obj(undname), calc_position)
xas_pos.move(*motion)
class StepXanes(ID26StepXAS):
......
......@@ -9,7 +9,7 @@ from bliss.common.scans import timescan, loopscan
from bliss.shell.standard import umv
from id26.scripts.fscan import fscan
from id26.scripts.xas import ID26Measurement
from id26.scripts.xas import ID26Measurement, move_undulators
from id26.scripts.position_instances import PositionInstances
from id26.controllers.radiation_damage import axes2counters, PositionManager , RadiationDamagePreset
......@@ -496,9 +496,9 @@ class Rixs(ID26Measurement):
# TODO : when not in a MDT
if self.get_param('xas_end') is not None:
# setup_globals.move_undulators(self.get_param('xas_end')) # best resolution before undulator peak
#print('moving undulators') # this should go back when the line above works!
pass
move_undulators(self.get_param('xas_end')) # best resolution before undulator peak
print('moving undulators') # this should go back when the line above works!
# TODO: move together both!
......@@ -571,17 +571,17 @@ class Rixs(ID26Measurement):
print("*************************************************************")
print(" Start of rixs ")
print("*************************************************************")
# TODO: check all params defined
# TODO: check all params defined
if self._move_scan_mode == 'in':
print('Cannot use IN move_scan_mode in fscans. Change rixs[\'et_scan\'] or move_scan_mode.')
raise ValueError
# need to remember first index for the correction scan
elif self._move_scan_mode == 'between':
self._first_correction_index = self._position_manager.get_index(self._current_sample)
for hans in np.arange(number_scans):
#rccnt = 0; if (RCYESNO) {rc}
setup_globals.auto_offsets()
xes_energies = np.arange(self.get_param('xes_start'), (self.get_param('xes_end')+self.get_param('xes_int')/2), self.get_param('xes_int'))
if self._move_scan_mode == 'in':
print('Cannot use IN move_scan_mode in fscans. Change rixs[\'et_scan\'] or move_scan_mode.')
raise ValueError
# need to remember first index for the correction scan
elif self._move_scan_mode == 'between':
self._first_correction_index = self._position_manager.get_index(self._current_sample)
for xes4rixs in xes_energies:
print("Moving xes_en to {}\n".format(xes4rixs))
XES_EN.move(xes4rixs)
......@@ -598,9 +598,13 @@ class Rixs(ID26Measurement):
#TODO: id26check_gauges(5); _open_valve(4) # we had problems with penning 5 tripping
my_fscan = fscan(self.get_param('xas_start'),self.get_param('xas_end'),self.get_param('scan_time'),self.get_param('xas_int'))
print('fscan', self.get_param('xas_start'),self.get_param('xas_end'),self.get_param('scan_time'),self.get_param('xas_int'))
if self._move_scan_mode == 'between': # run CorrectionScan but here we have to recover number of points
current_index = self._position_manager.get_index(self._current_sample)
self._nbpts = current_index-self._first_correction_index
if self._move_scan_mode == 'between': # run CorrectionScan but here we have to recover number of points
current_index = self._position_manager.get_index(self._current_sample)
# following line fails if _first_correction_index was -1 (but is something big on a second run)
# self._nbpts = current_index-self._first_correction_index
# replaced by simpler:
self._nbpts = len(xes_energies)*number_scans
elif et_scan == True: # et_scan == True: rixs_et scan
print('rixs by ET scans')
print( "*************************************************************")
......@@ -705,11 +709,9 @@ class CorrectionScan(ID26Measurement):
self._main_scan = value
def scan(self, acq_time = None, inc_energy = None, xes_main_max = None, first_index = None, last_index = None, nbpts = None, pname = None):
# make sure pname is defined
if pname is None:
if self.current_sample is None:
self._current_sample = self._main_scan._current_sample
def scan(self, acq_time = None, inc_energy = None, xes_main_max = None, first_index = None, last_index = None, nbpts = None):
# make sure pname is defined, here it is automatically the main scan current_sample:
self._current_sample = self._main_scan._current_sample
if self._current_sample is None:
raise ValueError('current sample not defined')
......@@ -749,6 +751,7 @@ class CorrectionScan(ID26Measurement):
last_index = self._main_scan.get_current_index()
else:
nbpts = last_index - first_index+1
print(f'number of points is ', nbpts)
# check all params defined
if xes_main_max is None:
......@@ -787,16 +790,15 @@ class CorrectionScan(ID26Measurement):
except ValueError:
print(f'{mot_counters[1].name} probably is already in the ACTIVE_MG')
self._radiation_damage = RadiationDamagePreset(xmot, ymot, self._position_manager, self._current_sample) # this makes the cc RD independent of the main scan RD
# back to the starting index
if first_index == -1: # if sample not run yet
self.goto_index(len(self._main_scan._radiation_damage.pm._positions[self._current_sample])-1) # go to the last point of the pattern so that the next position is the first one
else:
self.goto_index(first_index)
print(f'1st index in the corrections scan {self.get_current_index()}')
print(f'1st index in the correction scan {self.get_current_index()}')
correction_scan = loopscan(nbpts, acq_time, run = False)
correction_scan.acq_chain.add_preset(self._main_scan._radiation_damage)
correction_scan.acq_chain.add_preset(self._radiation_damage) # must be run on the cc RD not to lose the main scan indexing!
correction_scan.run() # run the correction scan
return correction_scan
Supports Markdown
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