174 lines
6.3 KiB
Python
174 lines
6.3 KiB
Python
# -*- coding: iso-8859-1 -*-
|
|
|
|
TXEnableDelay = 2e-6 # test
|
|
TXEnableValue = 0b0001 # TTL line enabling RF amplifier (bit 0)
|
|
TXPulseValue = 0b0010 # TTL line triggering RF pulses (bit 1)
|
|
ADCSensitivity = 2 # voltage span for ADC
|
|
DAC_conv = 6.32e-5 # T/dac_value
|
|
|
|
def experiment(): # stimulated echo experiment
|
|
|
|
# set up acquisition parameters:
|
|
pars = {}
|
|
pars['P90'] = 3.2e-6 # 90-degree pulse length (s)
|
|
pars['SF'] = 338.7e6 # spectrometer frequency (Hz)
|
|
pars['O1'] = -87e3 # offset from SF (Hz)
|
|
pars['SW'] = 500e3 # spectrum width (Hz)
|
|
pars['SI'] = 8*1024 # number of acquisition points
|
|
pars['NS'] = 16*2 # number of scans
|
|
pars['DS'] = 0 # number of dummy scans
|
|
pars['RD'] = 3*7.7 # delay between scans (s)
|
|
pars['D1'] = 1e-3 # delay after first pulse (short tau) (s)
|
|
pars['D2'] = 50e-3 # delay after second pulse (long tau) (s)
|
|
pars['D4'] = 0e-6 # echo pre-acquisition delay (s)
|
|
pars["DAC1"] = 1000 # DAC value (PFG)
|
|
pars["D5"] = 0.9e-3 # PFG pulse length
|
|
pars['PHA'] = 30+180 # receiver phase (degree)
|
|
pars['DATADIR'] = '/home/markusro/STE' # data directory
|
|
pars['OUTFILE'] = "" # output file name
|
|
|
|
# specify a variable parameter (optional):
|
|
pars['VAR_PAR'] = "DAC1" # variable parameter name (a string)
|
|
start = 0 # starting value
|
|
stop = int(5/DAC_conv) #1.5e5 # end value
|
|
steps = 21 # number of values
|
|
log_scale = False # log scale flag
|
|
stag_range = False # staggered range flag
|
|
|
|
# check parameters for safety:
|
|
if pars['PHA'] < 0:
|
|
pars['PHA'] = 360 + pars['PHA']
|
|
|
|
if pars['P90'] > 20e-6:
|
|
raise Exception("Pulse too long!!!")
|
|
|
|
# check whether a variable parameter is named:
|
|
var_key = pars.get('VAR_PAR')
|
|
if var_key == 'P90' and (start > 20e-6 or stop > 20e-6):
|
|
raise Exception("Pulse too long!!!")
|
|
|
|
if pars['NS']%16 != 0:
|
|
pars['NS'] = int(round(pars['NS'] / 16) + 1) * 16
|
|
print 'Number of scans changed to ',pars['NS'],' due to phase cycling'
|
|
|
|
# start the experiment:
|
|
|
|
# check if a variable parameter is named:
|
|
var_key = pars.get('VAR_PAR')
|
|
if var_key:
|
|
# this is an arrayed experiment:
|
|
if log_scale:
|
|
array = log_range(start,stop,steps)
|
|
else:
|
|
array = lin_range(start,stop,steps)
|
|
|
|
if stag_range:
|
|
array = staggered_range(array, size = 2)
|
|
|
|
# estimate the experiment time:
|
|
if var_key == 'D1':
|
|
seconds = (sum(array)*2 + (pars['D2'] + pars['RD']) * steps) * (pars['NS'] + pars['DS'])
|
|
elif var_key == 'D2':
|
|
seconds = (sum(array) + (pars['D1']*2 + pars['RD']) * steps) * (pars['NS'] + pars['DS'])
|
|
elif var_key == 'RD':
|
|
seconds = (sum(array) + (pars['D1']*2 + pars['D2']) * steps) * (pars['NS'] + pars['DS'])
|
|
else:
|
|
seconds = (pars['D1']*2 + pars['D2'] + pars['RD']) * steps * (pars['NS']+ pars['DS'])
|
|
m, s = divmod(seconds, 60)
|
|
h, m = divmod(m, 60)
|
|
print '%s%02d:%02d:%02d' % ('Experiment time estimated: ', h, m, s)
|
|
|
|
# loop for a variable parameter:
|
|
for index, pars[var_key] in enumerate(array):
|
|
print 'Arrayed experiment for '+var_key+': run = '+str(index+1)+\
|
|
' out of '+str(array.size)+': value = '+str(pars[var_key])
|
|
# loop for accumulation:
|
|
for run in xrange(pars['NS']+pars['DS']):
|
|
yield ste_experiment(pars, run)
|
|
synchronize()
|
|
else:
|
|
# estimate the experiment time:
|
|
seconds = (pars['D1']*2 + pars['D2'] + pars['RD']) * (pars['NS']+ pars['DS'])
|
|
m, s = divmod(seconds, 60)
|
|
h, m = divmod(m, 60)
|
|
print '%s%02d:%02d:%02d' % ('Experiment time estimated: ', h, m, s)
|
|
|
|
# loop for accumulation:
|
|
for run in xrange(pars['NS']+pars['DS']):
|
|
yield ste_experiment(pars, run)
|
|
|
|
|
|
# the pulse program:
|
|
|
|
def ste_experiment(pars, run):
|
|
e=Experiment()
|
|
|
|
dummy_scans = pars.get('DS')
|
|
if dummy_scans:
|
|
run -= dummy_scans
|
|
|
|
pars['PROG'] = 'ste_experiment'
|
|
|
|
# phase lists [16-phase cycle from JMR 157, 31 (2002)]:
|
|
pars['PH1'] = [0, 180, 0, 180, 0, 180, 0, 180, 90, 270, 90, 270, 90, 270, 90, 270] # 1st 90-degree pulse
|
|
pars['PH3'] = [0, 0, 180, 180, 0, 0, 180, 180, 0, 0, 180, 180, 0, 0, 180, 180] # 2nd 90-degree pulse
|
|
pars['PH4'] = [0, 0, 0, 0, 180, 180, 180, 180, 0, 0, 0, 0, 180, 180, 180, 180] # 3nd 90-degree pulse
|
|
pars['PH2'] = [0, 180, 180, 0, 180, 0, 0, 180, 270, 90, 90, 270, 90, 270, 270, 90] # receiver
|
|
|
|
# read in variables:
|
|
P90 = pars['P90']
|
|
SF = pars['SF']
|
|
O1 = pars['O1']
|
|
RD = pars['RD']
|
|
D1 = pars['D1']
|
|
D2 = pars['D2']
|
|
D4 = pars['D4']
|
|
D5 = pars['D5']
|
|
DAC1 = pars['DAC1']
|
|
PH1 = pars['PH1'][run%len(pars['PH1'])]
|
|
PH3 = pars['PH3'][run%len(pars['PH3'])]
|
|
PH4 = pars['PH4'][run%len(pars['PH4'])]
|
|
PH2 = pars['PH2'][run%len(pars['PH2'])]
|
|
PHA = pars['PHA']
|
|
|
|
# set sampling parameters:
|
|
SI = pars['SI']
|
|
SW = pars['SW']
|
|
while SW <= 10e6 and SI < 256*1024:
|
|
SI *= 2
|
|
SW *= 2
|
|
|
|
# run the pulse sequence:
|
|
e.wait(RD) # delay between scans
|
|
e.set_frequency(SF+O1, phase=PH1)
|
|
e.ttl_pulse(TXEnableDelay, value=TXEnableValue)
|
|
e.ttl_pulse(P90, value=TXEnableValue|TXPulseValue) # 90-degree pulse
|
|
|
|
e.set_phase(PH3)
|
|
|
|
e.set_pfg(dac_value=DAC1, length=D5, shape=("rec",100e-6))
|
|
e.wait(D1-P90/2-TXEnableDelay - D5) # 'short tau'
|
|
|
|
e.ttl_pulse(TXEnableDelay, value=TXEnableValue)
|
|
e.ttl_pulse(P90, value=TXEnableValue|TXPulseValue) # 90-degree pulse
|
|
|
|
e.wait(D2-P90/2-TXEnableDelay) # 'long tau'
|
|
e.set_phase(PH4)
|
|
|
|
e.ttl_pulse(TXEnableDelay, value=TXEnableValue)
|
|
e.ttl_pulse(P90, value=TXEnableValue|TXPulseValue) # 90-degree pulse
|
|
|
|
e.set_phase(PHA)
|
|
|
|
e.set_pfg(dac_value=DAC1, length=D5, shape=("rec",100e-6))
|
|
e.wait(D1-P90/2-TXEnableDelay+D4-D5) # 'short tau'
|
|
e.record(SI, SW, sensitivity=ADCSensitivity) # acquisition
|
|
|
|
|
|
# write experiment parameters:
|
|
for key in pars.keys():
|
|
e.set_description(key, pars[key]) # acquisition parameters
|
|
e.set_description('run', run) # current scan
|
|
e.set_description('rec_phase', -PH2) # current receiver phase
|
|
|
|
return e |