From 1c3836a21242d208c57df00eb04d7a218d5235ed Mon Sep 17 00:00:00 2001
From: Yb Tweezer <ybtweezer@gmail.com>
Date: Wed, 11 Oct 2023 16:53:01 -0500
Subject: [PATCH] add axial cooling via kill block

---
 lib/system.py |  24 +++-
 main.py       | 335 ++++++++++++++++++++++++++++++++++++++++++--------
 2 files changed, 301 insertions(+), 58 deletions(-)

diff --git a/lib/system.py b/lib/system.py
index 2e6e242..698f2b3 100644
--- a/lib/system.py
+++ b/lib/system.py
@@ -124,11 +124,11 @@ CONNECTIONS = ConnectionLayout(
     # qinit_green_aom_fm      =  Analog(11, +1.0, delay=0.0),
 
     # probe double pass
-    probe_green_aom         = Digital(0, 11, 1, delay_up=0.0, delay_down=0.0),
-    probe_green_aom_am      =  Analog(5, 0.125, delay=0.0),
-    probe_green_aom_fm      =  Analog(6,  0.02, delay=0.0),
-    probe_green_servo       = Digital(0, 22, 0, delay_up=0.0, delay_down=0.0),
-    probe_green_sh_2        = Digital(1,  0, 0, delay_up=5e-3, delay_down=1.5e-3),
+    probe_green_aom         = Digital(0,  11, 1, delay_up=0.0, delay_down=0.0),
+    probe_green_aom_am      =  Analog(5,  0.125, delay=0.0),
+    probe_green_aom_fm      =  Analog(14, 0.000, delay=0.0),
+    probe_green_servo       = Digital(0,  22, 0, delay_up=0.0, delay_down=0.0),
+    probe_green_sh_2        = Digital(1,   0, 0, delay_up=5e-3, delay_down=1.5e-3),
 
     # moglabs OP AOM #1
     qinit_green_aom_0       = Digital(1,  2, 0, delay_up=0.0, delay_down=0.0),
@@ -147,7 +147,7 @@ CONNECTIONS = ConnectionLayout(
     clock_aom_fm            =  Analog(13, 0.0, delay=0.0),
 
     # tweezer_aod_am      =  Analog(9, +1.19, delay=0.0), # for 7x magnification
-    tweezer_aod_am          =  Analog(9,  +4.465, delay=0.0), # for 4x magnification
+    tweezer_aod_am          =  Analog(9,  +3.931, delay=0.0), # for 4x magnification
     tweezer_aod_switch      = Digital(1,  6, 1, delay_up=25e-9, delay_down=25e-9),
     # tweezer_aod_am      =  Analog(9, +3.795, delay=0.0), # for 2x magnification
     # tweezer_aod_am      =  Analog(9, +2.004, delay=0.0), # for [100, 102.5, 105, 107.5, 110] MHz array (7x mag)
@@ -462,6 +462,18 @@ def PROBE_GREEN_AOM_AM(s: float, warn_only: bool=False) -> float:
     #         raise Exception(f"PROBE_GREEN_AOM_AM: saturation parameter {s:g} too high at frequency {f:g}")
     return v
 
+def PROBE_GREEN_AOM_FM(f: float) -> float:
+    f0 = 80.0
+    order = -1
+    fp = order * f / 2 - f0
+    if abs(fp > 6.0):
+        raise Exception(f"PROBE_GREEN_AOM_FM: frequency {f:g} out of range")
+    # measured on 2023.09.22
+    a = 0.75820
+    b = -0.08133
+    v = (fp - b) / a
+    return v
+
 def AXIAL_GREEN_AOM_AMP_FREQ(f: float) -> float:
     # returns max optical power achievable at `f` in nW
     A = 67.0259184 # last measured 09.13.2022
diff --git a/main.py b/main.py
index e679ee6..b215c4e 100644
--- a/main.py
+++ b/main.py
@@ -17,8 +17,8 @@ def qq(x):
     return x
 
 _save = True
-_label = "cooling-scan"
-_counter = 1
+_label = "hist"
+_counter = 10
 comments = """
 """[1:-1]
 
@@ -61,7 +61,7 @@ probe_warn: bool = True
 ## MAIN SEQUENCE PARAMETERS ####################################################
 
 # repeat shots for statistics
-reps: int = 20
+reps: int = 500
 
 # trigger the Andor for the CMOT and truncate the sequence to check alignment
 # to the tweezer
@@ -109,10 +109,10 @@ qubit_readout_1: bool = False
 qubit_readout_2: bool = False
 
 # do a final atom readout
-final_atom_readout: bool = False       
+final_atom_readout: bool = True
 
 # include OP in the final atom readout
-final_pump: bool = False
+final_pump: bool = True
 
 # fix the duration of the clock block to max(TAU_CLOCK)
 clock_fixed_duration: bool = False
@@ -126,7 +126,7 @@ image_pad: float = 25.0e-3 # ~1.07 ms/px
 
 ## BLOCK PARAMETERS ###########################################################
 
-U_mul = 0.575 # overall scaling factor on tweezer depths
+U_mul = 0.500 # overall scaling factor on tweezer depths
 # U_mul = 0.700 # overall scaling factor on tweezer depths
 tau_bramp = 15e-3 # shim coil ramping time; s
 tau_bsettle = 40e-3 # shim coil servo overshoot time; s
@@ -146,9 +146,9 @@ N_compression = 125 # number of steps in CMOT graident ramp
 N_fpramp = 1000 # number of CMOT frequency/power ramp steps
 B_green = int(44182 * 1.30) # broadband green gradient
 B_cmot = int(B_green * 1.80) # CMOT gradient setting
-SHIMS_CMOT_FB = np.array([+1.195]) # image-left (20 sites)
-SHIMS_CMOT_LR = np.array([+0.785]) # middle / 5 sites
-SHIMS_CMOT_UD = np.array([-0.265]) # image-left (20 sites) (-0.265 for normal)
+SHIMS_CMOT_FB = np.array([+1.2]) # image-left (20 sites)
+SHIMS_CMOT_LR = np.array([+0.76]) # middle / 5 sites
+SHIMS_CMOT_UD = np.array([-0.265]) # image-left (20 sites)
 # SHIMS_CMOT_FB = np.array([+1.210]) # middle / 5 sites
 # SHIMS_CMOT_LR = np.array([+0.785]) # middle / 5 sites
 # SHIMS_CMOT_UD = np.array([-0.312]) # middle / 5 sites
@@ -188,30 +188,45 @@ tau_B_off = 15e-3 # ramping time for the CMOT coils to turn off; s
 # cool
 SHIMS_COOL_FB = np.array([+0.000]) # G
 SHIMS_COOL_LR = np.array([+0.000]) # G
-SHIMS_COOL_UD = np.array([+0.200]) # G
-# SHIMS_COOL_UD = np.array([-2.45]) # G  (-2.45) cooling gradient setting
+# SHIMS_COOL_UD = np.array([+3.000]) # G
+SHIMS_COOL_UD = np.array([-2.45]) # G  (-2.45) cooling gradient setting
 B_cool = np.array([0]) # cooling gradient setting (35000)
 # TAU_COOL = np.array([0.0]) * 1e-3 # initial tweezer cooling block; s
 # TAU_COOL = np.array([350.0]) * 1e-3
-# TAU_COOL = np.array([300.0]) * 1e-3
-TAU_COOL = np.array([20.0]) * 1e-3 # resonance detuning scan
-# TAU_COOL = np.array([10,20 ,40.0,60.0,80,100,120,140,160]) * 1e-3 # cooling lifetime scan
+TAU_COOL = np.array([150.0]) * 1e-3
+# TAU_COOL = np.array([20.0]) * 1e-3 # resonance detuning scan
+# TAU_COOL = np.array([10, 20, 50, 100.0, 150.0, 250, 400]) * 1e-3 # cooling lifetime scan
 # TAU_COOL = np.array([0.0, 10.0, 20.0, 40.0, 50.0, 65.0, 80.0, 120.0]) * 1e-3 # cooling lifetime scan
 # TAU_COOL = np.array([350.0, 400.0, 450.0]) * 1e-3
-P_COOL = np.array([1.0]) # resonance detuning scan
 # P_COOL = np.array([6.0])
 # P_COOL = np.array([0.00])
-# P_COOL = np.array([2.5]) # 
+# P_COOL = np.array([0.5]) # resonance detuning scan
+P_COOL = np.array([2.0]) # 
 # P_COOL = np.arange(7.0, 10.0, 0.75)
 # P_COOL = np.array([0.5, 1.5, 2.0,]) # 
 # DET_COOL = np.array([92.8]) # 760 1.5G + bias -1/2
 # DET_COOL = 90.0 + np.arange(2.50, 3.40, 50e-3) # resonance detuning scan (1.5 G)
-# DET_COOL = np.array([92.05]) # 760 3.0 G + bias -1/2
+DET_COOL = np.array([92.15]) # 760 3.0 G + bias -1/2
+# DET_COOL = np.array([91.96]) # 760 3.0 G + bias -1/2
 # DET_COOL = np.array([87.05]) # 760 3.0 G + bias -1/2 (10 G)
 # DET_COOL = np.arange(91.6, 92.8, 75e-3) # resonance detuning scan (3 G)
+# DET_COOL = np.arange(91.9, 92.3, 50e-3) # resonance detuning scan (3 G)
 # DET_COOL = np.arange(86.6, 87.8, 125e-3) # resonance detuning scan (10 G)
-DET_COOL = np.arange(87.0, 93, 0.4) # resonance detuning scan (3/2 at 1 G)
-# 
+# DET_COOL = np.arange(82, 86, 0.2) # resonance detuning scan (3/2 at 1 G)
+
+# probe cool
+PCOOL_PUMP_ON = False
+SHIMS_PCOOL_FB = np.array([+0.000]) # G
+SHIMS_PCOOL_LR = np.array([+0.000]) # G
+SHIMS_PCOOL_UD = np.array([+0.000]) # G
+HHOLTZ_PCOOL = np.array([120.0]) # G
+# TAU_PCOOL = np.array([20.0]) * 1e-3
+TAU_PCOOL = np.array([0.0]) * 1e-3
+# TAU_PCOOL = np.array([5.0, 20.0, 50.0, 100.0, 150.0, 200.0, 400.0]) * 1e-3
+P_PCOOL_AM = np.array([3.0])
+DET_PCOOL = np.array([-160.66])
+# DET_PCOOL = np.arange(-160.8, -158.4, 150e-3)
+
 # pump
 N_pump_chirp = 1000
 U_PUMP = U_mul * np.array([1000.0]) # uK
@@ -223,7 +238,7 @@ HHOLTZ_PUMP = np.array([120.000]) # G
 TAU_PUMP = np.array([70.0e-6]) # pumping pulse duration; s
 # TAU_PUMP = np.array([20.0e-3]) # pumping pulse duration; s
 # TAU_PUMP = TAU_PUMP[0] + np.arange(-30e-6, +30e-6, 10e-6)
-P_PUMP = np.array([-0.85]) # V
+P_PUMP = np.array([-0.7]) # V
 # P_PUMP = np.array([0.0]) # V
 # P_PUMP = np.arange(-0.55, -0.2, 0.05)
 # DET_PUMP = np.array([10.150]) # MHz
@@ -288,10 +303,10 @@ det_lifetime_probe_am = 94.5 # FM (for AM) channel setting; MHz
 # ramp-down
 N_Uramp = 1000 # number of steps for tweezer depth ramps
 U_RAMPDOWN = U_mul * np.array([1000.0]) # ramp-down depth; uK
-# U_RAMPDOWN = U_mul * np.array([5.0, 10.0, 20.0, 30.0, 40.0, 50.0, 100.0, 200.0, 300.0, 600.0, 1000.0]) # ramp-down depth; uK
+# U_RAMPDOWN = U_mul * np.array([1.0, 2.0, 5.0, 10.0, 20.0, 50.0, 100.0, 200.0, 300.0, 600.0, 1000.0]) # ramp-down depth; uK
 # U_RAMPDOWN = U_mul * np.array([20.0, 30.0, 40.0, 50.0, 100.0, 200.0, 300.0, 600.0, 1000.0]) # ramp-down depth; uK
 # U_RAMPDOWN = U_mul * np.array([50.0, 1000.0])
-# U_RAMPDOWN = U_mul * np.array([50.0])
+U_RAMPDOWN = U_mul * np.array([5.0])
 tau_Uramp = 4e-3 # tweezer ramping time; s
 TAU_RAMPDOWN = np.array([20.0]) * 1e-3 # hold time for tweezer ramp; s
 tau_Upause = 2e-3 # pause time for tweezer; s
@@ -329,13 +344,18 @@ TAU_AWG = np.array([0e-6]) # AWG sequence time; s
 
 
 # kill
+N_kill_chirp = 100
 U_KILL = U_mul * np.array([1000.0]) # uK (normalized)
 HHOLTZ_KILL = np.array([120.0]) # G
-# TAU_KILL = np.array([5e-3]) # s
+# TAU_KILL = np.array([20e-3]) # s
 TAU_KILL = np.array([0e-3]) # s
 # TAU_KILL = np.array([0, 10, 20, 50, 100.0, 200.0, 400.0, 800.0, 1600.0]) * 1e-3
-# TAU_KILL = np.arange(0e-3, 300e-3, 20e-3)
-P_KILL = np.array([3]) # I_sat
+# TAU_KILL = np.arange(0e-3, 30e-3, 2.5e-3)
+P_KILL = np.array([0.5]) # I_sat (1 Isat for probe <-> 4.4 Isat for kill)
+# P_KILL = np.array([0.5, 1, 1.5, 2, 3.0])
+# DET_KILL = np.arange(-161., -160.3, 50e-3)
+DET_KILL = np.array([-160.7])
+DET_KILL_CHIRP = np.array([0.0])
 
 # image
 U_image = U_mul * 1000.0 # imaging tweezer depth; uK
@@ -364,8 +384,8 @@ P_PROBE = np.array([27.0]) # dBm
 # DET_PROBE = np.arange(-32.2, -30.1, 100e-3) + 0.1 # -3/2 @ 58 G 
 # DET_PROBE = np.arange(-31, -30, 0.1) # -3/2 @ 58 G 
 # DET_PROBE = np.arange(-30.4, -29.9, 40e-3) # -3/2 @ 58 G
-DET_PROBE = np.array([-160.35]) # 120 G
-# DET_PROBE = np.arange(-160.9, -159.30, 75e-3) # 120 G resonance scan
+DET_PROBE = np.array([-160.20]) # 120 G
+# DET_PROBE = np.arange(-161.15, -159.50, 75e-3) # 120 G resonance scan
 # DET_PROBE = np.arange(-160.9, -160.2, 50e-3) # 120 G
 # DET_PROBE = np.array([-157.65]) # 120 G, horizontal tweezer polarization
 # DET_PROBE = np.arange(-158.0, -157.0, 50e-3) # 120 G, horizontal tweezer polarization
@@ -406,6 +426,14 @@ if check_tweezer_alignment:
     P_COOL = P_COOL[:1]
     DET_COOL = DET_COOL[:1]
 
+    SHIMS_PCOOL_FB = SHIMS_PCOOL_FB[:1]
+    SHIMS_PCOOL_LR = SHIMS_PCOOL_LR[:1]
+    SHIMS_PCOOL_UD = SHIMS_PCOOL_UD[:1]
+    HHOLTZ_PCOOL = HHOLTZ_PCOOL[:1]
+    TAU_PCOOL = TAU_PCOOL[:1]
+    P_PCOOL_AM = P_PCOOL_AM[:1]
+    DET_PCOOL = DET_PCOOL[:1]
+
     SHIMS_PUMP_FB = SHIMS_PUMP_FB[:1]
     SHIMS_PUMP_LR = SHIMS_PUMP_LR[:1]
     SHIMS_PUMP_UD = SHIMS_PUMP_UD[:1]
@@ -495,6 +523,13 @@ entangleware_arrs = [
     SHIMS_COOL_FB, SHIMS_COOL_LR, SHIMS_COOL_UD,
     TAU_COOL,
 
+    # pcool block
+    SHIMS_PCOOL_FB, SHIMS_PCOOL_LR, SHIMS_PCOOL_UD,
+    HHOLTZ_PCOOL,
+    TAU_PCOOL,
+    P_PCOOL_AM,
+    DET_PCOOL,
+    
     # pump block
     U_PUMP,
     SHIMS_PUMP_FB, SHIMS_PUMP_LR, SHIMS_PUMP_UD,
@@ -546,6 +581,8 @@ entangleware_arrs = [
     HHOLTZ_KILL,
     TAU_KILL,
     P_KILL,
+    DET_KILL,
+    DET_KILL_CHIRP,
 
     # image
     SHIMS_PROBE_FB, SHIMS_PROBE_LR, SHIMS_PROBE_UD,
@@ -553,12 +590,14 @@ entangleware_arrs = [
     TAU_PROBE,
     TAU_OFFSET,
     P_PROBE_AM,
+    DET_PROBE,
     TT_WIDTH,
 ]
 
 cool_arrs = [ P_COOL, DET_COOL, ]
 
-probe_arrs = [ P_PROBE, DET_PROBE, ]
+# probe_arrs = [ P_PROBE, DET_PROBE, ]
+probe_arrs = [ P_PROBE, ]
 
 mag_arrs = [ SHIMS_MAG_AMP_FB, SHIMS_MAG_AMP_LR, F_MAG, PHI_MAG, PHI_MAG_2, TAU_RAMSEY, ]
 
@@ -597,6 +636,7 @@ def init_blue_mot(
     det_pump: float,
     # det_clock: float,
     p_probe_am: float,
+    det_probe: float,
 ) -> (Sequence, State):
     t_start = state.t
     seq = Sequence()
@@ -679,6 +719,12 @@ def init_blue_mot(
         # Event.digitalc(C.probe_green_sh, 1, t_start, with_delay=False),
         Event.digitalc(C.probe_green_sh_2, 0, t_start, with_delay=False),
         Event.digitalc(C.probe_green_aom, 0, t_start, with_delay=False),
+        Event.analogc(
+            C.probe_green_aom_fm,
+            PROBE_GREEN_AOM_FM(det_probe),
+            t_start,
+            with_delay=False
+        ),
         Event.analogc(
             C.probe_green_aom_am,
             PROBE_GREEN_AOM_AM(p_probe_am),
@@ -1045,6 +1091,109 @@ def cool(
     state.hholtz = 0.0
     return seq, state
 
+def pcool(
+    state: State,
+    shims_pcool_fb: float,
+    shims_pcool_lr: float,
+    shims_pcool_ud: float,
+    hholtz_pcool: float,
+    tau_pcool: float,
+    p_pcool_am: float,
+    det_pcool: float,
+    pump_on: bool=False,
+) -> (Sequence, State):
+    t_start = state.t
+    seq = Sequence()
+    if abs(TAU_PCOOL).sum() == 0.0 or check_tweezer_alignment:
+        return seq, state
+    
+    if pump_on:
+        seq += Sequence([
+            Event.analogc(
+                C.qinit_green_aom_am,
+                P_PUMP[0],
+                t_start
+            ),
+            Event.analogc(
+                C.qinit_green_aom_fm,
+                QINIT_GREEN_AOM_FM(DET_PUMP[0]),
+                t_start
+            )
+        ])
+    
+    seq += Sequence([
+        Event.analogc(
+            C.probe_green_aom_am,
+            PROBE_GREEN_AOM_AM(p_pcool_am, probe_warn),
+            t_start,
+            with_delay=False
+        )
+    ])
+    seq += Sequence([
+        Event.analogc(
+            C.probe_green_aom_fm,
+            PROBE_GREEN_AOM_FM(det_pcool),
+            t_start,
+            with_delay=False,
+        )
+    ])
+
+    if (
+        shims_pcool_fb != state.shims_fb
+        or shims_pcool_lr != state.shims_lr
+        or shims_pcool_ud != state.shims_ud
+        or hholtz_pcool != state.hholtz
+    ):
+        SHIMS_FBRAMP = np.linspace(state.shims_fb, shims_pcool_fb, N_bramp)
+        SHIMS_LRRAMP = np.linspace(state.shims_lr, shims_pcool_lr, N_bramp)
+        SHIMS_UDRAMP = np.linspace(state.shims_ud, shims_pcool_ud, N_bramp)
+        seq += Sequence.joinall(*[
+            set_shims(
+                t_start + t,
+                fb=SHIM_COILS_FB_MAG(fb),
+                lr=SHIM_COILS_LR_MAG(lr),
+                ud=SHIM_COILS_UD_MAG(ud),
+            )
+            for t, fb, lr, ud in zip(T_BRAMP, SHIMS_FBRAMP, SHIMS_LRRAMP, SHIMS_UDRAMP)
+        ])
+        HHOLTZ_RAMP = np.linspace(state.hholtz, hholtz_pcool, N_bramp)
+        seq += Sequence.joinall(*[
+            Sequence.serial_bits_c(
+                C.mot3_coils_sig,
+                t_start + t,
+                HHOLTZ_CONV(hholtz), bits_Bset,
+                AD5791_DAC, bits_DACset,
+                C.mot3_coils_clk, C.mot3_coils_sync,
+                clk_freq
+            )
+            for t, hholtz in zip(T_BRAMP, HHOLTZ_RAMP)
+        ])
+        t_start += (tau_bramp + 5e-3)
+
+    # pulse pump beam
+    if pump_on:
+        seq += Sequence([
+            Event.digitalc(C.qinit_green_sh, 1, t_start - 5e-3), # on
+            Event.digitalc(C.qinit_green_sh, 0, t_start + tau_pcool + 1e-3), # off
+            Event.digitalc(C.qinit_green_aom_0, 1, t_start),
+            Event.digitalc(C.qinit_green_aom, 0, t_start),
+            Event.digitalc(C.qinit_green_aom_0, 0, t_start + tau_pcool),
+            Event.digitalc(C.qinit_green_aom, 1, t_start + tau_pcool),
+        ])
+
+    # pulse probe beam
+    # seq += set_probe(False, t_start-10e-3)
+    seq += set_probe(True, t_start)
+    seq += set_probe(False, t_start + tau_pcool)
+
+    t_next = t_start + tau_pcool
+    state.t = t_next
+    state.shims_fb = shims_pcool_fb
+    state.shims_lr = shims_pcool_lr
+    state.shims_ud = shims_pcool_ud
+    state.hholtz = hholtz_pcool
+    return seq, state
+
 def pump(
     state: State,
     U_pump: float,
@@ -1651,6 +1800,8 @@ def kill(
     hholtz_kill: float,
     tau_kill: float,
     p_kill: float,
+    det_kill: float,
+    det_kill_chirp: float,
 ) -> (Sequence, State):
     t_start = state.t
     seq = Sequence()
@@ -1688,19 +1839,41 @@ def kill(
         )
     )
     if tau_kill > 0.0: # don't do any pulsing if tau_kill <= 0.0
+        seq += Sequence([
+            Event.analogc(
+                C.probe_green_aom_fm,
+                PROBE_GREEN_AOM_FM(det_kill),
+                t_start,
+            )
+        ])
+        if det_kill_chirp > 0.0:
+            T_CHIRP = np.linspace(0, tau_kill, N_kill_chirp)
+            DET_CHIRP = np.linspace(
+                det_kill - det_kill_chirp / 2.0,
+                 det_kill + det_kill_chirp / 2.0,
+                  N_kill_chirp
+            )
+            seq += Sequence([
+                Event.analogc(
+                    C.probe_green_aom_fm,
+                    PROBE_GREEN_AOM_FM(d),
+                    _t_start + t,
+                )
+                for d, t in zip(DET_CHIRP, T_CHIRP)
+            ])
         seq += Sequence([
             Event.analogc( # set the AOM AM for p_kill
                 C.probe_green_aom_am,
                 PROBE_GREEN_AOM_AM(p_kill, probe_warn),
-                t_start,
+                t_start - 5e-3,
                 with_delay=False
             ),
             Event.digitalc(C.kill_green_sh, 1, _t_start - 2.5e-3), # open the shutter
             Event.digitalc(C.kill_green_sh, 0, _t_start + tau_kill), # close the shutter
         ])
-        seq += set_probe(True, t_start, shutter=False) # the beam is on the probe line, so pulse that AOM
-        seq += set_probe(True, _t_start, shutter=False)
-        seq += set_probe(False, _t_start + tau_kill, shutter=False)
+        # seq += set_probe(False, t_start, shutter=False)
+        seq += set_probe(True, _t_start)
+        seq += set_probe(False, _t_start + tau_kill)
     if Uramp_flag:
         U_URAMP = np.linspace(U_kill, U_nominal, N_Uramp + 1)
         seq += Sequence.from_analogc_data(
@@ -1724,6 +1897,7 @@ def image(
     tau_probe: float,
     tau_offset: float,
     p_probe_am: float,
+    det_probe: float,
     tt_width: float,
     cam_trigger: bool=True, # flag to control whether camera is triggered
     timetagger: bool=True, # flag to control whether the timetagger gate is opened
@@ -1798,11 +1972,18 @@ def image(
             for t, hholtz in zip(T_BRAMP, HHOLTZ_RAMP)
         ])
     if tau_probe > 0.0 and probe_on:
+        seq += Sequence([
+            Event.analogc(
+                C.probe_green_aom_fm,
+                PROBE_GREEN_AOM_FM(det_probe),
+                t_start,
+            )
+        ])
         seq += Sequence([
             Event.analogc(
                 C.probe_green_aom_am,
                 PROBE_GREEN_AOM_AM(p_probe_am, probe_warn),
-                t_start + 5e-3,
+                t_start,
                 with_delay=False
             ),
         ])
@@ -1923,6 +2104,14 @@ def make_sequence(
     shims_cool_ud: float,
     tau_cool: float,
 
+    shims_pcool_fb: float,
+    shims_pcool_lr: float,
+    shims_pcool_ud: float,
+    hholtz_pcool: float,
+    tau_pcool: float,
+    p_pcool_am: float,
+    det_pcool: float,
+    
     U_pump: float,
     shims_pump_fb: float,
     shims_pump_lr: float,
@@ -1977,6 +2166,8 @@ def make_sequence(
     hholtz_kill: float,
     tau_kill: float,
     p_kill: float,
+    det_kill: float,
+    det_kill_chirp: float,
 
     shims_probe_fb: float,
     shims_probe_lr: float,
@@ -1985,6 +2176,7 @@ def make_sequence(
     tau_probe: float,
     tau_offset: float,
     p_probe_am: float,
+    det_probe: float,
     tt_width: float,
 
     name: str="sequence"
@@ -2019,6 +2211,7 @@ def make_sequence(
             det_pump,
             # det_clock,
             p_probe_am,
+            det_probe,
         )
     SEQ["init"].set_color("C0")
 
@@ -2061,6 +2254,34 @@ def make_sequence(
         )
     SEQ["cool"].set_color("C6")
 
+    # times.append(state_next.t)
+    # SEQ["pcool"], state_next \
+    #     = pcool(
+    #         state_next,
+    #         shims_pcool_fb,
+    #         shims_pcool_lr,
+    #         shims_pcool_ud,
+    #         hholtz_pcool,
+    #         tau_pcool,
+    #         p_pcool_am,
+    #         det_pcool,
+    #         pump_on=PCOOL_PUMP_ON,
+    #     )
+    # SEQ["pcool"].set_color("b")
+
+    times.append(state_next.t)
+    SEQ["kill"], state_next \
+        = kill(
+            state_next,
+            U_kill,
+            hholtz_kill,
+            tau_kill,
+            p_kill,
+            det_kill,
+            det_kill_chirp,
+        )
+    SEQ["kill"].set_color("r")
+
     if initial_pump:
         times.append(state_next.t)
         seq0, state_next \
@@ -2094,6 +2315,7 @@ def make_sequence(
                 tau_probe,
                 tau_offset,
                 p_probe_am,
+                det_probe,
                 tt_width,
             )
         SEQ["init atom readout"] = seq0 + seq1
@@ -2131,6 +2353,7 @@ def make_sequence(
                 tau_probe,
                 tau_offset,
                 p_probe_am,
+                det_probe,
                 tt_width,
             )
         SEQ["qubit readout 1"].set_color("C3")
@@ -2165,16 +2388,18 @@ def make_sequence(
         )
     SEQ["clock"].set_color("C5")
 
-    times.append(state_next.t)
-    SEQ["kill"], state_next \
-        = kill(
-            state_next,
-            U_kill,
-            hholtz_kill,
-            tau_kill,
-            p_kill,
-        )
-    SEQ["kill"].set_color("r")
+    # times.append(state_next.t)
+    # SEQ["kill"], state_next \
+    #     = kill(
+    #         state_next,
+    #         U_kill,
+    #         hholtz_kill,
+    #         tau_kill,
+    #         p_kill,
+    #         det_kill,
+    #         det_kill_chirp,
+    #     )
+    # SEQ["kill"].set_color("r")
 
     times.append(state_next.t)
     SEQ["AWG"], state_next \
@@ -2198,6 +2423,7 @@ def make_sequence(
                 tau_probe,
                 tau_offset,
                 p_probe_am,
+                det_probe,
                 tt_width,
             )
         SEQ["qubit readout 2"].set_color("C3")
@@ -2252,6 +2478,7 @@ def make_sequence(
                 tau_probe,
                 tau_offset,
                 p_probe_am,
+                det_probe,
                 tt_width,
             )
         SEQ["final atom readout"] = seq0 + seq1
@@ -2295,7 +2522,7 @@ class Main(Controller):
 
         self.timebase = (TIMEBASE.connect()
             # .set_frequency(PROBE_GREEN_TB_FM_CENTER)
-            .set_frequency_mod(False)
+            .set_frequency_mod(True)
             .set_amplitude(27.0)
         )
 
@@ -2399,11 +2626,12 @@ class Main(Controller):
                 .set_frequency(2, det_cool)
             )
         if self.N_probe == 1:
-            p_probe, det_probe = list(product(*probe_arrs))[0]
+            p_probe, = list(product(*probe_arrs))[0]
             # f0, f1 = PROBE_GREEN_DOUBLE_F(det_probe, probe_warn)
             # f0_2 = PROBE_GREEN_DOUBLE_F_2(det_probe_2, f1, probe_warn)
             self.mogrf.set_frequency(4, 90.0)
-            self.timebase.set_amplitude(p_probe).set_frequency(PROBE_GREEN_DOUBLE_F(det_probe))
+            # self.timebase.set_amplitude(p_probe).set_frequency(PROBE_GREEN_DOUBLE_F(det_probe))
+            self.timebase.set_amplitude(p_probe)
         if self.N_mag == 1:
             mag_amp_fb, mag_amp_lr, f_mag, phi_mag, phi_mag_2, tau_ramsey = list(product(*mag_arrs))[0]
             (self.rigol_mag
@@ -2433,12 +2661,13 @@ class Main(Controller):
                             .set_amplitude(2, MOT3_GREEN_ALT_AM(p_cool, det_cool))
                             .set_frequency(2, det_cool)
                         )
-                    for c, (p_probe, det_probe) in enumerate(product(*probe_arrs)):
+                    for c, (p_probe,) in enumerate(product(*probe_arrs)):
                         if self.N_probe > 1:
                             # f0, f1 = PROBE_GREEN_DOUBLE_F(det_probe, probe_warn)
                             # f0_2 = PROBE_GREEN_DOUBLE_F_2(det_probe_2, f1, probe_warn)
                             self.mogrf.set_frequency(4, 90.0)
-                            self.timebase.set_amplitude(p_probe).set_frequency(PROBE_GREEN_DOUBLE_F(det_probe))
+                            # self.timebase.set_amplitude(p_probe).set_frequency(PROBE_GREEN_DOUBLE_F(det_probe))
+                            self.timebase.set_amplitude(p_probe)
                         for d, (mag_amp_fb, mag_amp_lr, f_mag, phi_mag, phi_mag_2, tau_ramsey) in enumerate(product(*mag_arrs)):
                             if self.N_mag > 1:
                                 (self.rigol_mag
@@ -2541,11 +2770,12 @@ class Main(Controller):
                 .set_frequency(2, det_cool)
             )
         if self.N_probe == 1:
-            p_probe, det_probe = list(product(*probe_arrs))[0]
+            p_probe, = list(product(*probe_arrs))[0]
             # f0, f1 = PROBE_GREEN_DOUBLE_F(det_probe, probe_warn)
             # f0_2 = PROBE_GREEN_DOUBLE_F_2(det_probe_2, f1, probe_warn)
             self.mogrf.set_frequency(4, 90.0)
-            self.timebase.set_amplitude(p_probe).set_frequency(PROBE_GREEN_DOUBLE_F(det_probe))
+            # self.timebase.set_amplitude(p_probe).set_frequency(PROBE_GREEN_DOUBLE_F(det_probe))
+            self.timebase.set_amplitude(p_probe)
         if self.N_mag == 1:
             mag_amp_fb, mag_amp_lr, f_mag, phi_mag, phi_mag_2, tau_ramsey = list(product(*mag_arrs))[0]
             (self.rigol_mag
@@ -2576,12 +2806,13 @@ class Main(Controller):
                         .set_frequency(2, det_cool)
                     )
                     time.sleep(0.01)
-                for c, (p_probe, det_probe) in enumerate(product(*probe_arrs)):
+                for c, (p_probe,) in enumerate(product(*probe_arrs)):
                     if self.N_probe > 1:
                         # f0, f1 = PROBE_GREEN_DOUBLE_F(det_probe, probe_warn)
                         # f0_2 = PROBE_GREEN_DOUBLE_F_2(det_probe_2, f1, probe_warn)
                         self.mogrf.set_frequency(4, 90.0)
-                        self.timebase.set_amplitude(p_probe).set_frequency(PROBE_GREEN_DOUBLE_F(det_probe))
+                        # self.timebase.set_amplitude(p_probe).set_frequency(PROBE_GREEN_DOUBLE_F(det_probe))
+                        self.timebase.set_amplitude(p_probe)
                     for d, (mag_amp_fb, mag_amp_lr, f_mag, phi_mag, phi_mag_2, tau_ramsey) in enumerate(product(*mag_arrs)):
                         if self.N_mag > 1:
                             (self.rigol_mag
-- 
GitLab