Note
Go to the end to download the full example code.
Advanced Sequence Axes¶
import pyepr as epr
import numpy as np
Parameter Arithmetic¶
Parameters can be added to, subtracted from and multiplied by numbers or other parameters. Any dynamic axes are carried through to the new parameter.
tau1 = epr.Parameter("tau1", 400, unit="ns", description="Interpulse delay 1")
tau2 = epr.Parameter("tau2", 2000, unit="ns", description="Interpulse delay 2")
t = epr.Parameter(
"t", 200, step=8, dim=250, unit="ns", description="Pump pulse position")
pump_t = tau1 + t
ref2_t = 2 * tau1 + tau2
print(f"Pump pulse position: {pump_t.get_axis()[:5]} ... ns")
print(f"Second refocusing pulse position: {ref2_t.value} ns")
Pump pulse position: [600. 608. 616. 624. 632.] ... ns
Second refocusing pulse position: 2800.0 ns
Linked Axes¶
In experiments such as the resonator profile sequence two parameters need to be stepped together, we can do this by linking the two parameters together. Parameter Arithmetic automatically creates a new parameter that is linked to the original parameter.
fc = 34.0 # GHz
B = 12127.0 # Gauss
gyro = fc/B # GHz/Gauss
freq = epr.Parameter(
"freq", fc, start=-0.3, step=0.02, dim=30, unit="GHz",
description="Frequency")
B_field = epr.Parameter(
"B", B, start=-0.3/gyro, step=0.02/gyro, dim=30, unit="Gauss",
link=freq, description="B0 Field")
seq = epr.Sequence(
name="linked_axes", B=B_field, freq=fc, reptime=3e3, averages=1, shots=10)
seq.freq = freq
seq.addPulse([
epr.RectPulse(t=0, tp=16, freq=0, flipangle=np.pi/2),
epr.RectPulse(t=500, tp=32, freq=0, flipangle=np.pi),
epr.Detection(t=1000, tp=512)])
seq.evolution([freq])
# Both ``freq`` and ``B`` are now stepped along the same axis
print(f"Variables: {seq.progTable['Variable']}, axis IDs: {seq.progTable['axID']}")
print(seq)
Variables: ['B', 'freq'], axis IDs: [0, 0]
###############################################################################
PyEPR Sequence Definition
###############################################################################
Sequence Parameters:
Name Value Unit Description
B 12127 Gauss B0 Field
freq 34 GHz Frequency
reptime 3000 us The shot repetition time
averages 1 None The number of averages to perform.
shots 10 None The number of shots per scan.
det_window 128 None The length of the default detection gate
time 0:0:1 HH:MM:SS Estimated sequence run time
Events (Pulses, Delays, etc...):
iD t (ns) tp (ns) scale type Phase Cycle
0 0 16 None RectPulse
1 500 32 None RectPulse
2 1000 512 N/A Detection
Progression:
Pulse Prog. Axis Parameter Step Dim Unit
Seq 0 B 7.1335 30 Gauss
Seq 0 freq 0.02 30 GHz
###############################################################################
Built by PyEPR Version: 1.2
###############################################################################
Reduced Axes¶
We can also tag one moving parameter to be automatically reduced to a single value, for example for tau1 averaging in 4p-DEER.
tau1 = epr.Parameter(
"tau1", 400, step=16, dim=8, unit="ns", description="Interpulse delay 1")
tau2 = epr.Parameter("tau2", 2000, unit="ns", description="Interpulse delay 2")
t = epr.Parameter(
"t", 200, step=8, dim=250, unit="ns", description="Pump pulse position")
seq = epr.Sequence(
name="4pDEER_tau_avg", B=B, freq=fc, reptime=3e3, averages=1, shots=10)
seq.addPulse([
epr.RectPulse(t=0, tp=16, freq=0, flipangle=np.pi/2),
epr.RectPulse(t=tau1, tp=32, freq=0, flipangle=np.pi),
epr.RectPulse(t=tau1 + t, tp=32, freq=-0.1, flipangle=np.pi),
epr.RectPulse(t=2*tau1 + tau2, tp=32, freq=0, flipangle=np.pi),
epr.Detection(t=2*tau1 + 2*tau2, tp=256)])
seq.evolution([t, tau1], reduce=[tau1])
print(f"Reduced: {seq.progTable['reduce']}")
print(seq)
Reduced: [True, True, False, True, True]
###############################################################################
PyEPR Sequence Definition
###############################################################################
Sequence Parameters:
Name Value Unit Description
B 12127 Gauss The static B0 field for the experiment
freq 34 GHz The central frequency of the sequence
reptime 3000 us The shot repetition time
averages 1 None The number of averages to perform.
shots 10 None The number of shots per scan.
det_window 128 None The length of the default detection gate
time 0:1:0 HH:MM:SS Estimated sequence run time
Events (Pulses, Delays, etc...):
iD t (ns) tp (ns) scale type Phase Cycle
0 0 16 None RectPulse
1 400 32 None RectPulse
2 600 32 None RectPulse
3 2800 32 None RectPulse
4 4800 256 N/A Detection
Progression:
Pulse Prog. Axis Parameter Step Dim Unit
1 1 t 16 8 ns
2 1 t 16 8 ns
2 0 t 8 250 ns
3 1 t 32 8 ns
4 1 t 32 8 ns
###############################################################################
Built by PyEPR Version: 1.2
###############################################################################
Non-linear Axes¶
We can also define a parameter that is non-linear for non-uniform sampling for example.
Non linear axes are not supported on all spectrometer interfaces, for example Bruker XeprAPI based systems.
tau = epr.Parameter(
"tau", np.round(np.geomspace(200, 20000, 40)), unit="ns",
description="Interpulse delay")
seq = epr.Sequence(
name="T2_NUS", B=B, freq=fc, reptime=3e3, averages=1, shots=10)
seq.addPulse([
epr.RectPulse(t=0, tp=16, freq=0, flipangle=np.pi/2),
epr.RectPulse(t=tau, tp=32, freq=0, flipangle=np.pi),
epr.Detection(t=2*tau, tp=256)])
seq.evolution([tau])
print(f"tau axis: {tau.get_axis()[:5]} ... ns")
print(seq)
tau axis: [200. 225. 253. 285. 321.] ... ns
###############################################################################
PyEPR Sequence Definition
###############################################################################
Sequence Parameters:
Name Value Unit Description
B 12127 Gauss The static B0 field for the experiment
freq 34 GHz The central frequency of the sequence
reptime 3000 us The shot repetition time
averages 1 None The number of averages to perform.
shots 10 None The number of shots per scan.
det_window 128 None The length of the default detection gate
time 0:0:1 HH:MM:SS Estimated sequence run time
Events (Pulses, Delays, etc...):
iD t (ns) tp (ns) scale type Phase Cycle
0 0 16 None RectPulse
1 200 32 None RectPulse
2 400 256 N/A Detection
Progression:
Pulse Prog. Axis Parameter Step Dim Unit
1 0 t Var 40 ns
2 0 t Var 40 ns
###############################################################################
Built by PyEPR Version: 1.2
###############################################################################
Total running time of the script: (0 minutes 0.008 seconds)