51 lines
1.8 KiB
Python
51 lines
1.8 KiB
Python
# runs a series of harmonic scans
|
|
# in the _0000 file the result of processed scans for each id energy is saved.
|
|
# columns: 1- ID energy; 2 - calculated energy of harmonic peak from fit; 3 - energy of harm peak from finding the minimum; 4 - peak flux
|
|
|
|
import mathutils
|
|
|
|
ID_ENERGIES = range(1250,1350,10)
|
|
#ID_ENERGIES = [250, 960, 20]
|
|
HALFWIDTH = 8.0
|
|
STEP = 0.25
|
|
|
|
|
|
|
|
def runInnerScan():
|
|
global HALFWIDTH, STEP
|
|
idenergy = int(energy_id.read())
|
|
|
|
print "idenergy=",idenergy
|
|
def before(position, scan):
|
|
wait_device(energy_done, 1 )
|
|
sleep( 0.2 ) # Settling time
|
|
#return lscan(energy, [signal_i0,'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'], idenergy-HALFWIDTH, idenergy+HALFWIDTH, STEP, latency = 0.3)
|
|
return lscan(energy, [signal_i0,'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'], idenergy-HALFWIDTH, idenergy+HALFWIDTH, STEP, before_read = before)
|
|
|
|
|
|
class HarmonicMin(Readable):
|
|
def read(self):
|
|
global tag_prefix
|
|
ret= runInnerScan()
|
|
xdata = ret.getPositions(0)
|
|
ydata = ret.getReadable(0)
|
|
coefs = (a0, a1, a2) = mathutils.fit_polynomial(ydata, xdata, 2)
|
|
xmin = -0.5 * a1 / a2
|
|
ymin = min(ydata)
|
|
xminmin = xdata[ydata.index(min(ydata))]
|
|
print "xmin=",xmin,"xminmin = ",xminmin,"ymin = ",ymin
|
|
return (xmin, xminmin, ymin)
|
|
|
|
|
|
sensor= HarmonicMin()
|
|
|
|
#Pre-actions
|
|
caput('X07MA-PHS-E:OPT', 'PGM')
|
|
pol_offset.write(0.0)
|
|
|
|
print "List of ID energies: ",ID_ENERGIES
|
|
vscan(energy_id, sensor, ID_ENERGIES)
|
|
|
|
caput('X07MA-PHS-E:OPT', 'PGM+ID')
|
|
|