Script execution
This commit is contained in:
+112
-157
@@ -1,157 +1,112 @@
|
|||||||
#Script imported from: Fe_hyst_plus.xml
|
#Parameters
|
||||||
|
"""
|
||||||
#Parameters
|
FIELD = "Hx"
|
||||||
START_FIELD = -0.2
|
START_FIELD = -0.1
|
||||||
END_FIELD = 0.2
|
END_FIELD = 0.1
|
||||||
ENERGIES = (707.90, 703.90)
|
ENERGIES = (707.90, 703.90)
|
||||||
RAMP_RATE = 2.0
|
RAMP_RATE = 0.2
|
||||||
ENERGY_CHANGE_SLEEP = 0.5
|
ENERGY_CHANGE_SLEEP = 0.5
|
||||||
|
MODE = 'CIRC +'
|
||||||
#Pre-actions
|
OFFSET = -1.0
|
||||||
#cawait('ACOAU-ACCU:OP-MODE', 'Light Available', type = 's')
|
"""
|
||||||
#caput('X07MA-ID:MODE', 'CIRC +')
|
|
||||||
sleep(1.0)
|
|
||||||
#cawait('X07MA-ID:DONE', 'DONE', ype = 's')
|
iPS = False # false for old power supply, True for new (Oxford Instr) supply
|
||||||
#caput('X07MA-ID:ENERGY-OFFS', '-1.0')
|
|
||||||
#cawait('X07MA-ID:DONE', 'DONE', type = 's')
|
#close_shutter_at_zero = False # True to close shutter during B field scan when it is close to 0 T
|
||||||
caputq('X07MA-PC:CSCALER.INPB', '1')
|
#signal_field_analog_x
|
||||||
caputq('X07MA-PC-PS2:SET:DMD:RAMPRATE:TPM', RAMP_RATE)
|
|
||||||
#sleep(15.0)
|
|
||||||
|
FIELD_PRECISION = 0.01
|
||||||
if len(ENERGIES) ==2:
|
|
||||||
dif_series = plot([],"Dif", title="Dif")[0].getSeries(0)
|
field = cv
|
||||||
else:
|
field_done = di
|
||||||
dif_series = None
|
|
||||||
|
#Pre-actions
|
||||||
set_preference(Preference.ENABLED_PLOTS, ['field', 'tey_norm', 'trans_norm'])
|
#cawait('ACOAU-ACCU:OP-MODE', 'Light Available', type = 's')
|
||||||
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'])
|
|
||||||
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()
|
|
||||||
|
if len(ENERGIES) ==2:
|
||||||
#Stop condition
|
# dif_series = plot([],"Dif", get_context()="Dif")[0].getSeries(0)
|
||||||
ramp_done = Channel('X07MA-PC-MAG:X:RAMP:DONE', type = 'i')
|
dif_series = plot([],"Dif")[0].getSeries(0)
|
||||||
|
else:
|
||||||
#Creating channels: dimension 1
|
dif_series = None
|
||||||
#RegionPositioner field
|
|
||||||
#field = Channel('X07MA-PC:GO', type = 'd')
|
set_preference(Preference.ENABLED_PLOTS, ['field', 'tey_norm', 'trans_norm'])
|
||||||
fieldReadback = Channel('X07MA-PC-PS2:STS:PMCURRENT', type = 'd')
|
set_preference(Preference.PLOT_TYPES, {'tey_norm':1, 'trans_norm':1})
|
||||||
#Creating channels: dimension 2
|
|
||||||
#ArrayPositioner Energy
|
field_var = 'fieldAnalogZ' if (FIELD == "Hz") else 'fieldAnalogX'
|
||||||
Energy = sim_energy #Channel('X07MA-PHS-E:GO.A', type = 'd')
|
scan = ManualScan(['field', 'Energy'], ['TEY', 'I0', 'trans', 'polarization', 'polAngle', 'temperature', 'RingCurrent', \
|
||||||
EnergyReadback = sim_energy_readback # Channel('X07MA-PGM:CERBK', type = 'd')
|
field_var, 'tey_norm','trans_norm'], [0.0, ENERGIES[0]], [0.0, ENERGIES[-1]], [0, len(ENERGIES)-1])
|
||||||
#ScalarDetector TEY
|
scan.start()
|
||||||
TEY = Channel('X07MA-ES1-AI:SIGNAL0', type = 'd')
|
|
||||||
#ScalarDetector I0
|
|
||||||
I0 = Channel('X07MA-ES1-AI:SIGNAL1', type = 'd')
|
print "Waiting for start field"
|
||||||
#ScalarDetector trans
|
|
||||||
trans = Channel('X07MA-ES1-AI:SIGNAL2', type = 'd')
|
#if abs(field.readback.read() - START_FIELD) > FIELD_PRECISION:
|
||||||
#ScalarDetector polarization
|
# field.write(START_FIELD)
|
||||||
#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')
|
print "Set energy..."
|
||||||
#ScalarDetector RingCurrent
|
setpoint2 = ENERGIES[0]
|
||||||
RingCurrent = Channel('ARIDI-PCT:CURRENT', type = 'd')
|
print setpoint2
|
||||||
#ScalarDetector fieldAnalogX
|
energy.write(setpoint2)
|
||||||
fieldAnalogX = Channel('X07MA-ES1-AI:SIGNAL4', type = 'd')
|
sleep( ENERGY_CHANGE_SLEEP ) # Settling time
|
||||||
|
|
||||||
|
|
||||||
print "Waiting for start field"
|
|
||||||
"""
|
index = 0
|
||||||
#WORKAROUND TO BUG IN DRIVER
|
|
||||||
if abs(fieldReadback.get() - START_FIELD) < 0.005:
|
while(True):
|
||||||
caput('X07MA-PC-PS2:M:GO.A', START_FIELD + 0.01)
|
#Dimension 2START_FIELD = -0.2
|
||||||
caput('X07MA-PC-PS2:M:GO.A', START_FIELD)
|
#ArrayPositioner Energy
|
||||||
#caputq('X07MA-PC-PS2:M:GO.A', START_FIELD)
|
for setpoint2 in ENERGIES:
|
||||||
"""
|
if len (ENERGIES)>1:
|
||||||
|
#Energy.put(setpoint2, timeout=None) # TODO: Set appropriate timeout
|
||||||
caput("X07MA-PC-MAG:X:DMD", START_FIELD)
|
energy.write(setpoint2)
|
||||||
caput("X07MA-PC-MAG:STARTRAMP.PROC", 1)
|
|
||||||
ramp_done.wait_for_value(1.0)
|
#TODO: change to Controlled variable?
|
||||||
print "Set end field"
|
readback2 = energy.read() + 0.001 #EnergyReadback.get()
|
||||||
caput("X07MA-PC-MAG:X:DMD", END_FIELD)
|
if abs(readback2 - setpoint2) > 0.1 : # TODO: Check accuracy
|
||||||
caputq("X07MA-PC-MAG:STARTRAMP.PROC", 1)
|
# 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)
|
||||||
index = 0
|
|
||||||
while(True):
|
#Detector field readback
|
||||||
#ArrayPositioner Energy
|
field_readback = field.readback.read() #fieldReadback.get()
|
||||||
for setpoint2 in ENERGIES:
|
|
||||||
Energy.put(setpoint2, timeout=None) # TODO: Set appropriate timeout
|
detector1 = 1.0 #signal_tey.read() #TEY.get()
|
||||||
sleep( ENERGY_CHANGE_SLEEP ) # Settling time
|
detector2 = 2.0 #signal_i0.read() #I0.get()
|
||||||
|
detector3 = 3.0 #signal_trans.read() #trans.get()
|
||||||
readback2 = EnergyReadback.get()
|
detector4 = 4.0 #float(pol_mode.getPositions().index(pol_mode.readback.read())) #polarization.get()
|
||||||
if abs(readback2 - setpoint2) > 0.1 : # TODO: Check accuracy
|
detector5 = 5.0 #pol_angle.read() #polAngle.get()
|
||||||
raise Exception('Actor Energy could not be set to the value ' + str(setpoint2))
|
detector6 = 6.0 #temperature.readback.read() #temperature.get()
|
||||||
|
detector7 = 7.0 #current.read()
|
||||||
#Detector field readback
|
detector8 = 8.0 #signal_field_analog_z.read() if FIELD =="Hz" else signal_field_analog_x.read() # fieldAnalogX.get()
|
||||||
field_readback = fieldReadback.get()
|
|
||||||
|
_tey_norm = detector1/detector2
|
||||||
#Detector TEY
|
_trans_norm = detector3/detector2
|
||||||
detector1 = TEY.get()
|
|
||||||
#Detector I0
|
if dif_series is not None:
|
||||||
detector2 = I0.get()
|
if setpoint2 == ENERGIES[0]:
|
||||||
#Detector trans
|
first = _tey_norm
|
||||||
detector3 = trans.get()
|
else:
|
||||||
#Detector polarization
|
dif = _tey_norm-first
|
||||||
detector4 = sim_energy_readback.read() # polarization.get()
|
dif_series.appendData(field_readback,dif)
|
||||||
#Detector polAngle
|
scan.append ([field_readback, setpoint2], [field_readback, readback2], [detector1, detector2, detector3, detector4, detector5, detector6, detector7, detector8, _tey_norm, _trans_norm])
|
||||||
detector5 = sim_energy_readback.read() #polAngle.get()
|
#after_sample() #To call check_id_error()
|
||||||
#Detector temperature
|
|
||||||
detector6 = temperature.get()
|
if index>100:
|
||||||
#Detector RingCurrent
|
print "Field has reached target, breaking execution."
|
||||||
detector7 = RingCurrent.get()
|
break
|
||||||
#Detector fieldAnalogX
|
|
||||||
detector8 = fieldAnalogX.get()
|
index = index+1
|
||||||
|
|
||||||
|
scan.end()
|
||||||
#Manipulation tey_norm
|
|
||||||
#Variable Mappings
|
|
||||||
|
|
||||||
#TODO: Move, if needed, this import to the file header: import math
|
|
||||||
tey_norm = detector1/detector2
|
|
||||||
|
|
||||||
#Manipulation trans_norm
|
|
||||||
#Variable Mappings
|
|
||||||
|
|
||||||
#TODO: Move, if needed, this import to the file header: import math
|
|
||||||
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)
|
|
||||||
print [field_readback, setpoint2]
|
|
||||||
print [field_readback, readback2]
|
|
||||||
print [detector1, detector2, detector3, detector4, detector5, detector6, detector7, detector8, tey_norm, trans_norm]
|
|
||||||
scan.append ([field_readback, setpoint2], [field_readback, readback2], [detector1, detector2, detector3, detector4, detector5, detector6, detector7, detector8, tey_norm, trans_norm])
|
|
||||||
|
|
||||||
|
|
||||||
print "Field = " + str(fieldReadback.get())
|
|
||||||
if ramp_done.get() == 1: #If not ramping
|
|
||||||
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()
|
|
||||||
|
|||||||
Reference in New Issue
Block a user