From 9c593e9805f39df3ceb004e026f3edb22b658dae Mon Sep 17 00:00:00 2001 From: gac-x03da Date: Mon, 27 Mar 2023 23:47:35 +0200 Subject: [PATCH] Script execution --- script/staff/HoloFlyScan2.py | 70 ++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 script/staff/HoloFlyScan2.py diff --git a/script/staff/HoloFlyScan2.py b/script/staff/HoloFlyScan2.py new file mode 100644 index 00000000..82644052 --- /dev/null +++ b/script/staff/HoloFlyScan2.py @@ -0,0 +1,70 @@ +""" +Flying hologram scan (experimental) + +Arguments: + +THETA_RANGE (tuple (min, max)) +PHI_RANGE (tuple (min, max)) +THETA_STEP (scalar) +PHI_STEP (scalar) + +ZIGZAG (BOOLEAN) +LATENCY (float) in seconds +SENSORS (list of devices) +""" + +THETA_RANGE = (-9.0, 80.0) +THETA_STEP = 1.0 +#PHI_RANGE = (-40.0, +40.0) +PHI_RANGE = (-170.0, +170.0) +PHI_STEP = 20.0 + +LATENCY = 0.0 +ZIGZAG = True +ENDSCAN = True +MOTORS = (ManipulatorTheta) +#SENSORS = (Counts, Scienta.spectrum, SampleCurrent, RefCurrent, MachineCurrent) +SENSORS = (Counts, Scienta.dataMatrix, SampleCurrent, RefCurrent, MachineCurrent) +efix = 110. +Scienta.centerEnergy.write(efix) + +#set_preference(Preference.ENABLED_PLOTS, [ManipulatorPhi, ManipulatorTheta, Scienta.dataMatrix, ImageIntegrator]) +#set_preference(Preference.PLOT_TYPES,{'ImageIntegrator':1}) +adjust_sensors() +set_adc_averaging() +set_preference(Preference.PLOT_TYPES, {'Scienta spectrum':1}) +set_exec_pars(compression=True) + +# time per scienta acquisition in seconds +time1 = time.time() +trig_scienta() +time2 = time.time() +scienta_time = (time2 - time1) +print "scienta_time: ", scienta_time + +# time for one theta scan in seconds +THETA_NSTEPS = int((THETA_RANGE[1] - THETA_RANGE[0]) / THETA_STEP) + 1 +theta_time = scienta_time * THETA_NSTEPS +print "theta_time: ", theta_time + +PHI_NSTEPS = int((PHI_RANGE[1] - PHI_RANGE[0]) / PHI_STEP) + 1 +phi_positions = [PHI_RANGE[0] + PHI_STEP * i for i in range(PHI_NSTEPS)] +print "phi_positions: ", phi_positions + + +def before_pass(index, scan): + global phi_positions + print "Starting pass: ", index + phi = phi_positions[index-1] + ManipulatorPhi.write(phi) + print "phi = ", phi + ManipulatorPhi.waitValueInRange(phi, 1.0, 100) + + +try: + cscan(MOTORS, SENSORS, THETA_RANGE[0], THETA_RANGE[1], THETA_NSTEPS - 1, time=theta_time, passes=len(phi_positions), zigzag=ZIGZAG, before_read=before_readout, after_read = after_readout, before_pass = before_pass, check_positions = False) + +finally: + if ENDSCAN: + after_scan() + \ No newline at end of file