113 lines
3.4 KiB
Python
Executable File
113 lines
3.4 KiB
Python
Executable File
#Parameters
|
|
"""
|
|
FIELD = "Hx"
|
|
START_FIELD = -0.1
|
|
END_FIELD = 0.1
|
|
ENERGIES = (707.90, 703.90)
|
|
RAMP_RATE = 0.2
|
|
ENERGY_CHANGE_SLEEP = 0.5
|
|
MODE = 'CIRC +'
|
|
OFFSET = -1.0
|
|
"""
|
|
|
|
|
|
iPS = False # false for old power supply, True for new (Oxford Instr) supply
|
|
|
|
#close_shutter_at_zero = False # True to close shutter during B field scan when it is close to 0 T
|
|
#signal_field_analog_x
|
|
|
|
|
|
FIELD_PRECISION = 0.01
|
|
|
|
field = cv
|
|
field_done = di
|
|
|
|
#Pre-actions
|
|
#cawait('ACOAU-ACCU:OP-MODE', 'Light Available', type = 's')
|
|
|
|
|
|
|
|
|
|
|
|
if len(ENERGIES) ==2:
|
|
# dif_series = plot([],"Dif", get_context()="Dif")[0].getSeries(0)
|
|
dif_series = plot([],"Dif")[0].getSeries(0)
|
|
else:
|
|
dif_series = None
|
|
|
|
set_preference(Preference.ENABLED_PLOTS, ['field', 'tey_norm', 'trans_norm'])
|
|
set_preference(Preference.PLOT_TYPES, {'tey_norm':1, 'trans_norm':1})
|
|
|
|
field_var = 'fieldAnalogZ' if (FIELD == "Hz") else 'fieldAnalogX'
|
|
scan = ManualScan(['field', 'Energy'], ['TEY', 'I0', 'trans', 'polarization', 'polAngle', 'temperature', 'RingCurrent', \
|
|
field_var, 'tey_norm','trans_norm'], [0.0, ENERGIES[0]], [0.0, ENERGIES[-1]], [0, len(ENERGIES)-1])
|
|
scan.start()
|
|
|
|
|
|
print "Waiting for start field"
|
|
|
|
#if abs(field.readback.read() - START_FIELD) > FIELD_PRECISION:
|
|
# field.write(START_FIELD)
|
|
|
|
|
|
|
|
|
|
print "Set energy..."
|
|
setpoint2 = ENERGIES[0]
|
|
print setpoint2
|
|
energy.write(setpoint2)
|
|
sleep( ENERGY_CHANGE_SLEEP ) # Settling time
|
|
|
|
|
|
|
|
index = 0
|
|
|
|
while(True):
|
|
#Dimension 2START_FIELD = -0.2
|
|
#ArrayPositioner Energy
|
|
for setpoint2 in ENERGIES:
|
|
if len (ENERGIES)>1:
|
|
#Energy.put(setpoint2, timeout=None) # TODO: Set appropriate timeout
|
|
energy.write(setpoint2)
|
|
|
|
#TODO: change to Controlled variable?
|
|
readback2 = energy.read() + 0.001 #EnergyReadback.get()
|
|
if abs(readback2 - setpoint2) > 0.1 : # TODO: Check accuracy
|
|
# raise Exception('Energy could not be set to the value ' + str(setpoint2))
|
|
#print 'Energy could not be set to the value, try again. ' + str(setpoint2)
|
|
energy.write(setpoint2)
|
|
|
|
#Detector field readback
|
|
field_readback = field.readback.read() #fieldReadback.get()
|
|
|
|
detector1 = 1.0 #signal_tey.read() #TEY.get()
|
|
detector2 = 2.0 #signal_i0.read() #I0.get()
|
|
detector3 = 3.0 #signal_trans.read() #trans.get()
|
|
detector4 = 4.0 #float(pol_mode.getPositions().index(pol_mode.readback.read())) #polarization.get()
|
|
detector5 = 5.0 #pol_angle.read() #polAngle.get()
|
|
detector6 = 6.0 #temperature.readback.read() #temperature.get()
|
|
detector7 = 7.0 #current.read()
|
|
detector8 = 8.0 #signal_field_analog_z.read() if FIELD =="Hz" else signal_field_analog_x.read() # fieldAnalogX.get()
|
|
|
|
_tey_norm = detector1/detector2
|
|
_trans_norm = detector3/detector2
|
|
|
|
if dif_series is not None:
|
|
if setpoint2 == ENERGIES[0]:
|
|
first = _tey_norm
|
|
else:
|
|
dif = _tey_norm-first
|
|
dif_series.appendData(field_readback,dif)
|
|
scan.append ([field_readback, setpoint2], [field_readback, readback2], [detector1, detector2, detector3, detector4, detector5, detector6, detector7, detector8, _tey_norm, _trans_norm])
|
|
#after_sample() #To call check_id_error()
|
|
|
|
if index>100:
|
|
print "Field has reached target, breaking execution."
|
|
break
|
|
|
|
index = index+1
|
|
|
|
scan.end()
|
|
|
|
|