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`.
This commit is contained in:
Markus Rosenstihl 2024-02-27 16:57:51 +01:00
parent 7f4a1ac515
commit caf19bc468
2 changed files with 10 additions and 56 deletions

View File

@ -11,22 +11,21 @@ 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['O1'] = -60e3 # offset from SF (Hz) pars['SW'] = 200e3 # sampling rate (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'] = 100 # receiver phase (degree) pars['PHA'] = 0 # receiver phase (degree)
# -*- these aren't variable: -*- # -*- 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['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
@ -34,7 +33,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']
@ -47,8 +46,7 @@ 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:
pars['NS'] = int(round(pars['NS'] / 4) + 1) * 4 print 'Number of scans should be changed to ',pars['NS'],' due to phase cycling'
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")
@ -57,7 +55,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:
@ -117,8 +115,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']
D2 = pars['D2'] D2 = pars['D2']
@ -128,20 +125,13 @@ def satrec_experiment(pars, run):
PH2 = pars['PH2'][run%len(pars['PH2'])] PH2 = pars['PH2'][run%len(pars['PH2'])]
PHA = pars['PHA'] 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: # 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+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(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]:
@ -149,9 +139,9 @@ 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) # 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

View File

@ -29,42 +29,6 @@ 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'])