Version 1.14
This commit is contained in:
@@ -23,7 +23,7 @@ edata.initialize()
|
||||
p=None
|
||||
def start_plot():
|
||||
global p
|
||||
p = plot([None, None, None,None, None], ["TEY", "TFY", "TEYraw", "TFYraw", "I0"])
|
||||
p = plot([None, None, None,None, None], ["TEY_norm", "diode_norm", "TEY_raw", "diode_raw", "I0"])
|
||||
|
||||
def _update_plots(p, x, s0, s1, s2, s3, s4):
|
||||
p[0].getSeries(0).setData(x, s0)
|
||||
@@ -141,8 +141,7 @@ while True:
|
||||
print "It is done."
|
||||
############
|
||||
"""
|
||||
|
||||
|
||||
caput('X07MA-PGM:CERBK.N',10) # set energy readback averaging to 10 pts
|
||||
|
||||
caput('E1', E1)
|
||||
#print "caput E1" #add for debug
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
import java.awt.Color as Color
|
||||
if get_exec_pars().source == CommandSource.ui:
|
||||
ID_ENERGY = 1250
|
||||
HALFWIDTH = 10
|
||||
STEP = 0.5
|
||||
MODE = "Manual"
|
||||
|
||||
DRY_MODE = False
|
||||
|
||||
|
||||
try:
|
||||
if not DRY_MODE:
|
||||
caput('X07MA-PHS-E:OPT', 'PGM')
|
||||
energy_id.write(ID_ENERGY)
|
||||
wait_device(energy_done, 1 )
|
||||
sensors = [signal_i0, signal_tey, 'ca://X07MA-PC-K428:2:getTotalGain', energy]
|
||||
|
||||
if MODE =="C+":
|
||||
set_pol_cplus()
|
||||
if MODE =="C-":
|
||||
set_pol_cminus()
|
||||
if MODE == "LH":
|
||||
set_pol_lin(0.0)
|
||||
elif MODE == "LV":
|
||||
set_pol_lin(90.0)
|
||||
current_offset = pol_offset.take()
|
||||
|
||||
else:
|
||||
sensors = [sin, energy]
|
||||
current_offset = 0.0
|
||||
|
||||
ret = lscan(energy, sensors, ID_ENERGY-HALFWIDTH, ID_ENERGY+HALFWIDTH, STEP, latency = 0.3)
|
||||
|
||||
xdata = ret.getPositions(0)
|
||||
ydata = ret.getReadable(0)
|
||||
ymin = min(ydata)
|
||||
e0 = xdata[ydata.index(min(ydata))]
|
||||
new_offset =ID_ENERGY - e0 + current_offset
|
||||
print "E0=",e0," ymin=",ymin," Offset=",new_offset
|
||||
p=get_plots()[0]
|
||||
p.addMarker(e0, p.AxisId.X, "%0.2f" % e0, Color.BLUE)
|
||||
set_return(new_offset)
|
||||
|
||||
except:
|
||||
print("Aborting...")
|
||||
raise
|
||||
finally:
|
||||
if not DRY_MODE:
|
||||
caput('X07MA-PHS-E:OPT', 'PGM+ID')
|
||||
|
||||
@@ -1,23 +1,24 @@
|
||||
#####################
|
||||
## INPUT PARAMETERS##
|
||||
#POS_START = 158.4 #Min = 150.0
|
||||
#POS_END = 159.9 #Max = 170.0
|
||||
POS_START = 157.0 #Min = 150.0
|
||||
POS_END = 162.0 #Max = 170.0
|
||||
|
||||
POS_START = 156.0 #Minn = 150.0
|
||||
POS_END = 162 #Max = 170.0
|
||||
POS_STEP = 0.25
|
||||
|
||||
|
||||
#ENERGIES = [363.2, 356.0]# Nb
|
||||
#ENERGIES = [774.0] # Co
|
||||
#ENERGIES = [774. 0] # Co
|
||||
#ENERGIES = [577.0, 573.0] # Cr
|
||||
#ENERGIES = [708.3,704.0] # Fe
|
||||
#ENERGIES = [928.4, 925.0 ] # Cu
|
||||
#ENERGIES = [700.0]
|
||||
#ENERGIES = [706.7,708.3,704.0] # Fe
|
||||
ENERGIES = [851.3,845]#[851.2,848.0] # Ni
|
||||
#ENERGIES = [851.3,845]#[851.2,848.0] # Ni
|
||||
#ENERGIES = [280,292] #C
|
||||
#ENERGIES = [772,776.7] # Co
|
||||
#ENERGIES = [776.9,774] # Co
|
||||
#ENERGIES = [642.0,630.0] # Mn
|
||||
ENERGIES = [1067, 1076 ] # Sm
|
||||
#ENERGIES = [870, 880.3 ] # Ce
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,27 +1,30 @@
|
||||
#####################
|
||||
## INPUT PARAMATERS##
|
||||
#open_valve()
|
||||
POS_START = 104 #Min = 98.0
|
||||
POS_END = 114 #Max = 118.0
|
||||
POS_STEP = 0.25
|
||||
POS_START = 106 #Min = 98.0
|
||||
POS_END = 110 #Max = 118.0
|
||||
POS_STEP = 0.5
|
||||
|
||||
#POS_START = 106
|
||||
#POS_END = 116
|
||||
|
||||
#"""
|
||||
#POS_START =106 #Min = 98.0
|
||||
#POS_END = 108.7
|
||||
#POS_START =108 #Min = 98.0
|
||||
#POS_END = 115
|
||||
#Max = 118.0
|
||||
#POS_STEP = 0.1
|
||||
#"""
|
||||
#ENERGIES = [1344.5, 1338] # Ho edge, pre-edge
|
||||
#ENERGIES = [1289.5, 1280] # Dy edge, pre-edge
|
||||
#ENERGIES = [459,455] #Ti
|
||||
#ENERGIES = [459.5,455] #Ti
|
||||
#ENERGIES = [363.2, 356.0]# Nb
|
||||
#ENERGIES = [260.0]# C
|
||||
#ENERGIES = [285.0,280]# C
|
||||
#ENERGIES = [285.2,280]# C
|
||||
#ENERGIES = [395,390] #Mo
|
||||
#ENERGIES = [780.0,777.0]
|
||||
#ENERGIES = [396.0] # N
|
||||
#ENERGIES = [397.6, 395.0] # N
|
||||
#ENERGIES = [385.0]# C
|
||||
#ENERGIES = [576.3, 560.0] #Cr
|
||||
#ENERGIES = [570.0,576.3] #Cr
|
||||
#ENERGIES = [1850, 1820]# Si
|
||||
#ENERGIES = [530] #O
|
||||
#ENERGIES = [397.7,392] # Pc
|
||||
@@ -30,14 +33,16 @@ POS_STEP = 0.25
|
||||
#ENERGIES = [642.0,630.0] # Mn
|
||||
#ENERGIES = [463,457]
|
||||
#ENERGIES = [637.8,638.9,640.1,636.0] # Mn
|
||||
#ENERGIES = [700.0] # Fe
|
||||
#ENERGIES = [928.2, 925] #CuO
|
||||
#ENERGIES = [700.0,708.5] # Fe
|
||||
#ENERGIES = [928.4, 925] #Cu
|
||||
#ENERGIES = [931.7, 925] #Cu
|
||||
#ENERGIES = [929] #Cu
|
||||
#ENERGIES = [929.3] #Cu
|
||||
#ENERGIES = [927, 929] #Cu
|
||||
#ENERGIES = [928.5, 931] #CuGly special
|
||||
#ENERGIES = [402, 397] # Ta
|
||||
#ENERGIES = [777.3,774] # Co
|
||||
#ENERGIES = [778] # Co
|
||||
#ENERGIES = [851.3,845.0] # Ni
|
||||
#ENERGIES = [848.5, 845] # La
|
||||
#ENERGIES = [465.0,450.0] # STO
|
||||
#ENERGIES = [1234.5, 1225 ] # Tb
|
||||
#ENERGIES = [976, 970] # Nd
|
||||
@@ -54,9 +59,9 @@ POS_STEP = 0.25
|
||||
#ENERGIES = [1456.9, 1450 ] # Tm
|
||||
#ENERGIES = [931.7, 925.0] # Cu metal
|
||||
#ENERGIES = [928.4 ] # Cu1
|
||||
#ENERGIES = [700.0, 708.0] # Fe
|
||||
ENERGIES = [708.3, 700.0] # Fe
|
||||
#ENERGIES = [696.7, 680.0] # F
|
||||
ENERGIES = [692.0] # F
|
||||
#ENERGIES = [692.0] # F
|
||||
#ENERGIES = [782.50, 775.0] # Ba
|
||||
#ENERGIES = [782.50] # Ba
|
||||
#ENERGIES = [1289, 1280] # Dy edge
|
||||
@@ -66,6 +71,9 @@ ENERGIES = [692.0] # F
|
||||
#ENERGIES = [850.9, 849 ] # Ni
|
||||
#ENERGIES = [516, 503] # V
|
||||
#ENERGIES = [1455,1420] # Se
|
||||
#ENERGIES = [1181.0,1173.0]
|
||||
#ENERGIES = [285.1, 280.0]# C
|
||||
#ENERGIES = [1650.0]
|
||||
#####################
|
||||
|
||||
open_valve()
|
||||
@@ -100,4 +108,8 @@ def before_pass(pass_num):
|
||||
|
||||
ret= lscan(sample_hor,sensors, POS_START, POS_END, POS_STEP, latency = 0.0, passes = len(ENERGIES), before_pass = before_pass, after_read=after_readout, plot_disabled=True, range="auto")
|
||||
|
||||
#if name is None:
|
||||
# name=get_scan_filename()
|
||||
#print "Created data file: " + str(name)
|
||||
|
||||
close_valve()
|
||||
|
||||
@@ -0,0 +1,196 @@
|
||||
#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
|
||||
|
||||
|
||||
if iPS == True:
|
||||
caput('X07MA-ES1-IPS:RAMP-ENBL', 1) # enable non-overshoot mode
|
||||
|
||||
FIELD_PRECISION = 0.01
|
||||
if FIELD == field_z: FIELD = "Hz"
|
||||
field = field_z if FIELD == "Hz" else (field_x_ips if iPS else field_x )
|
||||
field_done = field_z_done if FIELD == "Hz" else (None if iPS else field_x_done)
|
||||
ramp_rate = ramp_rate_z if FIELD == "Hz" else (ramp_rate_x_ips if iPS else ramp_rate_x)
|
||||
|
||||
#Pre-actions
|
||||
#cawait('ACOAU-ACCU:OP-MODE', 'Light Available', type = 's')
|
||||
|
||||
if NO_BEAM_CHECK == False:
|
||||
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')
|
||||
|
||||
# open shutter
|
||||
caput('X07MA-FE-PH1:CLOSE4BL',1)
|
||||
cawait('X07MA-FE-PH1:MS2', 1)
|
||||
print "OK"
|
||||
|
||||
#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", 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,'ESR_extrachannel', 'tey_norm','trans_norm'], [0.0, ENERGIES[0]], [0.0, ENERGIES[-1]], [0, len(ENERGIES)-1])
|
||||
scan.start()
|
||||
|
||||
write_logs()
|
||||
|
||||
print "Waiting for start field"
|
||||
|
||||
if abs(field.readback.read() - START_FIELD) > FIELD_PRECISION:
|
||||
ramp_rate.write(2.0)
|
||||
field.write(START_FIELD)
|
||||
if iPS == True:
|
||||
caput("X07MA-PC-MAG:X:DMD",float(START_FIELD))
|
||||
|
||||
if field_done is None:
|
||||
#ramp_rate.write(2.0)
|
||||
ramp_rate.waitInPosition(2.0,10000)
|
||||
time.sleep(1.0)
|
||||
caput("X07MA-ES1-IPS:ACTION", 1)
|
||||
time.sleep(3.0)
|
||||
wait_device_in_range(field, START_FIELD, FIELD_PRECISION)
|
||||
print "Waiting field done..."
|
||||
while caget("X07MA-ES1-IPS:OUTPUT_RBV", "i") != 0 :
|
||||
time.sleep(0.1)
|
||||
print "Done waiting"
|
||||
else:
|
||||
time.sleep(3.0)
|
||||
wait_device(field_done, 1) #ramp_done.wait_for_value(1.0)
|
||||
|
||||
|
||||
#open_valve(2.0)
|
||||
|
||||
|
||||
|
||||
print "Set energy..."
|
||||
setpoint2 = ENERGIES[0]
|
||||
print setpoint2
|
||||
energy.write(setpoint2)
|
||||
sleep( ENERGY_CHANGE_SLEEP ) # Settling time
|
||||
|
||||
wait_device(energy_done, 1 )
|
||||
|
||||
wait_device(pol_done, "DONE")
|
||||
|
||||
|
||||
#if WAIT_STABLE_TEMPERATURE == True:
|
||||
# wait_temp()
|
||||
|
||||
|
||||
if RAMP_RATE is not None:
|
||||
ramp_rate.write(RAMP_RATE)
|
||||
ramp_rate.waitInPosition(RAMP_RATE,10000)
|
||||
|
||||
print "Set end field"
|
||||
field.write(END_FIELD) #caputq('X07MA-PC-PS2:M:GO.A', END_FIELD)
|
||||
|
||||
if iPS == True:
|
||||
caput("X07MA-PC-MAG:X:DMD",float(END_FIELD))
|
||||
|
||||
|
||||
|
||||
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.25 ) # 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))
|
||||
#print 'Energy could not be set to the value, try again. ' + str(setpoint2)
|
||||
energy.write(setpoint2)
|
||||
sleep( ENERGY_CHANGE_SLEEP ) # Settling time
|
||||
|
||||
while True: # if ABORT_ON_ID_ERROR == False, waits reading with no ID error
|
||||
#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_z.read() if FIELD =="Hz" else signal_field_analog_x.read() # fieldAnalogX.get()
|
||||
# ESR HACK
|
||||
detector9 = signal_field_analog_z.read() # USE ADC4 here as additional detector
|
||||
|
||||
_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)
|
||||
if after_sample(): #To call check_id_error()
|
||||
break
|
||||
scan.append ([field_readback, setpoint2], [field_readback, readback2], [detector1, detector2, detector3, detector4, detector5, detector6, detector7, detector8, detector9, _tey_norm, _trans_norm])
|
||||
|
||||
#if field_done.read() == 1: #If not ramping #ramp_done.get() == 1:
|
||||
#if abs(field_readback - END_FIELDafter) < 0.007: REMOVED by Jan
|
||||
if abs(field_readback - END_FIELD) < 0.007:
|
||||
if iPS==True:
|
||||
print "Waiting field done..."
|
||||
while caget("X07MA-ES1-IPS:OUTPUT_RBV", "i") != 0 :
|
||||
time.sleep(0.1)
|
||||
print "Done waiting"
|
||||
|
||||
print "Field has reached target, breaking execution."
|
||||
break
|
||||
index = index+1
|
||||
|
||||
scan.end()
|
||||
|
||||
log_scan_filename()
|
||||
|
||||
if RAMP_RATE is not None:
|
||||
if FIELD == "Hz":
|
||||
print "Reset ramp rate-z"
|
||||
ramp_rate.write(0.35)
|
||||
ramp_rate.waitInPosition(0.35,10000)
|
||||
else:
|
||||
print "Reset ramp rate-x"
|
||||
ramp_rate.write(2.0)
|
||||
ramp_rate.waitInPosition(2.0,10000)
|
||||
|
||||
@@ -0,0 +1,50 @@
|
||||
#####################
|
||||
## INPUT PARAMETERS##
|
||||
POS_START = 150
|
||||
POS_END = 175
|
||||
POS_STEP = 0.5
|
||||
|
||||
|
||||
#ENERGIES = [704.0,708.7] # Fe
|
||||
ENERGIES = [630] #
|
||||
|
||||
#####################
|
||||
|
||||
#open_valve()
|
||||
#caput("X07MA-OP-VG13:WT_SET",1)
|
||||
#time.sleep(0.1)
|
||||
|
||||
sensors = [tey_norm, signal_tey, signal_i0, signal_trans, trans_norm, sample_hor, energy_readback]
|
||||
#sensors = [ signal_tey, signal_i0, sample_hor, energy_readback]
|
||||
#sensors_name = ['tey_norm', 'signal_tey', 'signal_i0', 'trans_norm', 'sample_hor', 'energy_readback']
|
||||
#sensors_name = ['signal_tey', 'signal_i0', 'sample_hor', 'energy_readback']
|
||||
|
||||
|
||||
#TODO: #Why must set range to "auto"?
|
||||
"""
|
||||
def before_pass(pass_num, scan):
|
||||
print "Setting energy = " , ENERGIES[pass_num-1]
|
||||
set_energy(ENERGIES[pass_num-1])
|
||||
lscan(sample_vert,sensors, POS_START, POS_END, POS_STEP, latency =0.5, passes = len(ENERGIES), before_pass=before_pass, range="auto")
|
||||
"""
|
||||
|
||||
#Setting a different color for each pass: must manage plots manually
|
||||
plots = plot([None]*len(sensors), name = [d.name for d in sensors])
|
||||
for p in plots:
|
||||
p.clear()
|
||||
p.legendVisible = True
|
||||
|
||||
def after_readout(record, scan):
|
||||
for i in range(len(plots)):
|
||||
plots[i].getSeries(plots[i].numberOfSeries-1).appendData(record.positions[0], record.values[i])
|
||||
def before_pass(pass_num):
|
||||
en = ENERGIES[pass_num-1]
|
||||
set_energy(en)
|
||||
open_valve()
|
||||
for p in plots: p.addSeries(LinePlotSeries(str(en)))
|
||||
|
||||
ret70= lscan(gold_mesh,sensors, POS_START, POS_END, POS_STEP, latency = 0.25, passes = len(ENERGIES), before_pass = before_pass, after_read=after_readout, plot_disabled=True, range="auto")
|
||||
|
||||
|
||||
|
||||
close_valve()
|
||||
+2
-1
@@ -5,7 +5,8 @@ POS_END = -60
|
||||
POS_STEP = 0.5
|
||||
|
||||
|
||||
ENERGIES = [704.0,708.7] # Fe
|
||||
#ENERGIES = [704.0,708.7] # Fe
|
||||
ENERGIES = [630] #
|
||||
|
||||
#####################
|
||||
|
||||
|
||||
@@ -0,0 +1,198 @@
|
||||
#Parameters
|
||||
"""
|
||||
FIELD = "Hx"
|
||||
START_FIELD = -0.1
|
||||
ACQPOINTS = 100
|
||||
ENERGIES = (707.90, 703.90)
|
||||
ENERGY_CHANGE_SLEEP = 2.0
|
||||
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
|
||||
|
||||
|
||||
if iPS == True:
|
||||
caput('X07MA-ES1-IPS:RAMP-ENBL', 1) # enable non-overshoot mode
|
||||
|
||||
FIELD_PRECISION = 0.01
|
||||
if FIELD == field_z: FIELD = "Hz"
|
||||
field = field_z if FIELD == "Hz" else (field_x_ips if iPS else field_x )
|
||||
field_done = field_z_done if FIELD == "Hz" else (None if iPS else field_x_done)
|
||||
ramp_rate = ramp_rate_z if FIELD == "Hz" else (ramp_rate_x_ips if iPS else ramp_rate_x)
|
||||
|
||||
#Pre-actions
|
||||
#cawait('ACOAU-ACCU:OP-MODE', 'Light Available', type = 's')
|
||||
|
||||
if NO_BEAM_CHECK == False:
|
||||
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')
|
||||
|
||||
# open shutter
|
||||
caput('X07MA-FE-PH1:CLOSE4BL',1)
|
||||
cawait('X07MA-FE-PH1:MS2', 1)
|
||||
print "OK"
|
||||
|
||||
#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", get_context()="Dif")[0].getSeries(0)
|
||||
dif_series = plot([],"Dif")[0].getSeries(0)
|
||||
else:
|
||||
dif_series = None
|
||||
|
||||
set_preference(Preference.ENABLED_PLOTS, ['field', 'TEY', 'trans','ESR_extrachannel'])
|
||||
#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,'ESR_extrachannel', 'tey_norm','trans_norm'], [0.0, ENERGIES[0]], [0.0, ENERGIES[-1]], [0, len(ENERGIES)-1])
|
||||
scan.start()
|
||||
|
||||
write_logs()
|
||||
|
||||
print "Waiting for start field"
|
||||
|
||||
if abs(field.readback.read() - START_FIELD) > FIELD_PRECISION:
|
||||
ramp_rate.write(2.0)
|
||||
field.write(START_FIELD)
|
||||
if iPS == True:
|
||||
caput("X07MA-PC-MAG:X:DMD",float(START_FIELD))
|
||||
|
||||
if field_done is None:
|
||||
#ramp_rate.write(2.0)
|
||||
ramp_rate.waitInPosition(2.0,10000)
|
||||
time.sleep(1.0)
|
||||
caput("X07MA-ES1-IPS:ACTION", 1)
|
||||
time.sleep(3.0)
|
||||
wait_device_in_range(field, START_FIELD, FIELD_PRECISION)
|
||||
print "Waiting field done..."
|
||||
while caget("X07MA-ES1-IPS:OUTPUT_RBV", "i") != 0 :
|
||||
time.sleep(0.1)
|
||||
print "Done waiting"
|
||||
else:
|
||||
time.sleep(3.0)
|
||||
wait_device(field_done, 1) #ramp_done.wait_for_value(1.0)
|
||||
|
||||
|
||||
#open_valve(2.0)
|
||||
|
||||
|
||||
|
||||
print "Set energy..."
|
||||
setpoint2 = ENERGIES[0]
|
||||
print setpoint2
|
||||
energy.write(setpoint2)
|
||||
sleep( ENERGY_CHANGE_SLEEP ) # Settling time
|
||||
|
||||
wait_device(energy_done, 1 )
|
||||
|
||||
wait_device(pol_done, "DONE")
|
||||
|
||||
|
||||
#if WAIT_STABLE_TEMPERATURE == True:
|
||||
# wait_temp()
|
||||
|
||||
|
||||
#if RAMP_RATE is not None:
|
||||
# ramp_rate.write(RAMP_RATE)
|
||||
# ramp_rate.waitInPosition(RAMP_RATE,10000)
|
||||
|
||||
#print "Set end field"
|
||||
#field.write(END_FIELD) #caputq('X07MA-PC-PS2:M:GO.A', END_FIELD)
|
||||
|
||||
#if iPS == True:
|
||||
#caput("X07MA-PC-MAG:X:DMD",float(END_FIELD))
|
||||
|
||||
|
||||
|
||||
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.25 ) # 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))
|
||||
#print 'Energy could not be set to the value, try again. ' + str(setpoint2)
|
||||
energy.write(setpoint2)
|
||||
sleep( ENERGY_CHANGE_SLEEP ) # Settling time
|
||||
|
||||
while True: # if ABORT_ON_ID_ERROR == False, waits reading with no ID error
|
||||
#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_z.read() if FIELD =="Hz" else signal_field_analog_x.read() # fieldAnalogX.get()
|
||||
# ESR HACK
|
||||
detector9 = signal_field_analog_z.read() # USE ADC4 here as additional detector
|
||||
|
||||
_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)
|
||||
if after_sample(): #To call check_id_error()
|
||||
break
|
||||
scan.append ([field_readback, setpoint2], [field_readback, readback2], [detector1, detector2, detector3, detector4, detector5, detector6, detector7, detector8, detector9, _tey_norm, _trans_norm])
|
||||
|
||||
#if field_done.read() == 1: #If not ramping #ramp_done.get() == 1:
|
||||
#if abs(field_readback - END_FIELDafter) < 0.007: REMOVED by Jan
|
||||
#if abs(field_readback - END_FIELD) < 0.007:
|
||||
# if iPS==True:
|
||||
# print "Waiting field done..."
|
||||
# while caget("X07MA-ES1-IPS:OUTPUT_RBV", "i") != 0 :
|
||||
# time.sleep(0.1)
|
||||
# print "Done waiting"
|
||||
|
||||
#print "Field has reached target, breaking execution."
|
||||
#break
|
||||
index = index+1
|
||||
|
||||
if index == ACQPOINTS:
|
||||
break
|
||||
|
||||
scan.end()
|
||||
|
||||
log_scan_filename()
|
||||
|
||||
#if RAMP_RATE is not None:
|
||||
# if FIELD == "Hz":
|
||||
# print "Reset ramp rate-z"
|
||||
# ramp_rate.write(0.35)
|
||||
# ramp_rate.waitInPosition(0.35,10000)
|
||||
# else:
|
||||
# print "Reset ramp rate-x"
|
||||
# ramp_rate.write(2.0)
|
||||
# ramp_rate.waitInPosition(2.0,10000)
|
||||
|
||||
+35
-21
@@ -1,43 +1,52 @@
|
||||
#####################
|
||||
## INPUT PARAMETERS##
|
||||
#POS_START = 5
|
||||
#POS_END = 25
|
||||
#POS_STEP = 0.5
|
||||
|
||||
POS_START = 9
|
||||
POS_END = 18
|
||||
POS_START =4
|
||||
POS_END = 27
|
||||
POS_STEP = 0.5
|
||||
|
||||
#ENERGIES = [532, 523]# O
|
||||
|
||||
#POS_STEP = 0.1
|
||||
#"""
|
||||
#POS_START = 7
|
||||
#POS_END = 15
|
||||
#POS_STEP = 0.25
|
||||
#"""
|
||||
|
||||
#ENERGIES = [532, 523]#
|
||||
#ENERGIES = [363.2, 356]# Nb
|
||||
#ENERGIES = [782.50, 775.0]
|
||||
#ENERGIES = [397.6, 396.0] # N
|
||||
#ENERGIES = [400.7, 396.0] # N
|
||||
#ENERGIES = [401.1,403] #Mo285
|
||||
#ENERGIES = [577.0, 573.0] # Cr
|
||||
#ENERGIES = [457,452] #Ti
|
||||
#ENERGIES = [459.5,452] #Ti
|
||||
#ENERGIES = [692.0] # F
|
||||
#ENERGIES = [696.5, 680.0] # F
|
||||
#ENERGIES = [1110,1125.5] #STO
|
||||
#ENERGIES = [397.7,392] # Pc
|
||||
ENERGIES = [700.0]#, 708.0] # Fe
|
||||
#ENERGIES = [708.3, 700.0] # Fe
|
||||
#ENERGIES = [530] #O
|
||||
#ENERGIES = [700.0] #Fe
|
||||
|
||||
ENERGIES = [700.0,708.0] #Fe
|
||||
#ENERGIES = [931.7, 925] #Cu
|
||||
#ENERGIES = [928.2, 925] #CuO
|
||||
#ENERGIES = [929] #Cu
|
||||
#ENERGIES = [928.4, 925] #CuO
|
||||
#ENERGIES = [929.3] #Cu
|
||||
#ENERGIES = [927, 929] #Cu
|
||||
#ENERGIES = [928.5, 931] #CuGly special
|
||||
#ENERGIES = [774.0] # Co
|
||||
#ENERGIES = [777.3, 774.0] # Co
|
||||
#ENERGIES = [776.9, 774.0] # Co
|
||||
#ENERGIES = [851.3,842.0] # Ni
|
||||
#ENERGIES = [848.5, 846] # La
|
||||
#ENERGIES = [576.4, 560.0] #Cr
|
||||
#ENERGIES = [570.0,576.3] #Cr
|
||||
#ENERGIES = [485.0,490.0] # Ru
|
||||
#ENERGIES = [638.5,630.0] # Mn
|
||||
#ENERGIES = [642.5,633.0] # Mn
|
||||
#ENERGIES = [465.0,450.0] # STO
|
||||
#ENERGIES = [1067, 1076 ] # Sm
|
||||
#ENERGIES = [870, 880.3 ] # Ce
|
||||
#ENERGIES = [1170, 1181 ] # Gd
|
||||
#ENERGIES = [285] #C
|
||||
#ENERGIES = [1370.0,1380.0] #Er
|
||||
#ENERGIES = [1390.0,1400.6] #Er2
|
||||
#ENERGIES = [1370.0,1380.0] #Er??
|
||||
#ENERGIES = [1400.6,1390.0] #Er
|
||||
#ENERGIES = [1390.0] #Er
|
||||
#ENERGIES = [1300, 1312 ] # Mg
|
||||
#ENERGIES = [1457.8] # Dy
|
||||
#ENERGIES = [1290.0, 1280.0] # Dy
|
||||
@@ -59,13 +68,15 @@ ENERGIES = [700.0]#, 708.0] # Fe
|
||||
#ENERGIES = [1345, 1338] # Ho edge, pre-edge
|
||||
#ENERGIES = [1290] # Dy
|
||||
#ENERGIES = [1125.6]# Eu
|
||||
#ENERGIES = [850.9, 849 ] # Ni
|
||||
#ENERGIES = [774,777.3] # Co
|
||||
#ENERGIES = [516, 503] # V
|
||||
#ENERGIES = [1455,1420] # Se
|
||||
#ENERGIES = [84.3, 80]# Au4F
|
||||
#ENERGIES = [285.1, 280.0]# C
|
||||
|
||||
#ENERGIES = [ 1650.0 ]
|
||||
#####################
|
||||
|
||||
#open_valve()
|
||||
open_valve()
|
||||
#caput("X07MA-OP-VG13:WT_SET",1)
|
||||
#time.sleep(0.1)
|
||||
|
||||
@@ -101,5 +112,8 @@ def before_pass(pass_num):
|
||||
ret70= lscan(sample_vert,sensors, POS_START, POS_END, POS_STEP, latency = 0.25, passes = len(ENERGIES), before_pass = before_pass, after_read=after_readout, plot_disabled=True, range="auto")
|
||||
|
||||
|
||||
#if name is None:
|
||||
# name=get_scan_filename()
|
||||
#print "Created data file: " + str(name)
|
||||
|
||||
close_valve()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
ID_ENERGY = 1234
|
||||
ID_ENERGY = 770
|
||||
|
||||
|
||||
|
||||
|
||||
+17
-1
@@ -306,6 +306,8 @@ def set_pol_cplus(offset = None, timeout = -1):
|
||||
pol_mode.write("CIRC +")
|
||||
if offset is not None:
|
||||
pol_offset.write(float(offset))
|
||||
time.sleep(0.5)
|
||||
pol_done.update()
|
||||
pol_done.waitValue("DONE",timeout)
|
||||
print "Done setting x-ray polarization"
|
||||
|
||||
@@ -317,6 +319,8 @@ def set_pol_cminus(offset = None, timeout = -1):
|
||||
pol_mode.write("CIRC -")
|
||||
if offset is not None:
|
||||
pol_offset.write(float(offset))
|
||||
time.sleep(0.5)
|
||||
pol_done.update()
|
||||
pol_done.waitValue("DONE",timeout)
|
||||
print "Done setting x-ray polarization"
|
||||
|
||||
@@ -329,6 +333,8 @@ def set_pol_lin(angle, offset = None, timeout = -1):
|
||||
pol_angle.write(float(angle))
|
||||
if offset is not None:
|
||||
pol_offset.write(float(offset))
|
||||
time.sleep(0.5)
|
||||
pol_done.update()
|
||||
pol_done.waitValue("DONE",timeout)
|
||||
print "Done setting x-ray polarization"
|
||||
|
||||
@@ -374,7 +380,7 @@ def set_energy (value, delay=0.5):
|
||||
tolerance = 0.3
|
||||
energy.write(float(value))
|
||||
try:
|
||||
energy_done.waitValue(1, timeout_ms) # timeout is now 60, was -1
|
||||
energy_done.waitValue(1, timeout_ms) # timeout is now 90 sec, was -1
|
||||
except:
|
||||
if abs(energy.read() - energy_readback.read()) > tolerance:
|
||||
throw
|
||||
@@ -552,6 +558,16 @@ def hyst_cont(field, init_field, final_field, ramp_speed, energies):
|
||||
"""
|
||||
run("HystScan",{"FIELD":field, "START_FIELD":init_field, "END_FIELD":final_field, "ENERGIES":energies, "RAMP_RATE":ramp_speed, "ENERGY_CHANGE_SLEEP":0.5, "MODE":None, "OFFSET":None})
|
||||
|
||||
def hyst_cont_ESR(field, init_field, final_field, ramp_speed, energies):
|
||||
"""
|
||||
"""
|
||||
run("HystScan_ESR",{"FIELD":field, "START_FIELD":init_field, "END_FIELD":final_field, "ENERGIES":energies, "RAMP_RATE":ramp_speed, "ENERGY_CHANGE_SLEEP":0.5, "MODE":None, "OFFSET":None})
|
||||
|
||||
def acq_cont_ESR(field, init_field, datapoints, energies):
|
||||
"""
|
||||
"""
|
||||
run("TimeScan_ESR",{"FIELD":field, "START_FIELD":init_field, "ACQPOINTS":datapoints, "ENERGIES":energies, "ENERGY_CHANGE_SLEEP":0.5, "MODE":None, "OFFSET":None})
|
||||
|
||||
def hyst_cont_mult(field, ranges, energies):
|
||||
"""
|
||||
"""
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
# magnet initial ramping 0 > 6.9 T
|
||||
# 0 -> 6.9 T at 0.36 T/min
|
||||
# then 6 -> 6.9 T at 0.075 T/min
|
||||
|
||||
# list of pairs [ [target field1, ramp rate1] , [target field2, ramp rate2] , [target field3, ramp rate3] ,... ]
|
||||
field_rate = [ [6.0,0.36], [6.9, 0.075], [6.0, 0.075], [0.0, 1.0] ]
|
||||
#field_rate = [ [0.1,0.25], [0.0, 2.0] ] test
|
||||
|
||||
for fr in field_rate:
|
||||
fi = fr[0]
|
||||
rr = fr[1]
|
||||
if abs(fi) > 7.0:
|
||||
sys.exit("Error in target field value. Aborting.")
|
||||
if rr <= 0. or rr > 2.05:
|
||||
sys.exit("Error in ramp rate value. Aborting.")
|
||||
print("Ramping to "+str(fi)+" T at a ramp rate of "+str(rr)+" T/min...")
|
||||
ramp_rate_x.write(rr)
|
||||
time.sleep(4.0)
|
||||
rr_rbv = caget('X07MA-PC-PS2:STS:RAMPRATE:TPM')
|
||||
print("Read back a ramp rate of "+str(rr_rbv)+" T/min.")
|
||||
if (abs(rr-rr_rbv) > rr * 0.1): # stay within 10%
|
||||
sys.exit("Something went wrong when setting the ramp rate. Demand-readback > "+ str(rr*0.05)+" T/min.")
|
||||
|
||||
set_hx(fi)
|
||||
print ("Target field reached. Waiting 10 seconds.")
|
||||
time.sleep(10.0)
|
||||
|
||||
ramp_rate_x.write(2.0)
|
||||
print ("Done. Everything went well, as far as I know.")
|
||||
@@ -0,0 +1,14 @@
|
||||
|
||||
def set_file(file_name):
|
||||
"""
|
||||
"""
|
||||
#set_exec_pars(name = file_name) #Increment index for each scan, and keep timestamp
|
||||
set_exec_pars(name = file_name, reset=True) #Different timestamp for each scan, index set to 0
|
||||
|
||||
|
||||
def runpy(fname, run_number):
|
||||
print 'running file: %s - run: %d/%d' % (fname, run_number, RUN_COUNT)
|
||||
run(fname)
|
||||
|
||||
for i in range(RUN_COUNT):
|
||||
runpy("test/Test2", i+1)
|
||||
@@ -0,0 +1,24 @@
|
||||
|
||||
def test3(samples,interval):
|
||||
"""
|
||||
"""
|
||||
run("test/Test3",{"interval":interval, "samples":samples})
|
||||
|
||||
|
||||
#10 min exec
|
||||
|
||||
set_file('Fe_hyst_minus')
|
||||
test3(121,1.0)
|
||||
|
||||
set_file('Fe_hyst_plus')
|
||||
test3(61,2.0)
|
||||
|
||||
|
||||
set_file('Fe_hyst_plus')
|
||||
test3(31, 4.0)
|
||||
|
||||
set_file('Fe_hyst_minus')
|
||||
test3(21, 6.0)
|
||||
|
||||
set_file('Fe_hyst_minus')
|
||||
test3(13, 10.0)
|
||||
@@ -0,0 +1,4 @@
|
||||
log("Run %03d/%05d - Script: %s - samples:%d interval:%f" % (get_exec_pars().seq, get_exec_pars().index , get_exec_pars().script , samples, interval), True)
|
||||
write_logs()
|
||||
tscan(current, samples, interval)
|
||||
log_scan_filename()
|
||||
@@ -0,0 +1,26 @@
|
||||
|
||||
def set_pol_cplus(offset = None, timeout = -1):
|
||||
"""
|
||||
"""
|
||||
print "Set x-ray polarization to c+"
|
||||
timeout = int(timeout *1000) if timeout>0 else timeout
|
||||
pol_mode.write("CIRC +")
|
||||
if offset is not None:
|
||||
pol_offset.write(float(offset))
|
||||
time.sleep(0.5)
|
||||
pol_done.update()
|
||||
pol_done.waitValue("DONE",timeout)
|
||||
print "Done setting x-ray polarization"
|
||||
|
||||
def set_pol_cminus(offset = None, timeout = -1):
|
||||
"""
|
||||
"""
|
||||
print "Set x-ray polarizaton to c-"
|
||||
timeout = int(timeout *1000) if timeout>0 else timeout
|
||||
pol_mode.write("CIRC -")
|
||||
if offset is not None:
|
||||
pol_offset.write(float(offset))
|
||||
time.sleep(0.5)
|
||||
pol_done.update()
|
||||
pol_done.waitValue("DONE",timeout)
|
||||
print "Done setting x-ray polarization"
|
||||
Reference in New Issue
Block a user