From d5cf076850726c1b7453adefe26abbf57a1a0abf Mon Sep 17 00:00:00 2001 From: gac-x03da Date: Thu, 14 Sep 2023 16:26:01 +0200 Subject: [PATCH] Script execution --- script/DeflectorScan.py | 63 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 script/DeflectorScan.py diff --git a/script/DeflectorScan.py b/script/DeflectorScan.py new file mode 100644 index 00000000..ddd0caf4 --- /dev/null +++ b/script/DeflectorScan.py @@ -0,0 +1,63 @@ +""" +Arguments: + +MOTOR (device) +SENSORS (list) +RANGE (tuple (min, max)) +STEPS (int or tuple) +LATENCY (double) +RELATIVE (BOOLEAN) +FLY_SCAN (BOOLEAN) +ENDSCAN (BOOLEAN) +""" + + +MOTORS = (ScientaCenterThetaY) +# save Scienta image: +SENSORS = (Counts, Scienta.dataMatrix, Scienta.spectrum, SampleCurrent, RefCurrent, MachineCurrent, EnergyDistribution, AngleDistribution) +# don't save Scienta image, derived data only: +# SENSORS = (Counts, Scienta.spectrum, SampleCurrent, RefCurrent, MachineCurrent, EnergyDistribution, AngleDistribution) + +STARTPOS = -15. +ENDPOS = +15. +# if integer, actual number of positions will be +1! +STEPS = 1 +RELATIVE = False +LATENCY = 0.0 +ENDSCAN = True +ZIGZAG = False +FLY_SCAN = False + +adjust_sensors() +set_adc_averaging() +set_preference(Preference.PLOT_TYPES, {'Scienta spectrum':1}) +set_exec_pars(compression=True) + +try: + if FLY_SCAN: + # time per scienta acquisition in seconds + trig_scienta() + time1 = time.time() + before_readout() + time.sleep(0.2) + time2 = time.time() + scienta_time = (time2 - time1) + 1. + print "step time: ", scienta_time + + if isinstance(STEPS,int): + raise Exception ("Fly Scan must define step size, and not number of steps") + + STEP = STEPS[0] + SPEED = STEP / scienta_time + fly_time = (RANGE[1] - RANGE[0]) / SPEED + STEPS = int(fly_time / scienta_time) + 1 + + print "speed: ", SPEED + print "scan time: ", fly_time + cscan(MOTOR, SENSORS, RANGE[0], RANGE[1], STEPS, LATENCY, fly_time, RELATIVE, before_read=before_readout, after_read = after_readout, check_positions = False) + else: + lscan(MOTOR, SENSORS, RANGE[0], RANGE[1], STEPS, LATENCY, RELATIVE, before_read=before_readout, after_read = after_readout) +finally: + if ENDSCAN: + after_scan() + \ No newline at end of file