Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
whuie2
experiment-control
Commits
f4c642f2
Commit
f4c642f2
authored
Jan 17, 2022
by
whooie
Browse files
Merge branch 'master' of gitlab-uiuc:whuie2/experiment-control
forgot to pull before pushing
parents
c199ff62
b061cb0c
Changes
5
Hide whitespace changes
Inline
Side-by-side
green_fluo_green_mot.py
0 → 100644
View file @
f4c642f2
from
lib
import
*
from
lib
import
CONNECTIONS
as
C
import
datetime
,
sys
,
pathlib
from
lib.system
import
MOGRF
import
time
import
numpy
as
np
timestamp
=
get_timestamp
()
print
(
timestamp
)
outdir
=
DATADIRS
.
green_fluo_green_mot
.
joinpath
(
timestamp
)
comments
=
"""
Find position of green and blue MOTs
================================
"""
[
1
:
-
1
]
# CAMERA OPTIONS
camera_config
=
{
"exposure_time"
:
20000
,
"gain"
:
47.99
,
"gamma"
:
1.25
,
"black_level"
:
5.0
,
"bin_size"
:
1
,
}
clk_freq
=
10e6
# Hz
t0
=
1.0
# cooling seq
tau
=
70e-3
SHIMS_LR
=
np
.
linspace
(
0.0
,
0.0
,
1
)
# LeftRight
SHIMS_FB
=
np
.
linspace
(
0.0
,
0.0
,
1
)
# FrontBack
SHIMS_UD
=
np
.
linspace
(
0.0
,
0.0
,
1
)
# UpDown
green_mot_servo_bit
=
int
(
44182
*
1.1
)
def
make_sequence
(
name
:
str
,
shim_fb
:
float
,
shim_lr
:
float
,
shim_ud
:
float
):
name
=
f
"fb=
{
shim_fb
:.
5
f
}
_lr=
{
shim_lr
:.
5
f
}
_ud=
{
shim_ud
:.
5
f
}
"
\
if
name
is
None
else
name
SEQ
=
SuperSequence
(
outdir
.
joinpath
(
"sequences"
),
name
,
{
"Sequence"
:
(
Sequence
.
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
-
50e-3
,
0.2985e-3
)
.
with_color
(
"C2"
).
with_stack_idx
(
4
)
),
"Camera 2"
:
(
Sequence
.
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
.
digital_lohi
(
*
C
.
push_sh
,
t0
-
25e-3
-
5e-3
,
t0
+
800e-3
)
.
with_color
(
"C3"
).
with_stack_idx
(
3
)
),
"Push aom"
:
(
Sequence
.
digital_lohi
(
*
C
.
push_aom
,
t0
-
15e-3
,
t0
+
800e-3
)
.
with_color
(
"C3"
).
with_stack_idx
(
3
)
),
"MOT servo green MOT"
:
(
Sequence
.
serial_bits_c
(
C
.
mot3_coils_sig
,
t0
,
green_mot_servo_bit
,
20
,
AD5791_DAC
,
4
,
C
.
mot3_coils_clk
,
C
.
mot3_coils_sync
,
clk_freq
)
).
with_color
(
"C1"
).
with_stack_idx
(
2
),
"MOT servo green CMOT 1"
:
(
Sequence
.
serial_bits_c
(
C
.
mot3_coils_sig
,
t0
+
tau
-
23e-3
,
int
(
green_mot_servo_bit
*
1.2
),
20
,
AD5791_DAC
,
4
,
C
.
mot3_coils_clk
,
C
.
mot3_coils_sync
,
clk_freq
)
).
with_color
(
"C1"
).
with_stack_idx
(
2
),
"MOT servo green CMOT 2"
:
(
Sequence
.
serial_bits_c
(
C
.
mot3_coils_sig
,
t0
+
tau
-
22e-3
,
int
(
green_mot_servo_bit
*
1.4
),
20
,
AD5791_DAC
,
4
,
C
.
mot3_coils_clk
,
C
.
mot3_coils_sync
,
clk_freq
)
).
with_color
(
"C1"
).
with_stack_idx
(
2
),
"MOT servo green CMOT 3"
:
(
Sequence
.
serial_bits_c
(
C
.
mot3_coils_sig
,
t0
+
tau
-
21e-3
,
int
(
green_mot_servo_bit
*
1.6
),
20
,
AD5791_DAC
,
4
,
C
.
mot3_coils_clk
,
C
.
mot3_coils_sync
,
clk_freq
)
).
with_color
(
"C1"
).
with_stack_idx
(
2
),
"MOT servo green CMOT 4"
:
(
Sequence
.
serial_bits_c
(
C
.
mot3_coils_sig
,
t0
+
tau
-
20e-3
,
int
(
green_mot_servo_bit
*
1.8
),
20
,
AD5791_DAC
,
4
,
C
.
mot3_coils_clk
,
C
.
mot3_coils_sync
,
clk_freq
)
).
with_color
(
"C1"
).
with_stack_idx
(
2
),
"MOT servo blue MOT recapture"
:
(
Sequence
.
serial_bits_c
(
C
.
mot3_coils_sig
,
t0
+
tau
-
4e-3
,
441815
,
20
,
AD5791_DAC
,
4
,
C
.
mot3_coils_clk
,
C
.
mot3_coils_sync
,
clk_freq
)
).
with_color
(
"C1"
).
with_stack_idx
(
2
),
"Blue beams "
:
(
Sequence
.
digital_hilo
(
*
C
.
mot3_blue_sh
,
0.0
,
t0
-
3e-3
+
0
*
4e-3
)
).
with_color
(
"C0"
).
with_stack_idx
(
5
),
"Blue beams recapture"
:
(
Sequence
.
digital_pulse
(
*
C
.
mot3_blue_sh
,
t0
+
tau
-
4e-3
,
700e-3
)
).
with_color
(
"C0"
).
with_stack_idx
(
5
),
"FB/LR/UD shims"
:
(
Sequence
()
<<
Event
.
analog
(
**
C
.
shim_coils_fb
,
s
=
0.0
)
@
(
t0
+
1e-16
)
<<
Event
.
analog
(
**
C
.
shim_coils_lr
,
s
=
0.0
)
@
(
t0
+
2e-16
)
<<
Event
.
analog
(
**
C
.
shim_coils_ud
,
s
=
0.0
)
@
(
t0
+
3e-16
)
<<
Event
.
analog
(
**
C
.
shim_coils_fb
,
s
=
1
*
shim_fb
)
@
(
t0
+
tau
-
20.5e-3
+
1e-16
)
<<
Event
.
analog
(
**
C
.
shim_coils_lr
,
s
=
1
*
shim_lr
)
@
(
t0
+
tau
-
20.5e-3
+
2e-16
)
<<
Event
.
analog
(
**
C
.
shim_coils_ud
,
s
=
1
*
shim_ud
)
@
(
t0
+
tau
-
20.5e-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
.
digital_hilo
(
*
C
.
mot3_green_aom
,
t0
-
40e-3
,
t0
-
35e-3
)
).
with_color
(
"C6"
).
with_stack_idx
(
6
),
"Green beams shutter"
:
(
Sequence
.
digital_hilo
(
*
C
.
mot3_green_sh
,
t0
-
58e-3
,
t0
+
tau
)
).
with_color
(
"C6"
).
with_stack_idx
(
7
),
# "Green imaging AOM": (Sequence
# .digital_hilo(*C.raman_green, t0 - 70e-3, t0 - 50e-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),
# "EMCCD": (Sequence
# .digital_pulse(*C.andor_trig, t0 + tau - 17e-3, 10e-3)
# ).with_color("C2").with_stack_idx(4),
"Scope"
:
(
Sequence
.
digital_hilo
(
*
C
.
scope_trig
,
t0
-
50e-3
,
t0
+
800e-3
)
.
with_color
(
"C7"
).
with_stack_idx
(
1
)
),
},
C
)
return
SEQ
seq_bkgd
=
SuperSequence
(
outdir
.
joinpath
(
"sequences"
),
f
"background"
,
{
"Sequence"
:
(
Sequence
.
digital_hilo
(
*
C
.
dummy
,
0.0
,
100e-3
)
),
"Push"
:
(
Sequence
.
digital_lohi
(
*
C
.
push_sh
,
0.0
,
100e-3
)
),
"MOT beams"
:
(
Sequence
.
digital_lohi
(
*
C
.
mot3_blue_sh
,
0.0
,
50e-3
)
),
"MOT coils"
:
(
Sequence
.
digital_hilo
(
*
C
.
mot3_coils_igbt
,
0.0
,
100e-3
)
.
digital_hilo
(
*
C
.
mot3_coils_onoff
,
0.0
,
100e-3
)
),
"Camera"
:
(
Sequence
.
digital_pulse
(
*
C
.
flir_trig
,
80e-3
,
camera_config
[
"exposure_time"
]
*
1e-6
)
),
"Scope"
:
(
Sequence
.
digital_hilo
(
*
C
.
scope_trig
,
0.0
,
100e-3
)
),
},
C
)
class
FluorescenceImaging
(
Controller
):
def
precmd
(
self
,
*
args
):
self
.
comp
=
MAIN
.
connect
()
(
self
.
comp
.
def_digital
(
*
C
.
mot3_coils_onoff
,
1
)
.
def_digital
(
*
C
.
mot3_blue_sh
,
1
)
.
def_digital
(
*
C
.
push_aom
,
1
)
.
def_digital
(
*
C
.
push_sh
,
1
)
)
self
.
cam
=
FLIR
.
connect
()
(
self
.
cam
.
configure_capture
(
**
camera_config
)
.
configure_trigger
()
)
self
.
names
=
list
()
self
.
sequences
=
list
()
self
.
ssequences
=
list
()
for
fb
in
SHIMS_FB
:
for
lr
in
SHIMS_LR
:
for
ud
in
SHIMS_UD
:
name
=
f
"fb=
{
fb
:.
5
f
}
_lr=
{
lr
:.
5
f
}
_ud=
{
ud
:.
5
f
}
"
sseq
=
make_sequence
(
name
,
fb
,
lr
,
ud
)
self
.
names
.
append
(
name
)
self
.
sequences
.
append
(
sseq
.
to_sequence
())
self
.
ssequences
.
append
(
sseq
)
ramp_time
=
30e-3
# in s
ramp_N
=
1000
delta_t
=
ramp_time
/
ramp_N
ramp_range
=
4
# MHz
f0
=
90
# MHz
delta_f
=
ramp_range
/
ramp_N
freq
=
f0
+
np
.
arange
(
0
,
ramp_N
+
1
)
*
delta_f
table
=
mogdriver
.
MOGTable
()
t_ref
=
1e-3
t_ramp
=
t_ref
+
20e-3
+
34e-3
t_hold
=
20e-3
table
<<
mogdriver
.
MOGEvent
(
frequency
=
f0
,
power
=
29.0
)
@
(
t_ref
)
for
ind
,
value
in
enumerate
(
freq
):
table
<<
mogdriver
.
MOGEvent
(
frequency
=
value
,
power
=
29.0
-
ind
*
0.015
)
@
(
t_ramp
+
ind
*
delta_t
)
table
<<
mogdriver
.
MOGEvent
(
frequency
=
value
,
power
=
0.0
)
@
(
t_ramp
+
ind
*
delta_t
+
t_hold
)
self
.
mog
=
MOGRF
.
connect
()
(
self
.
mog
.
set_frequency
(
1
,
90.0
).
set_power
(
1
,
29.0
)
.
set_mode
(
1
,
"TSB"
)
.
table_load
(
1
,
table
)
.
set_table_rearm
(
1
,
True
)
.
table_arm
(
1
)
)
def
postcmd
(
self
,
*
args
):
self
.
comp
.
clear
().
disconnect
()
self
.
cam
.
disconnect
()
(
self
.
mog
.
table_stop
(
1
)
.
table_clear
(
1
)
.
set_frequency
(
1
,
90.0
).
set_power
(
1
,
29.04
)
.
set_mode
(
1
,
"NSB"
)
.
set_output
(
1
,
True
)
.
disconnect
()
)
arrays
=
dict
()
for
k
,
name
in
enumerate
(
self
.
names
):
arrays
[
name
+
"_0"
]
=
self
.
frames
[
2
*
k
]
arrays
[
name
+
"_1"
]
=
self
.
frames
[
2
*
k
+
1
]
data
=
FluorescenceData
(
outdir
=
outdir
,
arrays
=
arrays
,
config
=
camera_config
,
comments
=
comments
)
data
.
compute_results
()
data
.
save
()
for
sseq
in
self
.
ssequences
:
sseq
.
save
()
data
.
render_arrays
()
def
run_sequence
(
self
,
*
args
):
for
name
,
seq
in
zip
(
self
.
names
,
self
.
sequences
):
print
(
name
)
(
self
.
comp
.
enqueue
(
seq
)
.
run
()
.
clear
()
)
def
run_camera
(
self
,
*
args
):
self
.
frames
=
self
.
cam
.
acquire_frames
(
2
*
len
(
self
.
names
))
def
cmd_visualize
(
self
,
*
args
):
make_sequence
(
""
,
SHIMS_FB
.
max
(),
SHIMS_LR
.
max
(),
SHIMS_UD
.
max
())
\
.
draw_detailed
().
show
().
close
()
sys
.
exit
(
0
)
if
__name__
==
"__main__"
:
FluorescenceImaging
().
RUN
()
\ No newline at end of file
green_mot_ramp_shim_scan.py
View file @
f4c642f2
...
...
@@ -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"
:
3
00
,
"gain"
:
4
5.4
9
,
"exposure_time"
:
200
00
,
"gain"
:
4
7.9
9
,
"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
:.
5
f
}
_lr=
{
shim_lr
:.
5
f
}
_ud=
{
shim_ud
:.
5
f
}
"
\
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 - 1
5e-3 - 0*5
0e-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.2
0
)
@
(
t0
+
tau
+
0e-3
+
2e-16
)
<<
Event
.
analog
(
**
C
.
shim_coils_ud
,
s
=
4.
3
0
)
@
(
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.5
0
)
@
(
t0
+
tau
+
0e-3
+
2e-16
)
<<
Event
.
analog
(
**
C
.
shim_coils_ud
,
s
=
4.
4
0
)
@
(
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
())
\
...
...
lib/imaging.py
View file @
f4c642f2
...
...
@@ -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
"""
...
...
lib/system.py
View file @
f4c642f2
...
...
@@ -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
,
5.20
),
#optimal values for blue MOT load to green broadband 4.4
shim_coils_lr
=
Analog
(
3
,
1.50
),
# 3.5
shim_coils_fb
=
Analog
(
4
,
3.00
),
# 5.0
mot3_coils_igbt
=
Digital
(
0
,
4
,
1
),
mot3_shims_onoff
=
Digital
(
0
,
0
,
0
),
mot3_blue_sh
=
Digital
(
1
,
7
,
1
),
...
...
narrow_cooling_opt.py
0 → 100644
View file @
f4c642f2
from
lib
import
*
from
lib
import
CONNECTIONS
as
C
import
datetime
,
sys
,
pathlib
from
lib.system
import
MOGRF
import
time
import
numpy
as
np
timestamp
=
get_timestamp
()
print
(
timestamp
)
outdir
=
DATADIRS
.
narrow_cooling_opt
.
joinpath
(
timestamp
)
comments
=
"""
Get dense CMOT
================================
"""
[
1
:
-
1
]
# CAMERA OPTIONS
camera_config
=
{
"exposure_time"
:
2000
,
"gain"
:
47.99
,
"gamma"
:
1.25
,
"black_level"
:
5.0
,
"bin_size"
:
1
,
}
clk_freq
=
10e6
# Hz
t0
=
1.0
# cooling seq
tau
=
70e-3
SHIMS_LR
=
np
.
linspace
(
0.05
,
0.05
,
1
)
# LeftRight
SHIMS_FB
=
np
.
linspace
(
1.7
,
1.7
,
1
)
# FrontBack
SHIMS_UD
=
np
.
linspace
(
0.25
,
0.25
,
1
)
# UpDown
green_mot_servo_bit
=
int
(
44182
*
1.1
)
def
make_sequence
(
name
:
str
,
shim_fb
:
float
,
shim_lr
:
float
,
shim_ud
:
float
):
name
=
f
"fb=
{
shim_fb
:.
5
f
}
_lr=
{
shim_lr
:.
5
f
}
_ud=
{
shim_ud
:.
5
f
}
"
\
if
name
is
None
else
name
SEQ
=
SuperSequence
(
outdir
.
joinpath
(
"sequences"
),
name
,
{
"Sequence"
:
(
Sequence
.
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
+
tau
-
10e-3
+
0
*
80e-3
,
0.2985e-3
)
.
with_color
(
"C2"
).
with_stack_idx
(
4
)
),
# "Camera 2": (Sequence
# .digital_pulse(*C.flir_trig, t0 + tau + 15e-3, 0.2985e-3)
# .with_color("C2").with_stack_idx(4)
# ),
"Push shutter"
:
(
Sequence
.
digital_lohi
(
*
C
.
push_sh
,
t0
-
25e-3
-
5e-3
,
t0
+
800e-3
)
.
with_color
(
"C3"
).
with_stack_idx
(
3
)
),
"Push aom"
:
(
Sequence
.
digital_lohi
(
*
C
.
push_aom
,
t0
-
15e-3
,
t0
+
800e-3
)
.
with_color
(
"C3"
).
with_stack_idx
(
3
)
),