Files
x03da/script/ManipulatorYZFlyScan.py
2021-11-18 13:00:13 +01:00

73 lines
2.0 KiB
Python

"""
Continuous 2D Manipulator scan
set manipulator scan parameters below.
set analyser parameters (fixed mode) separately!
"""
import math
RANGE_Z = (114.9, 115.9)
# actual number of positions will be +1!
STEPS_Z = 10
RANGE_Y = (-1.5, 1.5)
# speed = distance_per_point / (dwell_time + 0.1)
# minimum 0.01, maximum 0.125 mm/s
SPEED_Y = 0.125
RELATIVE = False
LATENCY = 0.0
ZIGZAG = False
ENDSCAN = True
MOTORS = (ManipulatorY)
SENSORS = (Counts, SampleCurrent, RefCurrent, MachineCurrent, EnergyDistribution, AngleDistribution, Scienta.dataMatrix)
adjust_sensors()
set_adc_averaging()
set_exec_pars(compression=True)
ManipulatorZ.write(RANGE_Z[0])
ManipulatorY.write(RANGE_Y[0])
# time per scienta acquisition in seconds
trig_scienta()
time1 = time.time()
trig_scienta()
time2 = time.time()
scienta_time = (time2 - time1)
print "scienta time: ", scienta_time
# time for one Y scan in seconds
fly_time = (RANGE_Y[1] - RANGE_Y[0]) / SPEED_Y
STEPS_Y = int(fly_time / scienta_time) + 1
print "Y time: ", fly_time
STEP_Z = (RANGE_Z[1] - RANGE_Z[0]) / STEPS_Z
positions_z = [RANGE_Z[0] + STEP_Z * i for i in range(STEPS_Z + 1)]
print "Z positions: ", positions_z
def before_pass(index, scan):
global positions_z
print "Starting pass: ", index
z = positions_z[index-1]
ManipulatorZ.write(z)
print "z = ", z
ManipulatorZ.waitValueInRange(z, 1.0, 100)
DIAGS = [ManipulatorZ]
try:
#cscan(dMOTORS, SENSORS, RANGE_Y[0], RANGE_Y[1], STEPS_Y, time=fly_time, passes=len(positions_z), zigzag=ZIGZAG, before_read=before_readout, after_read = after_readout, before_pass = before_pass, check_positions = False)
Scienta.setGrabMode(Scienta.getGrabMode().Continuous)
Scienta.start()
cscan(MOTORS, SENSORS, RANGE_Y[0], RANGE_Y[1], STEPS_Y, time=fly_time, passes=len(positions_z), zigzag=ZIGZAG, before_pass=before_pass, check_positions=False, diags=DIAGS)
Scienta.stop()
finally:
Scienta.setGrabMode(Scienta.getGrabMode().Single)
if ENDSCAN:
after_scan()