Startup
This commit is contained in:
115
script/test/HystScanBackup.py
Normal file
115
script/test/HystScanBackup.py
Normal file
@@ -0,0 +1,115 @@
|
||||
#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
|
||||
"""
|
||||
|
||||
|
||||
FIELD_PRECISION = 0.01
|
||||
field = field_z if FIELD == "Hz" else field_x
|
||||
field_done = field_z_done if FIELD == "Hz" else field_x_done
|
||||
ramp_rate = ramp_rate_z if FIELD == "Hz" else ramp_rate_x
|
||||
|
||||
#Pre-actions
|
||||
#cawait('ACOAU-ACCU:OP-MODE', 'Light Available', type = 's')
|
||||
wait_beam()
|
||||
if MODE is not None:
|
||||
pol_mode.write(MODE)
|
||||
if OFFSET is not None:
|
||||
pol_offset.write(OFFSET) #caput('X07MA-ID:ENERGY-OFFS', OFFSET)
|
||||
caputq('X07MA-PC:CSCALER.INPB', '1')
|
||||
if RAMP_RATE is not None:
|
||||
ramp_rate.write(RAMP_RATE)
|
||||
ramp_rate.waitInPosition(RAMP_RATE,10000)
|
||||
|
||||
|
||||
|
||||
if len(ENERGIES) ==2:
|
||||
# dif_series = plot([],"Dif", 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})
|
||||
|
||||
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()
|
||||
|
||||
|
||||
|
||||
print "SKIPPED Waiting for start field"
|
||||
|
||||
if abs(field.readback.read() - START_FIELD) > FIELD_PRECISION:
|
||||
field.write(START_FIELD)
|
||||
time.sleep(3.0)
|
||||
wait_device(field_done, 1) #ramp_done.wait_for_value(1.0)
|
||||
wait_device(pol_done, "DONE")
|
||||
|
||||
#open(2.0)
|
||||
|
||||
print "Set end field"
|
||||
field.write(END_FIELD) #caputq('X07MA-PC-PS2:M:GO.A', END_FIELD)
|
||||
|
||||
|
||||
if len (ENERGIES)==1:
|
||||
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)
|
||||
sleep( ENERGY_CHANGE_SLEEP ) # Settling time
|
||||
else:
|
||||
sleep( 0.1 ) # TODO: Check
|
||||
|
||||
#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.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_readback.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_done.read() == 1: #If not ramping #ramp_done.get() == 1:
|
||||
if abs(field_readback - END_FIELD) < 0.007:
|
||||
print "Field has reached target, breaking execution."
|
||||
break
|
||||
index = index+1
|
||||
|
||||
scan.end()
|
||||
|
||||
if RAMP_RATE is not None:
|
||||
ramp_rate.write(2.0)
|
||||
ramp_rate.waitInPosition(2.0,10000)
|
||||
|
||||
Reference in New Issue
Block a user