Compare commits

..

3 Commits

7 changed files with 123 additions and 43 deletions

View File

@ -11,21 +11,22 @@ def experiment(): # saturation-recovery experiment
pars = {} pars = {}
pars['P90'] = 1.7e-6 # 90-degree pulse length (s) pars['P90'] = 1.7e-6 # 90-degree pulse length (s)
pars['SF'] = 338.7e6 # spectrometer frequency (Hz) pars['SF'] = 338.7e6 # spectrometer frequency (Hz)
pars['SW'] = 200e3 # sampling rate (Hz) pars['O1'] = -60e3 # offset from SF (Hz)
pars['SW'] = 200e3 # spectral window (Hz)
pars['SI'] = 1*256 # number of acquisition points pars['SI'] = 1*256 # number of acquisition points
pars['NS'] = 8 # number of scans pars['NS'] = 8 # number of scans
pars['DS'] = 0 # number of dummy scans pars['DS'] = 0 # number of dummy scans
pars['TAU'] = 1 # delay for recovery (s) pars['TAU'] = 1 # delay for recovery (s)
pars['DEAD1'] = 5e-6 # receiver dead time (s) pars['DEAD1'] = 5e-6 # receiver dead time (s)
pars['PHA'] = 0 # receiver phase (degree) pars['PHA'] = 100 # receiver phase (degree)
# -*- these aren't variable: -*- # -*- these aren't variable: -*-
pars['NECH'] = 7 # number of saturation pulses pars['NECH'] = 40 # number of saturation pulses
pars['D1'] = 100e-3 # starting interval in saturation sequence (s) pars['D1'] = 100e-3 # starting interval in saturation sequence (s)
pars['D2'] = 1e-4 # end interval in saturation sequence (s) pars['D2'] = 1e-4 # end interval in saturation sequence (s)
pars['DATADIR'] = '/home/fprak/Students/' # data directory pars['DATADIR'] = '/home/fprak/Students/' # data directory
pars['OUTFILE'] = None # output file name pars['OUTFILE'] = None # output file name
# specify a variable parameter (optional): # specify a variable parameter (optional):
pars['VAR_PAR'] = 'TAU' # variable parameter name (a string) pars['VAR_PAR'] = 'TAU' # variable parameter name (a string)
start = 1e-3 # starting value start = 1e-3 # starting value
stop = 5e-0 # end value stop = 5e-0 # end value
@ -33,7 +34,7 @@ def experiment(): # saturation-recovery experiment
log_scale = True # log scale flag log_scale = True # log scale flag
stag_range = False # staggered range flag stag_range = False # staggered range flag
# check parameters for safety: # check parameters for safety:
if pars['PHA'] < 0: if pars['PHA'] < 0:
pars['PHA'] = 360 + pars['PHA'] pars['PHA'] = 360 + pars['PHA']
@ -46,7 +47,8 @@ def experiment(): # saturation-recovery experiment
raise Exception("Pulse too long!!!") raise Exception("Pulse too long!!!")
if pars['NS']%4 != 0: if pars['NS']%4 != 0:
print 'Number of scans should be changed to ',pars['NS'],' due to phase cycling' pars['NS'] = int(round(pars['NS'] / 4) + 1) * 4
print 'Number of scans changed to ',pars['NS'],' due to phase cycling'
if pars['D1'] < pars['D2']: if pars['D1'] < pars['D2']:
raise Exception("D1 must be greater than D2") raise Exception("D1 must be greater than D2")
@ -55,7 +57,7 @@ def experiment(): # saturation-recovery experiment
if sat_length > 1.: if sat_length > 1.:
raise Exception("Saturation sequence too long!!!") raise Exception("Saturation sequence too long!!!")
# start the experiment: # start the experiment:
if var_key: if var_key:
# this is an arrayed experiment: # this is an arrayed experiment:
if log_scale: if log_scale:
@ -115,6 +117,7 @@ def satrec_experiment(pars, run):
# read in variables: # read in variables:
P90 = pars['P90'] P90 = pars['P90']
SF = pars['SF'] SF = pars['SF']
O1 = pars['O1']
DEAD1 = pars['DEAD1'] DEAD1 = pars['DEAD1']
NECH = pars['NECH'] NECH = pars['NECH']
D1 = pars['D1'] D1 = pars['D1']
@ -124,15 +127,21 @@ def satrec_experiment(pars, run):
PH3 = pars['PH3'][run%len(pars['PH3'])] PH3 = pars['PH3'][run%len(pars['PH3'])]
PH2 = pars['PH2'][run%len(pars['PH2'])] PH2 = pars['PH2'][run%len(pars['PH2'])]
PHA = pars['PHA'] PHA = pars['PHA']
SI = pars["SI"]
SW = pars["SW"] # set sampling parameters:
SI = pars['SI']
SW = pars['SW']
while SW <= 10e6 and SI < 256*1024:
SI *= 2
SW *= 2
# set variable delay list for saturation pulses: # set variable delay list for saturation pulses:
vdlist = log_range(D2, D1, NECH-1) vdlist = log_range(D2, D1, NECH-1)
# run the pulse sequence: # run the pulse sequence:
# saturation: # saturation:
e.set_frequency(SF, phase=PH1) # set frequency and phase for saturation pulses e.set_frequency(SF+O1, phase=PH1) # set frequency and phase for saturation pulses
e.ttl_pulse(TXEnableDelay, value=TXEnableValue) # enable RF amplifier e.ttl_pulse(TXEnableDelay, value=TXEnableValue) # enable RF amplifier
e.ttl_pulse(P90, value=TXEnableValue|TXPulseValue) # apply 90-degree pulse e.ttl_pulse(P90, value=TXEnableValue|TXPulseValue) # apply 90-degree pulse
for delay in vdlist[::-1]: for delay in vdlist[::-1]:
@ -140,15 +149,15 @@ def satrec_experiment(pars, run):
e.ttl_pulse(TXEnableDelay, value=TXEnableValue) # enable RF amplifier e.ttl_pulse(TXEnableDelay, value=TXEnableValue) # enable RF amplifier
e.ttl_pulse(P90, value=TXEnableValue|TXPulseValue) # apply 90-degree pulse e.ttl_pulse(P90, value=TXEnableValue|TXPulseValue) # apply 90-degree pulse
e.set_phase(PH3) # set phase for measuring pulse
# recovery: # recovery:
e.wait(TAU-5e-7) # recovery time e.wait(TAU) # recovery time
e.set_phase(PH3) # set phase for measuring pulse
# detection: # detection:
e.ttl_pulse(TXEnableDelay, value=TXEnableValue) # enable RF amplifier e.ttl_pulse(TXEnableDelay, value=TXEnableValue) # enable RF amplifier
e.ttl_pulse(P90, value=TXEnableValue|TXPulseValue) # apply 90-degree pulse e.ttl_pulse(P90, value=TXEnableValue|TXPulseValue) # apply 90-degree pulse
e.set_phase(PHA) # set phase for receiver e.set_phase(PHA) # set phase for receiver
e.wait(DEAD1-5e-7) # wait for coil ringdown e.wait(DEAD1) # wait for coil ringdown
e.record(SI, SW, sensitivity=ADCSensitivity) # acquire signal e.record(SI, SW, sensitivity=ADCSensitivity) # acquire signal
# write experiment parameters: # write experiment parameters:

View File

@ -29,6 +29,42 @@ def result():
# get actual sampling rate of timesignal: # get actual sampling rate of timesignal:
sampling_rate = timesignal.get_sampling_rate() sampling_rate = timesignal.get_sampling_rate()
# get user-defined spectrum width:
spec_width = pars['SW']
# specify cutoff frequency, in relative units:
cutoff = spec_width / sampling_rate
if cutoff < 1: # no filter applied otherwise
# number of filter's coefficients:
numtaps = 29
# use firwin to create a lowpass FIR filter:
fir_coeff = firwin(numtaps, cutoff)
# downsize x according to user-defined spectral window:
skip = int(sampling_rate / spec_width)
timesignal.x = timesignal.x[::skip]
for i in range(2):
# apply the filter to ith channel:
timesignal.y[i] = lfilter(fir_coeff, 1.0, timesignal.y[i])
# zeroize first N-1 "corrupted" samples:
timesignal.y[i][:numtaps-1] = 0.0
# circular left shift of y:
timesignal.y[i] = roll(timesignal.y[i], -(numtaps-1))
# downsize y to user-defined number of samples (SI):
timesignal.y[i] = timesignal.y[i][::skip]
# update the sampling_rate attribute of the signal's:
timesignal.set_sampling_rate(spec_width)
# ----------------------------------------------------
# rotate timesignal according to current receiver's phase: # rotate timesignal according to current receiver's phase:
timesignal.phase(pars['rec_phase']) timesignal.phase(pars['rec_phase'])

View File

@ -11,23 +11,23 @@ def experiment(): # saturation-recovery with soild-echo detection
pars = {} pars = {}
pars['P90'] = 2.3e-6 # 90-degree pulse length (s) pars['P90'] = 2.3e-6 # 90-degree pulse length (s)
pars['SF'] = 46.7e6 # spectrometer frequency (Hz) pars['SF'] = 46.7e6 # spectrometer frequency (Hz)
pars['O1'] = 5.6e3 # offset from SF (Hz)
pars['SW'] = 10e6 # spectral window (Hz) pars['SW'] = 10e6 # spectral window (Hz)
pars['SI'] = 1*1024 # number of acquisition points pars['SI'] = 1*1024 # number of acquisition points
pars['NS'] = 16 # number of scans pars['NS'] = 16 # number of scans
pars['DS'] = 0 # number of dummy scans pars['DS'] = 0 # number of dummy scans
pars['TAU'] = 1 # delay for recovery (s) pars['TAU'] = 1 # delay for recovery (s)
pars['D3'] = 20e-6 # echo delay (s) pars['D3'] = 20e-6 # echo delay (s)
pars['D4'] = 0 # pre-aquisition delay (s), use negative values pars['D4'] = 0 # echo pre-aquisition delay (s)
pars['PHA'] = -30 # receiver phase (degree) pars['PHA'] = -30 # receiver phase (degree)
# -*- these ain't variable: -*- # -*- these ain't variable: -*-
pars['NECH'] = 7 # number of saturation pulses pars['NECH'] = 40 # number of saturation pulses
pars['D1'] = 100e-3 # starting interval in saturation sequence (s) pars['D1'] = 100e-3 # starting interval in saturation sequence (s)
pars['D2'] = 1e-4 # end interval in saturation sequence (s) pars['D2'] = 1e-4 # end interval in saturation sequence (s)
pars['DATADIR'] = '/home/fprak/Students/' # data directory pars['DATADIR'] = '/home/fprak/Students/' # data directory
pars['OUTFILE'] = None # output file name pars['OUTFILE'] = None # output file name
pars["suppress_ringing"] = False # 16 Phase cycle, reduces ringing but halves SNR
# specify a variable parameter (optional): # specify a variable parameter (optional):
pars['VAR_PAR'] = 'TAU' # variable parameter name (a string) pars['VAR_PAR'] = 'TAU' # variable parameter name (a string)
start = 1e-4 # starting value start = 1e-4 # starting value
stop = 1e-0 # end value stop = 1e-0 # end value
@ -48,7 +48,8 @@ def experiment(): # saturation-recovery with soild-echo detection
raise Exception("Pulse too long!!!") raise Exception("Pulse too long!!!")
if pars['NS']%8 != 0: if pars['NS']%8 != 0:
print 'Number of scans should be ',pars['NS'],' due to phase cycling' pars['NS'] = int(round(pars['NS'] / 8) + 1) * 8
print 'Number of scans changed to ',pars['NS'],' due to phase cycling'
if pars['D1'] < pars['D2']: if pars['D1'] < pars['D2']:
raise Exception("D1 must be greater than D2!") raise Exception("D1 must be greater than D2!")
@ -110,21 +111,16 @@ def satrec2_experiment(pars, run):
pars['PROG'] = 'satrec2_experiment' pars['PROG'] = 'satrec2_experiment'
if pars["suppress_ringing"]: # phase lists:
# phase cycle to compensate ringing (loss of half the signal!) pars['PH1'] = [ 0] # saturation pulses
pars['PH3'] = [ 0, 0, 0, 0, 90, 90, 90, 90, 180, 180, 180, 180, 270, 270, 270, 270] # 1st 90-degree pulse pars['PH3'] = [ 0, 180, 0, 180, 90, 270, 90, 270] # 1st 90-degree pulse
pars['PH4'] = [ 0, 90, 180, 270, 90, 180, 270, 0, 180, 270, 0, 90, 270, 0, 90, 180] # 2nd 90-degree pulse pars['PH4'] = [90, 90, 270, 270, 0, 0, 180, 180] # 2nd 90-degree pulse
pars['PH2'] = [ 180, 0, 180, 0, 270, 90, 270, 90, 0, 180, 0, 180, 90, 270, 90, 270] # receiver pars['PH2'] = [ 0, 180, 0, 180, 90, 270, 90, 270] # receiver
else:
# simple phase cycle:
pars['PH1'] = [0] # saturation pulses
pars['PH3'] = [0, 180, 0, 180, 90, 270, 90, 270] # 1st 90-degree pulse
pars['PH4'] = [90, 90, 270, 270, 0, 0, 180, 180] # 2nd 90-degree pulse
pars['PH2'] = [0, 180, 0, 180, 90, 270, 90, 270] # receiver
# read in variables: # read in variables:
P90 = pars['P90'] P90 = pars['P90']
SF = pars['SF'] SF = pars['SF']
O1 = pars['O1']
NECH = pars['NECH'] NECH = pars['NECH']
D1 = pars['D1'] D1 = pars['D1']
D2 = pars['D2'] D2 = pars['D2']
@ -136,16 +132,21 @@ def satrec2_experiment(pars, run):
PH4 = pars['PH4'][run%len(pars['PH4'])] PH4 = pars['PH4'][run%len(pars['PH4'])]
PH2 = pars['PH2'][run%len(pars['PH2'])] PH2 = pars['PH2'][run%len(pars['PH2'])]
PHA = pars['PHA'] PHA = pars['PHA']
SI = pars['SI']
SW = pars['SW']
# set variable delay list for saturation pulses: # set variable delay list for saturation pulses:
vdlist = log_range(D2, D1, NECH-1) vdlist = log_range(D2, D1, NECH-1)
# set sampling parameters:
SI = pars['SI']
SW = pars['SW']
while SW <= 10e6 and SI < 256*1024:
SI *= 2
SW *= 2
# the pulse sequence: # the pulse sequence:
# saturation: # saturation:
e.set_frequency(SF, phase=PH1) # set frequency and phase for saturation pulses e.set_frequency(SF+O1, phase=PH1) # set frequency and phase for saturation pulses
e.ttl_pulse(TXEnableDelay, value=TXEnableValue) # enable RF amplifier e.ttl_pulse(TXEnableDelay, value=TXEnableValue) # enable RF amplifier
e.ttl_pulse(P90, value=TXEnableValue|TXPulseValue) # apply 90-degree pulse e.ttl_pulse(P90, value=TXEnableValue|TXPulseValue) # apply 90-degree pulse
for delay in vdlist[::-1]: for delay in vdlist[::-1]:
@ -153,19 +154,19 @@ def satrec2_experiment(pars, run):
e.ttl_pulse(TXEnableDelay, value=TXEnableValue) # enable RF amplifier e.ttl_pulse(TXEnableDelay, value=TXEnableValue) # enable RF amplifier
e.ttl_pulse(P90, value=TXEnableValue|TXPulseValue) # apply 90-degree pulse e.ttl_pulse(P90, value=TXEnableValue|TXPulseValue) # apply 90-degree pulse
e.set_phase(PH3) # set phase for next pulse
# recovery: # recovery:
e.wait(TAU-5e-7) # wait for tau e.wait(TAU) # wait for tau
e.set_phase(PH3) # set phase for next pulse
# echo detection: # echo detection:
e.ttl_pulse(TXEnableDelay, value=TXEnableValue) # enable RF amplifier e.ttl_pulse(TXEnableDelay, value=TXEnableValue) # enable RF amplifier
e.ttl_pulse(P90, value=TXEnableValue|TXPulseValue) # apply 90-degree pulse e.ttl_pulse(P90, value=TXEnableValue|TXPulseValue) # apply 90-degree pulse
e.wait(D3-P90-TXEnableDelay) # echo delay
e.set_phase(PH4) # set phase for next pulse e.set_phase(PH4) # set phase for next pulse
e.wait(D3-P90-TXEnableDelay-5e-7) # echo delay
e.ttl_pulse(TXEnableDelay, value=TXEnableValue) # enable RF amplifier e.ttl_pulse(TXEnableDelay, value=TXEnableValue) # enable RF amplifier
e.ttl_pulse(P90, value=TXEnableValue|TXPulseValue) # apply 90-degree pulse e.ttl_pulse(P90, value=TXEnableValue|TXPulseValue) # apply 90-degree pulse
e.set_phase(PHA) # set phase for receiver e.set_phase(PHA) # set phase for receiver
e.wait(D3-P90/2+D4-5e-7) # echo delay e.wait(D3-P90/2+D4) # echo delay
e.record(SI, SW, sensitivity=ADCSensitivity) # acquisition e.record(SI, SW, sensitivity=ADCSensitivity) # acquisition
# write experiment attributes: # write experiment attributes:

View File

@ -29,6 +29,40 @@ def result():
# get actual sampling rate of timesignal: # get actual sampling rate of timesignal:
sampling_rate = timesignal.get_sampling_rate() sampling_rate = timesignal.get_sampling_rate()
# get user-defined spectrum width:
spec_width = pars['SW']
# specify cutoff frequency, in relative units:
cutoff = spec_width / sampling_rate
if cutoff < 1: # no filter applied otherwise
# number of filter's coefficients:
numtaps = 29
# use firwin to create a lowpass FIR filter:
fir_coeff = firwin(numtaps, cutoff)
# downsize x according to user-defined spectral window:
skip = int(sampling_rate / spec_width)
timesignal.x = timesignal.x[::skip]
for i in range(2):
# apply the filter to ith channel:
timesignal.y[i] = lfilter(fir_coeff, 1.0, timesignal.y[i])
# zeroize first N-1 "corrupted" samples:
timesignal.y[i][:numtaps-1] = 0.0
# circular left shift of y:
timesignal.y[i] = roll(timesignal.y[i], -(numtaps-1))
# downsize y to user-defined number of samples (SI):
timesignal.y[i] = timesignal.y[i][::skip]
# update the sampling_rate attribute of the signal's:
timesignal.set_sampling_rate(spec_width)
# ---------------------------------------------------- # ----------------------------------------------------
# rotate timesignal according to current receiver's phase: # rotate timesignal according to current receiver's phase:

View File

@ -105,7 +105,7 @@ def spinal_experiment(pars, run):
# 8-step phase cycle (Schaefer et al. J Magn Res A 115 (1995)) # 8-step phase cycle (Schaefer et al. J Magn Res A 115 (1995))
pars['PH1'] = [ 0, 0, 180, 180, 90, 90, 270, 270] # 1st (90-degree) pulse pars['PH1'] = [ 0, 0, 180, 180, 90, 90, 270, 270] # 1st (90-degree) pulse
pars['PH3'] = [90, 270, 270, 90, 180, 0, 0, 180] # 2nd (90-degree) pulse pars['PH3'] = [90, 270, 90, 270, 180, 90, 180, 90] # 2nd (90-degree) pulse
pars['PH4'] = [90] # 3rd (90-degree) pulse pars['PH4'] = [90] # 3rd (90-degree) pulse
pars['PH2'] = [90, 270] # receiver pars['PH2'] = [90, 270] # receiver

View File

@ -106,7 +106,7 @@ def spinal4pulses_experiment(pars, run):
# 8-step phase cycle (Schaefer et al. J Magn Res A 115 (1995)) # 8-step phase cycle (Schaefer et al. J Magn Res A 115 (1995))
pars['PH1'] = [0, 0, 180, 180, 90, 90, 270, 270] # 1st (90-degree) pulse pars['PH1'] = [0, 0, 180, 180, 90, 90, 270, 270] # 1st (90-degree) pulse
pars['PH3'] = [90, 270, 270, 90, 180, 0, 0, 180] # 2nd (90-degree) pulse pars['PH3'] = [90, 270, 270, 90, 180, 90, 90, 180] # 2nd (90-degree) pulse
pars['PH4'] = [90] # 3rd (90-degree) pulse pars['PH4'] = [90] # 3rd (90-degree) pulse
pars['PH5'] = [90] * 8 + [270] * 8 pars['PH5'] = [90] * 8 + [270] * 8
pars['PH2'] = [90, 270] # receiver pars['PH2'] = [90, 270] # receiver

View File

@ -104,7 +104,7 @@ def zeeman_experiment(pars, run):
# 8-step phase cycle (Schaefer et al. J Magn Res A 115 (1995)) # 8-step phase cycle (Schaefer et al. J Magn Res A 115 (1995))
pars['PH1'] = [0, 0, 180, 180, 90, 90, 270, 270] # 1st (90-degree) pulse pars['PH1'] = [0, 0, 180, 180, 90, 90, 270, 270] # 1st (90-degree) pulse
pars['PH3'] = [0, 180, 180, 0, 90, 270, 270, 90] # 2nd (90-degree) pulse pars['PH3'] = [0, 180, 180, 0, 90, 270, 270, 90] # 2nd (90-degree) pulse
pars['PH4'] = [0] # 3rd (90-degree) pulse pars['PH4'] = [90] # 3rd (90-degree) pulse
pars['PH2'] = [90, 270] # receiver pars['PH2'] = [90, 270] # receiver
# read in variables: # read in variables: