Skip to content
Snippets Groups Projects
Commit 426e8de7 authored by Yb Tweezer's avatar Yb Tweezer
Browse files

upkeep (dirty)

parent ff7e23bf
No related branches found
No related tags found
No related merge requests found
......@@ -11,25 +11,25 @@ outdir = DATADIRS.compressed_mot.joinpath(timestamp)
comments = """
Narrowline cooling
w/o blue tweezer
w blue tweezer
================================
"""[1:-1]
# CAMERA OPTIONS
camera_config = {
"exposure_time": 300,
"gain": 45.49,
"exposure_time": 20000,
"gain": 47.99,
"gamma": 1.25,
"black_level": 5.0,
"bin_size": 1,
}
clk_freq = 10e6 # Hz
t0 = 2.0 # cooling seq
t0 = 1.0 # cooling seq
tau = 70e-3
SHIMS_LR = np.linspace(0.2, 0.2, 1) # LeftRight
SHIMS_FB = np.linspace(2.2, 2.2, 1) # FrontBack
SHIMS_UD = np.linspace(0.7, 0.7, 1) # UpDown
SHIMS_LR = np.linspace(0, 1, 4) # LeftRight
SHIMS_FB = np.linspace(0, 1, 4) # FrontBack
SHIMS_UD = np.linspace(0, 1, 4) # UpDown
def make_sequence(name: str, shim_fb: float, shim_lr: float, shim_ud: float):
name = f"fb={shim_fb:.5f}_lr={shim_lr:.5f}_ud={shim_ud:.5f}" \
if name is None else name
......@@ -38,12 +38,12 @@ def make_sequence(name: str, shim_fb: float, shim_lr: float, shim_ud: float):
.digital_hilo(*C.dummy, 0.0, t0 + 800e-3)
.with_color("k").with_stack_idx(0)
),
"Camera 1": (Sequence
.digital_pulse(*C.flir_trig, t0 - 10e-3, 0.2985e-3)
.with_color("C2").with_stack_idx(4)
),
# "Camera 1": (Sequence
# .digital_pulse(*C.flir_trig, t0 - 15e-3 - 0*50e-3, 0.2985e-3)
# .with_color("C2").with_stack_idx(4)
# ),
"Camera 2": (Sequence
.digital_pulse(*C.flir_trig, t0 + 80e-3, 0.2985e-3)
.digital_pulse(*C.flir_trig, t0 + tau - 20e-3 + 0*80e-3, 0.2985e-3)
.with_color("C2").with_stack_idx(4)
),
"Push shutter": (Sequence
......@@ -115,9 +115,9 @@ def make_sequence(name: str, shim_fb: float, shim_lr: float, shim_ud: float):
<< Event.analog(**C.shim_coils_fb, s=shim_fb) @ (t0 + tau - 20.5e-3 + 1e-16)
<< Event.analog(**C.shim_coils_lr, s=shim_lr) @ (t0 + tau - 20.5e-3 + 2e-16)
<< Event.analog(**C.shim_coils_ud, s=shim_ud) @ (t0 + tau - 20.5e-3 + 3e-16)
<< Event.analog(**C.shim_coils_fb, s=4.50) @ (t0 + tau + 0e-3 + 1e-16)
<< Event.analog(**C.shim_coils_lr, s=2.20) @ (t0 + tau + 0e-3 + 2e-16)
<< Event.analog(**C.shim_coils_ud, s=4.30) @ (t0 + tau + 0e-3 + 3e-16)
<< Event.analog(**C.shim_coils_fb, s=5.0) @ (t0 + tau + 0e-3 + 1e-16)
<< Event.analog(**C.shim_coils_lr, s=3.50) @ (t0 + tau + 0e-3 + 2e-16)
<< Event.analog(**C.shim_coils_ud, s=4.40) @ (t0 + tau + 0e-3 + 3e-16)
).with_color("C8"),
"Green beams AOM": (Sequence
......@@ -126,15 +126,12 @@ def make_sequence(name: str, shim_fb: float, shim_lr: float, shim_ud: float):
"Green beams shutter": (Sequence
.digital_hilo(*C.mot3_green_sh, t0 - 5e-3, t0 + tau)
).with_color("C6").with_stack_idx(7),
# "Green imaging AOM": (Sequence
# .digital_hilo(*C.raman_green, t0 + tau + 10e-3, t0 + tau + 20e-3 )
# ).with_color("C6").with_stack_idx(6),
# "Blue tweezer shutter": (Sequence
# .digital_pulse(*C.probe_sh, t0 + tau - 15e-3, 15e-3)
# ).with_color("C4").with_stack_idx(3),
# "Blue tweezer aom": (Sequence
# .digital_pulse(*C.probe_aom, t0 + tau - 10e-3, 10e-3)
# ).with_color("C4").with_stack_idx(3),
"Blue tweezer shutter": (Sequence
.digital_pulse(*C.probe_sh, t0 + tau - 15e-3, 15e-3)
).with_color("C4").with_stack_idx(3),
"Blue tweezer aom": (Sequence
.digital_pulse(*C.probe_aom, t0 + tau - 10e-3, 10e-3)
).with_color("C4").with_stack_idx(3),
# "EMCCD": (Sequence
# .digital_pulse(*C.andor_trig, t0 + tau - 17e-3, 10e-3)
......@@ -218,7 +215,7 @@ class FluorescenceImaging(Controller):
self.mog = MOGRF.connect()
(self.mog
.set_frequency(1, 90.0).set_power(1, 29.4)
.set_frequency(1, 90.0).set_power(1, 0)
.set_mode(1, "TSB")
.table_load(1, table)
.set_table_rearm(1, True)
......@@ -238,8 +235,9 @@ class FluorescenceImaging(Controller):
)
arrays = dict()
for k, name in enumerate(self.names):
arrays[name + "_0"] = self.frames[2 * k]
arrays[name + "_1"] = self.frames[2 * k + 1]
arrays[name + "_0"] = self.frames[k]
#arrays[name + "_0"] = self.frames[2 * k]
#arrays[name + "_1"] = self.frames[2 * k + 1]
data = FluorescenceData(
outdir=outdir,
arrays=arrays,
......@@ -262,7 +260,7 @@ class FluorescenceImaging(Controller):
)
def run_camera(self, *args):
self.frames = self.cam.acquire_frames(2 * len(self.names))
self.frames = self.cam.acquire_frames(len(self.names))
def cmd_visualize(self, *args):
make_sequence("", SHIMS_FB.max(), SHIMS_LR.max(), SHIMS_UD.max()) \
......
......@@ -17,9 +17,16 @@ import lib.dataio as io
H = 6.626070040e-34
C = 2.99792458e+8
ROI = [978, 651, 127, 122] # [x, y, w, h]
#ROI = [932, 729, 155, 125] # [x, y, w, h]
ROI = [910, 680, 120, 120]
ROI_s = (S[ROI[1]:ROI[1] + ROI[3]], S[ROI[0]:ROI[0] + ROI[2]])
# ROI_bkgd = [945, 560, 100, 100]
# ROI_bkgd_s = (
# S[ROI_bkgd[1]:ROI_bkgd[1] + ROI_bkgd[3]],
# S[ROI_bkgd[0]:ROI_bkgd[0] + ROI_bkgd[2]]
# )
DEF_DX = 3.45 # pixel size for Flir Grasshopper [um]
class ImagingData:
......@@ -179,46 +186,50 @@ class FluorescenceData(ImagingData):
data.outdir, data.arrays, data.config, data.comments, data.results)
def compute_results(self, subtract_bkgd: bool=True, dA: float=DEF_DX**2,
printflag: bool=True):
printflag: bool=True, debug: bool=False):
_dA = self.config.get("bin_size", 1)**2 * dA
if printflag: print("[imaging] Compute results")
compute_mot_number_params = {
"QE": 0.40,
# "QE": 0.40, #blue
"QE": 0.70, #green
"gain": self.config["gain"],
"exposure_time": self.config["exposure_time"] * 1e-6,
"solid_angle": (0.0127**2 * np.pi) / (4 * np.pi * 0.125**2),
"detuning": 50e6 * 2 * np.pi,
"solid_angle": (0.0127**2 * np.pi) / (4 * np.pi * 0.300**2),
# "detuning": 50e6 * 2 * np.pi, #blue
"detuning": 90e3 * 2 * np.pi, #green
"intensity_parameter": 1.0,
}
N_bkgd = compute_mot_number(
self.arrays["background"].astype(np.float64),
**compute_mot_number_params,
) if subtract_bkgd and "background" in self.arrays.keys() else 0.0
for k, (label, array) in enumerate(self.arrays.items()):
dtype_info = np.iinfo(array.dtype)
if array.max() >= (dtype_info.max - dtype_info.bits):
print(
f"[imaging] WARNING: image '{label}' may contain clipping")
# N = compute_mot_number( # debug
# array.astype(np.float64),
# **compute_mot_number_params,
# label
# )
N = compute_mot_number(
array.astype(np.float64),
**compute_mot_number_params,
k=label if debug else None
)
# sx, sy = lmfit_gaussian(array, _dA, label) # debug
sx, sy = lmfit_gaussian(array, _dA)
self.results = dict() if self.results is None else self.results
self.results.update({
label: {
"N": float(N) - float(N_bkgd)
if label != "background" else float(N),
"sx": float(sx),
"sy": float(sy)
"N": float(N) - float(N_bkgd) if label != "background" else float(N)
}
})
# sx, sy = lmfit_gaussian(array, _dA, k=label if debug else None)
# self.results = dict() if self.results is None else self.results
# self.results.update({
# label: {
# "N": float(N) - float(N_bkgd)
# if label != "background" else float(N),
# "sx": float(sx),
# "sy": float(sy)
# }
# })
return self
def compute_mot_number(image, QE, gain, exposure_time, solid_angle,
......@@ -230,10 +241,13 @@ def compute_mot_number(image, QE, gain, exposure_time, solid_angle,
# slice_w = S[int(W / K_w) : int((K_w - 1) * W / K_w)]
# im = image[slice_h, slice_w]
im = image[ROI_s]
#im_bkgd = image[ROI_bkgd_s]
if k is not None:
pd.Plotter().imshow(image).savefig(f"image_{k}.png").close()
pd.Plotter().imshow(im).savefig(f"img_{k}.png").close()
#pd.Plotter().imshow(image).colorbar().savefig(f"image_{k}.png").close()
pd.Plotter().imshow(im,vmax=65535,vmin=5000).set_title(f'{k}').colorbar().savefig(f"img_{k}.png").close()
#pd.Plotter().imshow(im_bkgd).colorbar().savefig(f"img_bkgd_{k}.png").close()
electron_rate = im.astype(np.float64).sum()
#electron_rate_bkgd = im_bkgd.astype(np.float64).sum()
photon_rate = (
electron_rate
/ 10**(gain / 20) # originally 10, testing out at 20
......@@ -241,13 +255,23 @@ def compute_mot_number(image, QE, gain, exposure_time, solid_angle,
/ solid_angle
/ exposure_time
)
Y = 29.1e6 * 2 * np.pi # transition linewidth; s^-1
l = 399e-9 # transition wavelength; m
# photon_rate_bkgd = (
# electron_rate_bkgd
# / 10**(gain / 20) # originally 10, testing out at 20
# / QE
# / solid_angle
# / exposure_time
# )
# Y = 29.1e6 * 2 * np.pi # transition linewidth; s^-1
# l = 399e-9 # transition wavelength; m
Y = 182e3 * 2 * np.pi # transition linewidth; s^-1
l = 556e-9 # transition wavelength; m
I_sat = (Y * H * C * np.pi) / (3 * l**3)
scatter_rate = lambda D, I: \
(Y / 2) * I / (1 + 4 * (D / Y)**2 + I)
N = photon_rate / scatter_rate(detuning, intensity_parameter)
return N
# N_bkgd = photon_rate_bkgd / scatter_rate(detuning, intensity_parameter)
return N #- N_bkgd
def lls_fit_gaussian(A, dA, k=None): # deprecated
"""
......
......@@ -20,6 +20,8 @@ DATADIRS = DataPaths(
green_shim_scan = DATA_HOME.joinpath("green shim scan"),
green_mot_fluor = DATA_HOME.joinpath("blue fluorescence from green mot"),
compressed_mot = DATA_HOME.joinpath("compressed mot"),
green_fluo_green_mot = DATA_HOME.joinpath("green fluorescene and mot"),
narrow_cooling_opt = DATA_HOME.joinpath("cmot optimization")
)
# DEPRECATED NAMES
......@@ -44,9 +46,9 @@ CONNECTIONS = ConnectionLayout(
mot3_coils_sig = Digital(0, 8, 0),
mot3_coils_clk = Digital(0, 10, 0),
mot3_coils_sync = Digital(0, 14, 1),
shim_coils_ud = Analog(2, 4.30),
shim_coils_lr = Analog(3, 2.20),
shim_coils_fb = Analog(4, 4.50),
shim_coils_ud = Analog(2, 4.40), #optimal values for blue MOT load to green broadband
shim_coils_lr = Analog(3, 3.50),
shim_coils_fb = Analog(4, 5.00),
mot3_coils_igbt = Digital(0, 4, 1),
mot3_shims_onoff = Digital(0, 0, 0),
mot3_blue_sh = Digital(1, 7, 1),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment