This commit is contained in:
2020-06-17 09:52:22 +02:00
parent 4a8a76afab
commit 6b5f55f877
3 changed files with 113 additions and 1 deletions

View File

@@ -1,4 +1,4 @@
#Mon Jun 15 15:43:13 CEST 2020
#Wed Jun 17 09:52:09 CEST 2020
test=1
geometry=fourcv
ScanIndex=5

80
script/harmonic.py Normal file
View File

@@ -0,0 +1,80 @@
idenergy = 770
############################################################3
#Pre-actions
caput('X07MA-ID:ENERGY', idenergy)
cawait('X07MA-ID:DONE', 'DONE', type = 's')
caput('X07MA-PHS-E:OPT', 'PGM')
halfwidth = 10.0
step = 0.5#1.0
try:
#TODO: Set the diplay names of positioners and detectors
scan = ManualScan(['PGMenergy'], ['I0', 'polarization', 'polangle', 'ringCurrent', 'SetEnergy', 'offset'] , [idenergy-halfwidth], [idenergy+halfwidth], [20])
scan.start()
#Creating channels: dimension 1
#RegionPositioner PGMenergy
PGMenergy = Channel('X07MA-PHS-E:GO.A', type = 'd')
PGMenergyReadback = Channel('X07MA-PGM:CERBK', type = 'd')
#ScalarDetector I0
I0 = Channel('X07MA-ES1-AI:SIGNAL1', type = 'd')
#ScalarDetector polarization
polarization = Channel('X07MA-ID:MODE', type = 'd')
#ScalarDetector polangle
polangle = Channel('X07MA-ID:ALPHA', type = 'd')
ringCurrent = Channel('ARIDI-PCT:CURRENT', type = 'd')
#ScalarDetector SetEnergy
SetEnergy = Channel('X07MA-PHS-E:GO.A', type = 'd')
#ScalarDetector offset
offset = Channel('X07MA-ID:ENERGY-OFFS', type = 'd')
#Dimension 1
#RegionPositioner PGMenergy
for setpoint1 in frange(idenergy-halfwidth, idenergy+halfwidth, step, True):
PGMenergy.put(setpoint1, timeout=180.) # Feb. 2019, changed timeout from 60 to 180s. CP
wait_device(energy_done, 1 )
sleep( 0.5 ) # Settling time
readback1 = PGMenergyReadback.get()
#if abs(readback1 - setpoint1) > 0.5 : # TODO: Check accuracy
#raise Exception('Actor PGMenergy could not be set to the value ' + str(setpoint1))
sleep( 0.5 ) # Settling time
#Detector I0
detector2 = I0.get()
#Detector polarization
detector3 = polarization.get()
#Detector polangle
detector4 = polangle.get()
#Detector ringCurrent
detector6 = ringCurrent.get()
#Detector SetEnergy
detector7 = SetEnergy.get()
#Detector offset
detector10 = offset.get()
scan.append ([setpoint1], [readback1], [detector2, detector3, detector4, detector6, detector7, detector10])
#Closing channels
PGMenergy.close()
PGMenergyReadback.close()
I0.close()
polarization.close()
polangle.close()
ringCurrent.close()
SetEnergy.close()
offset.close()
scan.end()
#Post-actions
caput('X07MA-PHS-E:OPT', 'PGM+ID')
except:
print("Aborting...")
caput('X07MA-PHS-E:OPT', 'PGM+ID')
#if get_exec_pars().source != CommandSource.plugin:
# show_message(str(ex))
raise

32
script/harmonic_v2.py Normal file
View File

@@ -0,0 +1,32 @@
ID_ENERGY = 1250
# energy at which the ID offset should be determined
#========================
HALFWIDTH = 10
STEP = 0.5
#========================
try:
caput('X07MA-PHS-E:OPT', 'PGM')
energy_id.write(ID_ENERGY)
wait_device(energy_done, 1 )
def before(position, scan):
#wait_device(energy_done, 1 )
sleep( 0.3 ) # Settling time
#ret = lscan(energy, [signal_i0, signal_tey, 'ca://X07MA-PC-K428:2:getTotalGain', 'ca://X07MA-ID:MODE?type=d', pol_angle, current, energy, pol_offset, 'ca://X07MA-ID-GAP:READ','ca://X07MA-ID-SHIFT:READ'], ID_ENERGY-HALFWIDTH, ID_ENERGY+HALFWIDTH, STEP, before_read = before)
ret = lscan(energy, [signal_i0, signal_tey, 'ca://X07MA-PC-K428:2:getTotalGain', energy], ID_ENERGY-HALFWIDTH, ID_ENERGY+HALFWIDTH, STEP, before_read = before)
xdata = ret.getPositions(0)
ydata = ret.getReadable(0)
ymin = min(ydata)
xminmin = xdata[ydata.index(min(ydata))]
print "Emin=",xminmin,"ymin = ",ymin
caput('X07MA-PHS-E:OPT', 'PGM+ID')
except:
print("Aborting...")
caput('X07MA-PHS-E:OPT', 'PGM+ID')
raise