152 lines
4.6 KiB
Python
152 lines
4.6 KiB
Python
#Script imported from: Fe_hyst_plus.xml
|
|
|
|
#Parameters
|
|
"""
|
|
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
|
|
"""
|
|
|
|
|
|
FIELD_PRECISION = 0.01
|
|
|
|
#Pre-actions
|
|
#cawait('ACOAU-ACCU:OP-MODE', 'Light Available', type = 's')
|
|
wait_beam()
|
|
|
|
pol_mode.write(MODE)
|
|
pol_offset.write(OFFSET) #caput('X07MA-ID:ENERGY-OFFS', OFFSET)
|
|
caputq('X07MA-PC:CSCALER.INPB', '1')
|
|
ramp_rate.write(RAMP_RATE)
|
|
|
|
|
|
if len(ENERGIES) ==2:
|
|
dif_series = plot([],"Dif", context="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})
|
|
|
|
scan = ManualScan(['field', 'Energy'], ['TEY', 'I0', 'trans', 'polarization', 'polAngle', 'temperature', 'RingCurrent', 'fieldAnalogX', 'tey_norm','trans_norm'], [0.0, ENERGIES[0]], [0.0, ENERGIES[-1]], [0, len(ENERGIES)-1])
|
|
scan.start()
|
|
|
|
#Stop condition
|
|
#ramp_done = Channel('X07MA-PC-MAG:X:RAMP:DONE', type = 'i')
|
|
|
|
#Creating channels: dimension 1
|
|
#RegionPositioner field
|
|
#field = Channel('X07MA-PC:GO', type = 'd')
|
|
#fieldReadback = Channel('X07MA-PC-PS2:STS:PMCURRENT', type = 'd')
|
|
#Creating channels: dimension 2
|
|
#ArrayPositioner Energy
|
|
#Energy = Channel('X07MA-PHS-E:GO.A', type = 'd')
|
|
#EnergyReadback = Channel('X07MA-PGM:CERBK', type = 'd')
|
|
#ScalarDetector TEY
|
|
#TEY = Channel('X07MA-ES1-AI:SIGNAL0', type = 'd')
|
|
#ScalarDetector I0
|
|
#I0 = Channel('X07MA-ES1-AI:SIGNAL1', type = 'd')
|
|
#ScalarDetector trans
|
|
#trans = Channel('X07MA-ES1-AI:SIGNAL2', type = 'd')
|
|
#ScalarDetector polarization
|
|
#polarization = Channel('X07MA-ID:MODE', type = 'd')
|
|
#ScalarDetector polAngle
|
|
#polAngle = Channel('X07MA-ID:ALPHA', type = 'd')
|
|
#ScalarDetector temperature
|
|
#temperature = Channel('X07MA-PC-TC:STS:T1', type = 'd')
|
|
#ScalarDetector RingCurrent
|
|
#RingCurrent = Channel('ARIDI-PCT:CURRENT', type = 'd')
|
|
#ScalarDetector fieldAnalogX
|
|
#fieldAnalogX = Channel('X07MA-ES1-AI:SIGNAL4', type = 'd')
|
|
|
|
|
|
print "SKIPPED Waiting for start field"
|
|
|
|
if abs(field_x.readback.read() - START_FIELD) > FIELD_PRECISION:
|
|
field_x.write(START_FIELD)
|
|
#if abs(fieldReadback.get() - START_FIELD) > FIELD_PRECISION:
|
|
# caput('X07MA-PC-PS2:M:GO.A', START_FIELD)
|
|
|
|
|
|
|
|
#caput("X07MA-PC-MAG:X:DMD", START_FIELD)
|
|
#caput("X07MA-PC-MAG:STARTRAMP.PROC", 1)
|
|
|
|
field_x_done.waitValue(1) #ramp_done.wait_for_value(1.0)
|
|
pol_done.waitValue("DONE")
|
|
|
|
#caput('X07MA-OP-VG13:WT_SET', 'Try open')
|
|
#time.sleep(2.0)
|
|
open(2.0)
|
|
|
|
print "Set end field"
|
|
#caput("X07MA-PC-MAG:X:DMD", END_FIELD)
|
|
#caputq("X07MA-PC-MAG:STARTRAMP.PROC", 1)
|
|
field_x.write(END_FIELD) #caputq('X07MA-PC-PS2:M:GO.A', END_FIELD)
|
|
|
|
|
|
|
|
|
|
index = 0
|
|
while(True):
|
|
#Dimension 2START_FIELD = -0.2
|
|
#ArrayPositioner Energy
|
|
for setpoint2 in ENERGIES:
|
|
#Energy.put(setpoint2, timeout=None) # TODO: Set appropriate timeout
|
|
energy.write(setpoint2)
|
|
sleep( ENERGY_CHANGE_SLEEP ) # Settling time
|
|
|
|
#TODO: change to Controlled variable?
|
|
readback2 = energy_readback.read() #EnergyReadback.get()
|
|
if abs(readback2 - setpoint2) > 0.1 : # TODO: Check accuracy
|
|
raise Exception('Energy could not be set to the value ' + str(setpoint2))
|
|
|
|
#Detector field readback
|
|
field_readback = field_x.readback.read() #fieldReadback.get()
|
|
|
|
detector1 = signal_tey.read() #TEY.get()
|
|
detector2 = signal_i0.read() #I0.get()
|
|
detector3 = signal_trans.read() #trans.get()
|
|
detector4 = float(pol_mode.getPositions().index(pol_mode.readback.read())) #polarization.get()
|
|
detector5 = pol_angle.read() #polAngle.get()
|
|
detector6 = temperature.read() #temperature.get()
|
|
detector7 = current.read()
|
|
detector8 = 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])
|
|
|
|
if field_x_done.read() == 1: #If not ramping #ramp_done.get() == 1:
|
|
print "Not ramping, breaking execution"
|
|
break
|
|
index = index+1
|
|
|
|
#Closing channels
|
|
#Energy.close()
|
|
#EnergyReadback.close()
|
|
#TEY.close()
|
|
#I0.close()
|
|
#trans.close()
|
|
#polarization.close()
|
|
#polAngle.close()
|
|
#temperature.close()
|
|
#RingCurrent.close()
|
|
#fieldAnalogX.close()
|
|
#field.close()
|
|
#fieldReadback.close()
|
|
#ramp_done.close()
|
|
|
|
scan.end()
|