Compare commits

...

9 Commits

Author SHA1 Message Date
7da97a4f26 Add option to suppress ringing in Saturation Recovery script
A parameter option "suppress_ringing" has been added to the Saturation Recovery script. This option modifies phase lists and allows the application of a phase cycle that compensates for ringing but reduces signal-to-noise ratio by half. This gives users the option to prioritize either reduced ringing or higher SNR as per their requirements.
2024-02-27 17:14:28 +01:00
0d25b17c60 Additional subtle changes include adjusted wait periods.
Removed filtering and up/downsampling.
2024-02-27 17:05:01 +01:00
caf19bc468 Remove filtering and downsampling process
Filtering and downsampling process in `satrec_res.py` was unnecessary and has been removed alongside similar modifications made in `satrec_exp.py`.
2024-02-27 16:57:51 +01:00
7f4a1ac515 Update 'Scripts/Zeeman_Order/zeeman_exp.py' 2023-03-31 17:19:19 +00:00
c1f1f1fc8a Update 'Scripts/Zeeman_Order_Four_Pulses/zeeman4pulses_exp.py' 2023-03-31 17:14:05 +00:00
10e5fdbcd5 Update 'Scripts/Zeeman_Order/zeeman_exp.py' 2023-03-31 17:12:36 +00:00
29f1e92c14 Update 'Scripts/Spin_Alignment_Four_Pulses/spinal4pulses_exp.py' 2023-03-31 17:10:08 +00:00
fc557233ea Update 'Scripts/Spin_Alignment/spinal_exp.py' 2023-03-31 17:07:12 +00:00
a68212d183 Merge pull request 'better phase cycles for STE (3+4 pulse)' (#4) from ste_phasecycle into main
Reviewed-on: #4
2023-02-08 21:13:49 +00:00
8 changed files with 45 additions and 125 deletions

View File

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

View File

@ -29,42 +29,6 @@ def result():
# get actual sampling rate of timesignal:
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:
timesignal.phase(pars['rec_phase'])

View File

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

View File

@ -29,40 +29,6 @@ def result():
# get actual sampling rate of timesignal:
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:

View File

@ -105,7 +105,7 @@ def spinal_experiment(pars, run):
# 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['PH3'] = [90, 270, 90, 270, 180, 90, 180, 90] # 2nd (90-degree) pulse
pars['PH3'] = [90, 270, 270, 90, 180, 0, 0, 180] # 2nd (90-degree) pulse
pars['PH4'] = [90] # 3rd (90-degree) pulse
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))
pars['PH1'] = [0, 0, 180, 180, 90, 90, 270, 270] # 1st (90-degree) pulse
pars['PH3'] = [90, 270, 90, 270, 180, 90, 180, 90] # 2nd (90-degree) pulse
pars['PH3'] = [90, 270, 270, 90, 180, 0, 0, 180] # 2nd (90-degree) pulse
pars['PH4'] = [90] # 3rd (90-degree) pulse
pars['PH5'] = [90] * 8 + [270] * 8
pars['PH2'] = [90, 270] # receiver

View File

@ -103,8 +103,8 @@ def zeeman_experiment(pars, run):
# 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['PH3'] = [0, 180, 0, 180, 90, 180, 90, 180] # 2nd (90-degree) pulse
pars['PH4'] = [90] # 3rd (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['PH2'] = [90, 270] # receiver
# read in variables:

View File

@ -104,7 +104,7 @@ def zeeman4pulses_experiment(pars, run):
# ok 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['PH3'] = [0, 180, 0, 180, 90, 180, 90, 270] # 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['PH5'] = [90] * 8 + [270] * 8
pars['PH2'] = [90, 270] # receiver