Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
artiq_experiments
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Nicolas Nunez Barreto
artiq_experiments
Commits
a0718351
Commit
a0718351
authored
Apr 27, 2022
by
Nicolas Nunez Barreto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
agrego una boludez
parent
af7aa5ab
Changes
17
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
2054 additions
and
24 deletions
+2054
-24
IR_blinking_both.py
artiq_master/repository/Calibrations/IR_blinking_both.py
+10
-3
IR_Power_calibration.py
...brations/Power Calibration AOM/IR/IR_Power_calibration.py
+256
-0
IR_Power_calibration_BS.py
...tions/Power Calibration AOM/IR/IR_Power_calibration_BS.py
+143
-0
IR_Power_calibration_BS_rpi.py
...s/Power Calibration AOM/IR/IR_Power_calibration_BS_rpi.py
+141
-0
IR_Power_calibration_BS_rpi_superfine.py
...libration AOM/IR/IR_Power_calibration_BS_rpi_superfine.py
+141
-0
IR_Power_calibration_check.py
...ns/Power Calibration AOM/IR/IR_Power_calibration_check.py
+102
-0
IR_Power_calibration_check_rpi.py
...ower Calibration AOM/IR/IR_Power_calibration_check_rpi.py
+99
-0
IR_Calibration_Fitting.py
...ibrations/Power Calibration AOM/IR_Calibration_Fitting.py
+48
-0
Photodiode_in_time.py
.../Calibrations/Power Calibration AOM/Photodiode_in_time.py
+103
-0
Power_calibration_check.py
...brations/Power Calibration AOM/Power_calibration_check.py
+95
-0
Power_calibration_inversed.py
...tions/Power Calibration AOM/Power_calibration_inversed.py
+58
-21
Power_calibration_v2.py
...alibrations/Power Calibration AOM/Power_calibration_v2.py
+137
-0
UV_Power_calibration.py
...brations/Power Calibration AOM/UV/UV_Power_calibration.py
+234
-0
UV_Power_calibration_BS.py
...tions/Power Calibration AOM/UV/UV_Power_calibration_BS.py
+144
-0
UV_Power_calibration_BS_rpi.py
...s/Power Calibration AOM/UV/UV_Power_calibration_BS_rpi.py
+141
-0
UV_Power_calibration_check.py
...ns/Power Calibration AOM/UV/UV_Power_calibration_check.py
+102
-0
UV_Power_calibration_check_rpi.py
...ower Calibration AOM/UV/UV_Power_calibration_check_rpi.py
+100
-0
No files found.
artiq_master/repository/Calibrations/IR_blinking_both.py
View file @
a0718351
...
@@ -41,11 +41,18 @@ class PMTCalibration(EnvExperiment):
...
@@ -41,11 +41,18 @@ class PMTCalibration(EnvExperiment):
@
kernel
@
kernel
def
init_kernel
(
self
):
def
init_kernel
(
self
):
self
.
core
.
reset
()
self
.
core
.
reset
()
self
.
laserIR
.
initialize_channel
()
#self.laserIR.initialize_channel()
self
.
laserUV
.
initialize_channel
()
#self.laserUV.channel.cpld.init()
#self.laserUV.channel.init()
#self.laserIR.channel.cpld.init()
#self.core.wait_until_mu(now_mu())
#self.laserIR.channel.init()
#self.laserUV.initialize_channel()
self
.
pmt
.
input
()
self
.
pmt
.
input
()
delay
(
10
*
us
)
delay
(
10
00
*
us
)
self
.
laserIR
.
set_channel
()
self
.
laserIR
.
set_channel
()
self
.
laserUV
.
set_channel
()
self
.
laserUV
.
set_channel
()
...
...
artiq_master/repository/Calibrations/Power Calibration AOM/IR/IR_Power_calibration.py
0 → 100644
View file @
a0718351
import
numpy
as
np
from
time
import
sleep
from
artiq.experiment
import
*
from
pyLIAF.artiq.controllers
import
UrukulCh
from
pyLIAF.RedPitaya
import
Read_analog
as
rp
from
scipy
import
interpolate
class
LaserPowerCalibration
(
EnvExperiment
):
"""IR Laser power calibration with photodiode and a red pitaya """
def
build
(
self
):
self
.
setattr_device
(
"ccb"
)
self
.
setattr_device
(
"scheduler"
)
self
.
setattr_device
(
"core"
)
self
.
laserIR
=
UrukulCh
(
self
,
ch
=
1
,
freq
=
208.0
,
amp
=
0.35
,
name
=
"IR"
)
self
.
setattr_argument
(
"Do_calibration"
,
BooleanValue
(
False
),
"Calibration_parameters"
)
self
.
setattr_argument
(
"Calibration_PD_Value_IR"
,
NumberValue
(
0.2
,
min
=
0.01
,
max
=
0.5
,
ndecimals
=
5
),
"Calibration_parameters"
)
self
.
setattr_argument
(
"Calibration_freqs_IR"
,
Scannable
(
default
=
CenterScan
(
208
*
MHz
,
10
*
MHz
,
0.1
*
MHz
),
unit
=
"MHz"
,
scale
=
MHz
,
global_min
=
1
*
MHz
,
global_max
=
400
*
MHz
)
)
self
.
setattr_argument
(
"Calibration_amps_IR"
,
Scannable
(
default
=
CenterScan
(
0.2
,
0.1
,
0.01
),
global_min
=
0
,
global_max
=
0.35
)
)
# self.setattr_argument("Experiment_frequencies", Scannable(
# default=CenterScan(110*MHz, 10*MHz, 0.1*MHz),
# unit="MHz",
# scale=MHz,
# global_min = 1*MHz,
# global_max = 400*MHz
# )
# )
@
rpc
def
create_datasets
(
self
):
if
self
.
Do_calibration
:
self
.
set_dataset
(
"PD_IR_counts"
,
list
(
np
.
zeros
(
len
(
self
.
Calibration_freqs_IR
.
sequence
)
*
len
(
self
.
Calibration_amps_IR
.
sequence
),
dtype
=
int
)),
broadcast
=
True
,
archive
=
True
)
self
.
set_dataset
(
"Calibration_freqs_IR"
,
len
(
self
.
Calibration_amps_IR
.
sequence
)
*
self
.
Calibration_freqs_IR
.
sequence
,
broadcast
=
True
,
archive
=
True
)
self
.
set_dataset
(
"Calibration_amps_IR"
,
self
.
Calibration_amps_IR
.
sequence
,
broadcast
=
True
,
archive
=
True
)
self
.
set_dataset
(
"Calibration_freqs_IR_Raw"
,
self
.
Calibration_freqs_IR
.
sequence
,
broadcast
=
True
,
archive
=
True
)
self
.
set_dataset
(
"Experiment_freqs_IR"
,
self
.
Calibration_freqs_IR
.
sequence
,
broadcast
=
True
,
archive
=
True
)
self
.
set_dataset
(
"Experiment_amps_IR"
,
np
.
zeros
(
len
(
self
.
Calibration_freqs_IR
.
sequence
),
dtype
=
float
),
broadcast
=
True
,
archive
=
True
)
@
rpc
(
flags
=
{
"async"
})
def
create_applets
(
self
):
self
.
ccb
.
issue
(
"create_applet"
,
"powercalibration"
,
"${python} -m pyLIAF.artiq.applets.plot_xy "
"PD_IR_counts "
"--x Calibration_freqs_IR"
)
@
rpc
(
flags
=
{
"async"
})
def
RemoveZeros
(
calib
,
freqs
):
i
,
j
=
0
,
1
new_calib
=
calib
while
i
<
len
(
calib
):
if
new_calib
[
0
]
==
0
:
new_calib
=
new_calib
[
1
:]
i
=
i
+
1
else
:
init_len
=
len
(
new_calib
)
final_calib
=
new_calib
while
j
<
init_len
:
if
final_calib
[
-
1
]
==
0
:
final_calib
=
final_calib
[:
-
1
]
j
=
j
+
1
else
:
if
j
==
1
:
return
freqs
[
i
:],
final_calib
else
:
return
freqs
[
i
:
-
j
+
1
],
final_calib
@
rpc
(
flags
=
{
"async"
})
def
Calibrate_amplitudes
(
self
):
Interpolation_functions
=
[]
PD_IR_counts
=
self
.
get_dataset
(
"PD_IR_counts"
)
n
=
len
(
self
.
Calibration_freqs_IR
.
sequence
)
PD_split
=
np
.
matrix
([
PD_IR_counts
[
i
*
n
:(
i
+
1
)
*
n
]
for
i
in
range
((
len
(
PD_IR_counts
)
+
n
-
1
)
//
n
)])
PD_T
=
np
.
transpose
(
PD_split
)
amps
=
self
.
Calibration_amps_IR
.
sequence
for
i
in
range
(
len
(
PD_T
)):
PD_values
=
np
.
array
(
PD_T
[
i
])[
0
]
f
=
interpolate
.
interp1d
(
PD_values
,
amps
,
kind
=
'linear'
)
Interpolation_functions
.
append
(
f
)
Calibration_PD_Value_IR
=
self
.
Calibration_PD_Value_IR
Calibrated_Amplitudes_IR
=
[]
for
fi
in
Interpolation_functions
:
try
:
Calibrated_Amplitudes_IR
.
append
(
float
(
fi
(
Calibration_PD_Value_IR
)))
except
:
Calibrated_Amplitudes_IR
.
append
(
0
)
print
(
'no, rey'
)
#Freqs_withoutZeros, Calibs_withoutZeros = RemoveZeros(Calibs, freqs)
Function_Calibs_vs_freq
=
interpolate
.
interp1d
(
self
.
Calibration_freqs_IR
.
sequence
,
Calibrated_Amplitudes_IR
,
kind
=
'linear'
)
i
=
0
for
freq
in
self
.
Calibration_freqs_IR
.
sequence
:
calibamp
=
Function_Calibs_vs_freq
(
freq
)
print
(
calibamp
)
self
.
mutate_dataset
(
"Experiment_amps_IR"
,
i
,
calibamp
)
i
=
i
+
1
print
(
'okarda con la calibreta'
)
@
rpc
(
flags
=
{
"async"
})
def
Recalibrate_amplitudes
(
self
):
Interpolation_functions
=
[]
PD_IR_counts
=
self
.
get_dataset
(
"PD_IR_counts"
)
Original_calib_freqs
=
self
.
get_dataset
(
"Calibration_freqs_IR_Raw"
)
n
=
len
(
Original_calib_freqs
)
PD_split
=
np
.
matrix
([
PD_IR_counts
[
i
*
n
:(
i
+
1
)
*
n
]
for
i
in
range
((
len
(
PD_IR_counts
)
+
n
-
1
)
//
n
)])
PD_T
=
np
.
transpose
(
PD_split
)
amps
=
self
.
Calibration_amps_IR
.
sequence
for
i
in
range
(
len
(
PD_T
)):
PD_values
=
np
.
array
(
PD_T
[
i
])[
0
]
f
=
interpolate
.
interp1d
(
PD_values
,
amps
,
kind
=
'linear'
)
Interpolation_functions
.
append
(
f
)
Calibration_PD_Value_IR
=
self
.
Calibration_PD_Value_IR
Calibrated_Amplitudes_IR
=
[]
for
fi
in
Interpolation_functions
:
try
:
Calibrated_Amplitudes_IR
.
append
(
float
(
fi
(
Calibration_PD_Value_IR
)))
except
:
Calibrated_Amplitudes_IR
.
append
(
0
)
print
(
'no, rey'
)
#Freqs_withoutZeros, Calibs_withoutZeros = RemoveZeros(Calibs, freqs)
Function_Calibs_vs_freq
=
interpolate
.
interp1d
(
Original_calib_freqs
,
Calibrated_Amplitudes_IR
,
kind
=
'linear'
)
i
=
0
for
freq
in
self
.
Calibration_freqs_IR
.
sequence
:
calibamp
=
float
(
Function_Calibs_vs_freq
(
freq
))
print
(
calibamp
)
self
.
mutate_dataset
(
"Experiment_amps_IR"
,
i
,
calibamp
)
i
=
i
+
1
print
(
'okarda con la calibreta'
)
@
rpc
(
flags
=
{
"async"
})
def
measure_PD
(
self
,
i
,
dump
=
False
):
if
not
self
.
RPstatus
:
self
.
rp_s
=
rp
.
Initiate_comm
()
self
.
RPstatus
=
True
value
=
rp
.
ReadVoltage
(
self
.
rp_s
)
print
(
value
)
if
not
dump
:
self
.
mutate_dataset
(
f
"PD_IR_counts"
,
i
,
np
.
abs
(
value
))
@
kernel
def
init_kernel
(
self
):
self
.
core
.
reset
()
self
.
laserIR
.
initialize_channel
()
delay
(
10
*
us
)
#self.laserIR.set_channel()
self
.
core
.
wait_until_mu
(
now_mu
())
delay
(
1
*
ms
)
self
.
laserIR
.
on
()
@
kernel
def
laser_off
(
self
):
self
.
core
.
break_realtime
()
self
.
laserIR
.
off
()
@
kernel
def
laser_on
(
self
):
delay
(
400
*
ms
)
self
.
laserIR
.
on
()
@
kernel
def
change_frequency
(
self
,
freq
,
amp
):
self
.
core
.
break_realtime
()
delay
(
50
*
ms
)
self
.
laserIR
.
set_frequency
(
freq
,
amp
)
delay
(
50
*
ms
)
#def GetTargetAmplitude(self, amplitudes, PD_values, i):
#f = interpolate.interp1d(amplitudes, PD_values)
#amplitudes_interpoladas = np.arange()
def
run
(
self
):
self
.
create_datasets
()
self
.
create_applets
()
self
.
init_kernel
()
self
.
RPstatus
=
False
self
.
No_freqs
=
len
(
self
.
Calibration_freqs_IR
.
sequence
)
i
=
0
self
.
measure_PD
(
0
,
dump
=
True
)
if
self
.
Do_calibration
:
print
(
'Usaremos mediciones nuevas'
)
for
amp
in
self
.
Calibration_amps_IR
.
sequence
:
print
(
amp
)
for
freq
in
self
.
Calibration_freqs_IR
.
sequence
:
#self.laser_on()
self
.
change_frequency
(
freq
,
amp
)
j
=
1
while
j
<
2
:
self
.
measure_PD
(
0
,
dump
=
True
)
j
=
j
+
1
self
.
measure_PD
(
i
)
#self.laser_off()
i
=
i
+
1
self
.
Calibrate_amplitudes
()
else
:
print
(
'Usando mediciones ya hechas'
)
self
.
Recalibrate_amplitudes
()
artiq_master/repository/Calibrations/Power Calibration AOM/IR/IR_Power_calibration_BS.py
0 → 100644
View file @
a0718351
import
numpy
as
np
from
time
import
sleep
from
artiq.experiment
import
*
from
pyLIAF.artiq.controllers
import
UrukulCh
from
pyLIAF.RedPitaya
import
Read_analog
as
rp
from
scipy
import
interpolate
class
IR_LaserPowerCalibration_BS
(
EnvExperiment
):
"""Binary search - IR Laser power calibration with photodiode and a red pitaya """
def
build
(
self
):
self
.
setattr_device
(
"ccb"
)
self
.
setattr_device
(
"scheduler"
)
self
.
setattr_device
(
"core"
)
self
.
laserIR
=
UrukulCh
(
self
,
ch
=
1
,
freq
=
208.0
,
amp
=
0.3
,
name
=
"IR"
)
#corresponde a 0.7 Vpp
self
.
setattr_argument
(
"Target_PD_Value"
,
NumberValue
(
0.4
,
min
=
0.01
,
max
=
0.5
),
"Calibration_parameters"
)
self
.
setattr_argument
(
"Max_amplitude"
,
NumberValue
(
0.30
,
min
=
0.01
,
max
=
0.35
),
"Calibration_parameters"
)
self
.
setattr_argument
(
"Min_amplitude"
,
NumberValue
(
0.01
,
min
=
0.01
,
max
=
0.35
),
"Calibration_parameters"
)
#self.setattr_argument("tolerance", NumberValue(0.005, max=0.5), "Calibration_parameters")
self
.
setattr_argument
(
"Calibration_freqs_IR"
,
Scannable
(
default
=
CenterScan
(
208
*
MHz
,
10
*
MHz
,
0.1
*
MHz
),
unit
=
"MHz"
,
scale
=
MHz
,
global_min
=
1
*
MHz
,
global_max
=
400
*
MHz
)
)
@
rpc
def
create_datasets
(
self
):
#self.set_dataset("PD_UV_counts", list(np.zeros(len(self.Calibration_freqs.sequence)*len(self.Calibration_amps.sequence), dtype=int)), broadcast=True, archive=True)
self
.
set_dataset
(
"Current_PD_IR"
,
np
.
array
([
0.05
]),
broadcast
=
True
,
archive
=
False
)
self
.
set_dataset
(
"Calibration_freqs"
,
self
.
Calibration_freqs_IR
.
sequence
,
broadcast
=
True
,
archive
=
True
)
self
.
set_dataset
(
"Experiment_freqs_IR"
,
self
.
Calibration_freqs_IR
.
sequence
,
broadcast
=
True
,
archive
=
True
)
self
.
set_dataset
(
"Experiment_amps_IR"
,
np
.
zeros
(
len
(
self
.
Calibration_freqs_IR
.
sequence
),
dtype
=
float
),
broadcast
=
True
,
archive
=
True
)
@
rpc
(
flags
=
{
"async"
})
def
create_applets
(
self
):
self
.
ccb
.
issue
(
"create_applet"
,
"IR_powercalibration_BS"
,
"${python} -m pyLIAF.artiq.applets.plot_xy "
"Experiment_amps_IR "
"--x Calibration_freqs"
)
@
rpc
(
flags
=
{
"async"
})
def
Binary_Search
(
self
,
pd_value
,
initial_amplitude
,
final_amplitude
,
current_freq
):
mid_amplitude
=
round
(
0.5
*
(
initial_amplitude
+
final_amplitude
),
4
)
print
(
f
'mid_amplitude: {mid_amplitude}'
)
if
abs
(
initial_amplitude
-
mid_amplitude
)
<
0.00001
or
abs
(
final_amplitude
-
mid_amplitude
)
<
0.00001
:
print
(
'toco un borde jejox'
)
return
mid_amplitude
#else:
if
mid_amplitude
>
self
.
Max_amplitude
or
mid_amplitude
<
self
.
Min_amplitude
:
raise
self
.
change_frequency
(
current_freq
,
mid_amplitude
)
self
.
measure_PD
(
dump
=
True
)
self
.
measure_PD
()
measured_PD
=
self
.
get_dataset
(
"Current_PD_IR"
)[
0
]
if
np
.
abs
(
measured_PD
-
pd_value
)
>
0.00005
:
if
measured_PD
>
pd_value
:
return
self
.
Binary_Search
(
pd_value
,
initial_amplitude
,
mid_amplitude
,
current_freq
)
elif
measured_PD
<
pd_value
:
return
self
.
Binary_Search
(
pd_value
,
mid_amplitude
,
final_amplitude
,
current_freq
)
else
:
print
(
'no se, fijate, paso algo'
)
return
0
else
:
return
mid_amplitude
@
rpc
(
flags
=
{
"async"
})
def
measure_PD
(
self
,
dump
=
False
):
if
not
self
.
RPstatus
:
self
.
rp_s
=
rp
.
Initiate_comm
()
self
.
RPstatus
=
True
value
=
rp
.
ReadVoltage
(
self
.
rp_s
)
print
(
value
)
if
not
dump
:
self
.
mutate_dataset
(
f
"Current_PD_IR"
,
0
,
np
.
abs
(
value
))
@
kernel
def
init_kernel
(
self
):
self
.
core
.
reset
()
delay
(
1
*
ms
)
self
.
core
.
break_realtime
()
self
.
laserIR
.
initialize_channel
()
delay
(
100
*
us
)
self
.
laserIR
.
set_channel
()
self
.
core
.
wait_until_mu
(
now_mu
())
delay
(
1
*
ms
)
self
.
laserIR
.
on
()
@
kernel
def
change_frequency
(
self
,
freq
,
amp
):
self
.
core
.
break_realtime
()
delay
(
50
*
ms
)
self
.
laserIR
.
set_frequency
(
freq
,
amp
)
delay
(
50
*
ms
)
def
run
(
self
):
self
.
create_datasets
()
self
.
create_applets
()
self
.
init_kernel
()
self
.
RPstatus
=
False
i
=
0
self
.
measure_PD
(
dump
=
True
)
initial_amplitude
=
self
.
Min_amplitude
final_amplitude
=
self
.
Max_amplitude
initial_PD
=
self
.
Target_PD_Value
for
freq
in
self
.
Calibration_freqs_IR
.
sequence
:
self
.
change_frequency
(
freq
,
initial_amplitude
)
self
.
measure_PD
(
dump
=
True
)
calibrated_amplitude
=
self
.
Binary_Search
(
initial_PD
,
initial_amplitude
,
final_amplitude
,
freq
)
print
(
f
'Done freq {freq}'
)
self
.
mutate_dataset
(
"Experiment_amps_IR"
,
i
,
calibrated_amplitude
)
#initial_amplitude = calibrated_amplitude-0.1
#final_amplitude = calibrated_amplitude+0.1
i
=
i
+
1
artiq_master/repository/Calibrations/Power Calibration AOM/IR/IR_Power_calibration_BS_rpi.py
0 → 100644
View file @
a0718351
import
numpy
as
np
from
time
import
sleep
from
artiq.experiment
import
*
from
pyLIAF.artiq.controllers
import
UrukulCh
#from pyLIAF.RedPitaya import Read_analog as rp
from
pyLIAF.RaspberryPi.PD_reader
import
PDreader
as
rpi
from
scipy
import
interpolate
class
IR_LaserPowerCalibration_BS
(
EnvExperiment
):
"""Binary search - IR Laser power calibration with photodiode and a raspberry pi """
def
build
(
self
):
self
.
setattr_device
(
"ccb"
)
self
.
setattr_device
(
"scheduler"
)
self
.
setattr_device
(
"core"
)
self
.
laserIR
=
UrukulCh
(
self
,
ch
=
1
,
freq
=
208.0
,
amp
=
0.3
,
name
=
"IR"
)
#corresponde a 0.7 Vpp
self
.
setattr_argument
(
"Target_PD_Value"
,
NumberValue
(
0.4
,
min
=
0.01
,
max
=
3
),
"Calibration_parameters"
)
self
.
setattr_argument
(
"Max_amplitude"
,
NumberValue
(
0.30
,
min
=
0.01
,
max
=
0.35
),
"Calibration_parameters"
)
self
.
setattr_argument
(
"Min_amplitude"
,
NumberValue
(
0.01
,
min
=
0.01
,
max
=
0.35
),
"Calibration_parameters"
)
#self.setattr_argument("tolerance", NumberValue(0.005, max=0.5), "Calibration_parameters")
self
.
setattr_argument
(
"Calibration_freqs_IR"
,
Scannable
(
default
=
CenterScan
(
208
*
MHz
,
10
*
MHz
,
0.1
*
MHz
),
unit
=
"MHz"
,
scale
=
MHz
,
global_min
=
1
*
MHz
,
global_max
=
400
*
MHz
)
)
@
rpc
def
create_datasets
(
self
):
#self.set_dataset("PD_UV_counts", list(np.zeros(len(self.Calibration_freqs.sequence)*len(self.Calibration_amps.sequence), dtype=int)), broadcast=True, archive=True)
self
.
set_dataset
(
"Current_PD_IR"
,
np
.
array
([
0.05
]),
broadcast
=
True
,
archive
=
False
)
self
.
set_dataset
(
"Calibration_freqs"
,
self
.
Calibration_freqs_IR
.
sequence
,
broadcast
=
True
,
archive
=
True
)
self
.
set_dataset
(
"Experiment_freqs_IR"
,
self
.
Calibration_freqs_IR
.
sequence
,
broadcast
=
True
,
archive
=
True
)
self
.
set_dataset
(
"Experiment_amps_IR"
,
np
.
zeros
(
len
(
self
.
Calibration_freqs_IR
.
sequence
),
dtype
=
float
),
broadcast
=
True
,
archive
=
True
)
@
rpc
(
flags
=
{
"async"
})
def
create_applets
(
self
):
self
.
ccb
.
issue
(
"create_applet"
,
"IR_powercalibration_BS"
,
"${python} -m pyLIAF.artiq.applets.plot_xy "
"Experiment_amps_IR "
"--x Calibration_freqs"
)
@
rpc
(
flags
=
{
"async"
})
def
Binary_Search
(
self
,
pd_value
,
initial_amplitude
,
final_amplitude
,
current_freq
):
mid_amplitude
=
round
(
0.5
*
(
initial_amplitude
+
final_amplitude
),
4
)
#print(f'mid_amplitude: {mid_amplitude}')
if
abs
(
initial_amplitude
-
mid_amplitude
)
<
0.00001
or
abs
(
final_amplitude
-
mid_amplitude
)
<
0.00001
:
#print('toco un borde jejox')
return
mid_amplitude
#else:
if
mid_amplitude
>
self
.
Max_amplitude
or
mid_amplitude
<
self
.
Min_amplitude
:
print
(
'Pusiste al reves los limites'
)
raise
self
.
change_frequency
(
current_freq
,
mid_amplitude
)
#self.measure_PD(dump=True)
self
.
measure_PD
()
measured_PD
=
self
.
get_dataset
(
"Current_PD_IR"
)[
0
]
if
np
.
abs
(
measured_PD
-
pd_value
)
>
0.00005
:
if
measured_PD
>
pd_value
:
return
self
.
Binary_Search
(
pd_value
,
initial_amplitude
,
mid_amplitude
,
current_freq
)
elif
measured_PD
<
pd_value
:
return
self
.
Binary_Search
(
pd_value
,
mid_amplitude
,
final_amplitude
,
current_freq
)
else
:
#print('no se, fijate, paso algo')
return
0
else
:
return
mid_amplitude
@
rpc
(
flags
=
{
"async"
})
def
measure_PD
(
self
,
dump
=
False
):
value
=
rpi
.
ReadPD_average_pi
(
0
,
1
)
print
(
value
)
if
not
dump
:
self
.
mutate_dataset
(
f
"Current_PD_IR"
,
0
,
np
.
abs
(
value
))
@
kernel
def
init_kernel
(
self
):
self
.
core
.
reset
()
delay
(
1
*
ms
)
self
.
core
.
break_realtime
()
#self.laserIR.initialize_channel()
delay
(
100
*
us
)
self
.
laserIR
.
set_channel
()
self
.
core
.
wait_until_mu
(
now_mu
())
delay
(
1
*
ms
)
self
.
laserIR
.
on
()
@
kernel
def
change_frequency
(
self
,
freq
,
amp
):
self
.
core
.
break_realtime
()
delay
(
50
*
ms
)
self
.
laserIR
.
set_frequency
(
freq
,
amp
)
delay
(
50
*
ms
)
def
run
(
self
):
self
.
create_datasets
()
self
.
create_applets
()
self
.
init_kernel
()
i
=
0
self
.
measure_PD
(
dump
=
True
)
initial_amplitude
=
self
.
Min_amplitude
final_amplitude
=
self
.
Max_amplitude
initial_PD
=
self
.
Target_PD_Value
for
freq
in
self
.
Calibration_freqs_IR
.
sequence
:
self
.
change_frequency
(
freq
,
initial_amplitude
)
#self.measure_PD(dump=True)
calibrated_amplitude
=
self
.
Binary_Search
(
initial_PD
,
initial_amplitude
,
final_amplitude
,
freq
)
print
(
f
'Done freq {freq}'
)
self
.
mutate_dataset
(
"Experiment_amps_IR"
,
i
,
calibrated_amplitude
)
#initial_amplitude = calibrated_amplitude-0.1
#final_amplitude = calibrated_amplitude+0.1
i
=
i
+
1
artiq_master/repository/Calibrations/Power Calibration AOM/IR/IR_Power_calibration_BS_rpi_superfine.py
0 → 100644
View file @
a0718351
import
numpy
as
np
from
time
import
sleep
from
artiq.experiment
import
*
from
pyLIAF.artiq.controllers
import
UrukulCh
#from pyLIAF.RedPitaya import Read_analog as rp
from
pyLIAF.RaspberryPi.PD_reader
import
PDreader
as
rpi
from
scipy
import
interpolate
class
IR_LaserPowerCalibration_BS_fine
(
EnvExperiment
):
"""SUPER FINE - Binary search - IR Laser power calibration with photodiode and a raspberry pi """
def
build
(
self
):
self
.
setattr_device
(
"ccb"
)
self
.
setattr_device
(
"scheduler"
)
self
.
setattr_device
(
"core"
)
self
.
laserIR
=
UrukulCh
(
self
,
ch
=
1
,
freq
=
208.0
,
amp
=
0.3
,
name
=
"IR"
)
#corresponde a 0.7 Vpp
self
.
setattr_argument
(
"Target_PD_Value"
,
NumberValue
(
0.4
,
min
=
0.01
,
max
=
3
),
"Calibration_parameters"
)
self
.
setattr_argument
(
"Max_amplitude"
,
NumberValue
(
0.30
,
min
=
0.01
,
max
=
0.35
),
"Calibration_parameters"
)
self
.
setattr_argument
(
"Min_amplitude"
,
NumberValue
(
0.01
,
min
=
0.01
,
max
=
0.35
),
"Calibration_parameters"
)
#self.setattr_argument("tolerance", NumberValue(0.005, max=0.5), "Calibration_parameters")
self
.
setattr_argument
(
"Calibration_freqs_IR"
,
Scannable
(
default
=
CenterScan
(
208
*
MHz
,
10
*
MHz
,
0.1
*
MHz
),
unit
=
"MHz"
,
scale
=
MHz
,
global_min
=
1
*
MHz
,
global_max
=
400
*
MHz
)
)
@
rpc
def
create_datasets
(
self
):
#self.set_dataset("PD_UV_counts", list(np.zeros(len(self.Calibration_freqs.sequence)*len(self.Calibration_amps.sequence), dtype=int)), broadcast=True, archive=True)
self
.
set_dataset
(
"Current_PD_IR"
,
np
.
array
([
0.05
]),
broadcast
=
True
,
archive
=
False
)
self
.
set_dataset
(
"Calibration_freqs"
,
self
.
Calibration_freqs_IR
.
sequence
,
broadcast
=
True
,
archive
=
True
)
self
.
set_dataset
(
"Experiment_freqs_IR_fine"
,
self
.
Calibration_freqs_IR
.
sequence
,
broadcast
=
True
,
archive
=
True
)
self
.
set_dataset
(
"Experiment_amps_IR_fine"
,
np
.
zeros
(
len
(
self
.
Calibration_freqs_IR
.
sequence
),
dtype
=
float
),
broadcast
=
True
,
archive
=
True
)
@
rpc
(
flags
=
{
"async"
})
def
create_applets
(
self
):
self
.
ccb
.
issue
(
"create_applet"
,
"IR_powercalibration_BS_fine"
,
"${python} -m pyLIAF.artiq.applets.plot_xy "
"Experiment_amps_IR_fine "
"--x Calibration_freqs"
)
@
rpc
(
flags
=
{
"async"
})
def
Binary_Search
(
self
,
pd_value
,
initial_amplitude
,
final_amplitude
,
current_freq
):
mid_amplitude
=
round
(
0.5
*
(
initial_amplitude
+
final_amplitude
),
4
)
#print(f'mid_amplitude: {mid_amplitude}')
if
abs
(
initial_amplitude
-
mid_amplitude
)
<
0.00001
or
abs
(
final_amplitude
-
mid_amplitude
)
<
0.00001
:
#print('toco un borde jejox')
return
mid_amplitude
#else:
if
mid_amplitude
>
self
.
Max_amplitude
or
mid_amplitude
<
self
.
Min_amplitude
:
print
(
'Pusiste al reves los limites'
)
raise
self
.
change_frequency
(
current_freq
,
mid_amplitude
)
#self.measure_PD(dump=True)
self
.
measure_PD
()
measured_PD
=
self
.
get_dataset
(
"Current_PD_IR"
)[
0
]
if
np
.
abs
(
measured_PD
-
pd_value
)
>
0.00005
:
if
measured_PD
>
pd_value
:
return
self
.
Binary_Search
(
pd_value
,
initial_amplitude
,
mid_amplitude
,
current_freq
)
elif
measured_PD
<
pd_value
:
return
self
.
Binary_Search
(
pd_value
,
mid_amplitude
,
final_amplitude
,
current_freq
)
else
:
#print('no se, fijate, paso algo')
return
0
else
:
return
mid_amplitude
@
rpc
(
flags
=
{
"async"
})
def
measure_PD
(
self
,
dump
=
False
):
value
=
rpi
.
ReadPD_average_pi
(
0
,
1
)
print
(
value
)
if
not
dump
:
self
.
mutate_dataset
(
f
"Current_PD_IR"
,
0
,
np
.
abs
(
value
))
@
kernel
def
init_kernel
(
self
):
self
.
core
.
reset
()
delay
(
1
*
ms
)
self
.
core
.
break_realtime
()
#self.laserIR.initialize_channel()
delay
(
100
*
us
)
self
.
laserIR
.
set_channel
()
self
.
core
.
wait_until_mu
(
now_mu
())
delay
(
1
*
ms
)
self
.
laserIR
.
on
()
@
kernel
def
change_frequency
(
self
,
freq
,
amp
):
self
.
core
.
break_realtime
()
delay
(
50
*
ms
)
self
.
laserIR
.
set_frequency
(
freq
,
amp
)
delay
(
50
*
ms
)
def
run
(
self
):
self
.
create_datasets
()
self
.
create_applets
()
self
.
init_kernel
()
i
=
0
self
.
measure_PD
(
dump
=
True
)
initial_amplitude
=
self
.
Min_amplitude
final_amplitude
=
self
.
Max_amplitude
initial_PD
=
self
.
Target_PD_Value
for
freq
in
self
.
Calibration_freqs_IR
.
sequence
:
self
.
change_frequency
(
freq
,
initial_amplitude
)
#self.measure_PD(dump=True)
calibrated_amplitude
=
self
.
Binary_Search
(
initial_PD
,
initial_amplitude
,
final_amplitude
,
freq
)
print
(
f
'Done freq {freq}'
)
self
.
mutate_dataset
(
"Experiment_amps_IR_fine"
,
i
,
calibrated_amplitude
)
#initial_amplitude = calibrated_amplitude-0.1
#final_amplitude = calibrated_amplitude+0.1
i
=
i
+
1
artiq_master/repository/Calibrations/Power Calibration AOM/IR/IR_Power_calibration_check.py
0 → 100644
View file @
a0718351
import
numpy
as
np
from
time
import
sleep
from
artiq.experiment
import
*
from
pyLIAF.artiq.controllers
import
UrukulCh
from
pyLIAF.RedPitaya
import
Read_analog
as
rp
from
scipy
import
interpolate
class
LaserPowerCalibration
(
EnvExperiment
):
"""Testing IR Laser power calibration with photodiode and a red pitaya """
def
build
(
self
):
self
.
setattr_device
(
"ccb"
)
self
.
setattr_device
(
"scheduler"
)
self
.
setattr_device
(
"core"
)
self
.
laserIR
=
UrukulCh
(
self
,
ch
=
1
,
freq
=
208.0
,
amp
=
0.35
,
name
=
"IR"
)
#corresponde a 0.7 Vpp
@
rpc
def
create_datasets
(
self
):
self
.
Test_Experiment_freqs
=
self
.
get_dataset
(
"Experiment_freqs_IR"
)
self
.
Test_Experiment_amps
=
self
.
get_dataset
(
"Experiment_amps_IR"
)
self
.
set_dataset
(
"Test_Experiment_freqs"
,
self
.
Test_Experiment_freqs
,
broadcast
=
True
,
archive
=
True
)
self
.
set_dataset
(
"Test_Experiment_amps"
,
self
.
Test_Experiment_amps
,
broadcast
=
True
,
archive
=
True
)
self
.
set_dataset
(
"Test_Measured_PD_IR_counts"
,
list
(
np
.
zeros
(
len
(
self
.
Test_Experiment_freqs
),
dtype
=
int
)),
broadcast
=
True
,
archive
=
True
)
@
rpc
(
flags
=
{
"async"
})
def
create_applets
(
self
):
self
.
ccb
.
issue
(
"create_applet"
,
"verification_powercalibration"
,
"${python} -m pyLIAF.artiq.applets.plot_xy "
"Test_Measured_PD_IR_counts "
"--x Test_Experiment_freqs"
)
"""
@rpc(flags={"async"})
def measure_PD(self, i):
#sleep(1)
value = rp.ReadVoltage()
print(np.abs(value))
self.mutate_dataset("Test_Measured_PD_IR_counts", i, np.abs(value))
"""
@
rpc
(
flags
=
{
"async"
})
def
measure_PD
(
self
,
i
,
dump
=
False
):
if
not
self
.
RPstatus
:
self
.
rp_s
=
rp
.
Initiate_comm
()
self
.
RPstatus
=
True
value
=
rp
.
ReadVoltage
(
self
.
rp_s
)
print
(
value
)
if
not
dump
:
self
.
mutate_dataset
(
f
"Test_Measured_PD_IR_counts"
,
i
,
np
.
abs
(
value
))
@
kernel
def
init_kernel
(
self
):
self
.
core
.
reset
()
self
.
laserIR
.
initialize_channel
()
delay
(
10
*
us
)
self
.
laserIR
.
set_channel
()
self
.
core
.
wait_until_mu
(
now_mu
())
delay
(
1
*
ms
)
self
.
laserIR
.
on
()
@
kernel
def
change_frequency
(
self
,
freq
,
amp
):
self
.
core
.
break_realtime
()
delay
(
50
*
ms
)
self
.
laserIR
.
set_frequency
(
freq
,
amp
)
delay
(
50
*
ms
)
def
run
(
self
):
self
.
create_datasets
()
self
.
create_applets
()
self
.
init_kernel
()
self
.
RPstatus
=
False
self
.
No_freqs
=
len
(
self
.
Test_Experiment_freqs
)
i
=
0
self
.
measure_PD
(
0
,
dump
=
True
)
for
amp
,
freq
in
zip
(
self
.
Test_Experiment_amps
,
self
.
Test_Experiment_freqs
):
print
(
amp
,
freq
)
#self.change_frequency(freq, 0.25)
self
.
change_frequency
(
freq
,
amp
)
self
.
measure_PD
(
0
,
dump
=
True
)
self
.
measure_PD
(
i
)
i
=
i
+
1
artiq_master/repository/Calibrations/Power Calibration AOM/IR/IR_Power_calibration_check_rpi.py
0 → 100644
View file @
a0718351
import
numpy
as
np
from
time
import
sleep
from
artiq.experiment
import
*
from
pyLIAF.artiq.controllers
import
UrukulCh
#from pyLIAF.RedPitaya import Read_analog as rp
from
pyLIAF.RaspberryPi.PD_reader
import
PDreader
as
rpi
from
scipy
import
interpolate
class
LaserPowerCalibration
(
EnvExperiment
):
"""Testing IR Laser power calibration with photodiode and a raspberry pi """
def
build
(
self
):
self
.
setattr_device
(
"ccb"
)
self
.
setattr_device
(
"scheduler"
)
self
.
setattr_device
(
"core"
)
self
.
laserIR
=
UrukulCh
(
self
,
ch
=
1
,
freq
=
208.0
,
amp
=
0.3
,
name
=
"IR"
)
#corresponde a 0.7 Vpp
@
rpc
def
create_datasets
(
self
):
self
.
Test_Experiment_freqs
=
self
.
get_dataset
(
"Experiment_freqs_IR"
)
self
.
Test_Experiment_amps
=
self
.
get_dataset
(
"Experiment_amps_IR"
)
self
.
set_dataset
(
"Test_Experiment_freqs"
,
self
.
Test_Experiment_freqs
,
broadcast
=
True
,
archive
=
True
)
self
.
set_dataset
(
"Test_Experiment_amps"
,
self
.
Test_Experiment_amps
,
broadcast
=
True
,
archive
=
True
)
self
.
set_dataset
(
"Test_Measured_PD_IR_counts"
,
list
(
np
.
zeros
(
len
(
self
.
Test_Experiment_freqs
),
dtype
=
int
)),
broadcast
=
True
,
archive
=
True
)
@
rpc
(
flags
=
{
"async"
})
def
create_applets
(
self
):
self
.
ccb
.
issue
(
"create_applet"
,
"verification_powercalibration"
,
"${python} -m pyLIAF.artiq.applets.plot_xy "
"Test_Measured_PD_IR_counts "
"--x Test_Experiment_freqs"
)
"""
@rpc(flags={"async"})
def measure_PD(self, i):
#sleep(1)
value = rp.ReadVoltage()
print(np.abs(value))
self.mutate_dataset("Test_Measured_PD_IR_counts", i, np.abs(value))
"""
@
rpc
(
flags
=
{
"async"
})
def
measure_PD
(
self
,
i
,
dump
=
False
):
value
=
rpi
.
ReadPD_average_pi
(
0
,
1
)
print
(
value
)
if
not
dump
:
self
.
mutate_dataset
(
f
"Test_Measured_PD_IR_counts"
,
i
,
np
.
abs
(
value
))
@
kernel
def
init_kernel
(
self
):
self
.
core
.
reset
()
#self.laserIR.initialize_channel()
delay
(
1000
*
us
)
self
.
laserIR
.
set_channel
()
self
.
core
.
wait_until_mu
(
now_mu
())
delay
(
1
*
ms
)
self
.
laserIR
.
on
()
@
kernel
def
change_frequency
(
self
,
freq
,
amp
):
self
.
core
.
break_realtime
()
delay
(
50
*
ms
)
self
.
laserIR
.
set_frequency
(
freq
,
amp
)
delay
(
50
*
ms
)
def
run
(
self
):
self
.
create_datasets
()
self
.
create_applets
()
self
.
init_kernel
()
self
.
No_freqs
=
len
(
self
.
Test_Experiment_freqs
)
i
=
0
self
.
measure_PD
(
0
,
dump
=
True
)
for
amp
,
freq
in
zip
(
self
.
Test_Experiment_amps
,
self
.
Test_Experiment_freqs
):
print
(
amp
,
freq
)
#self.change_frequency(freq, 0.25)
self
.
change_frequency
(
freq
,
amp
)
self
.
measure_PD
(
0
,
dump
=
True
)
self
.
measure_PD
(
i
)
i
=
i
+
1
artiq_master/repository/Calibrations/Power Calibration AOM/IR_Calibration_Fitting.py
0 → 100644
View file @
a0718351
import
numpy
as
np
from
time
import
sleep
from
artiq.experiment
import
*
from
pyLIAF.artiq.controllers
import
UrukulCh
from
pyLIAF.RedPitaya
import
Read_analog
as
rp
from
scipy
import
interpolate
class
IR_LaserPowerCalibration_BS
(
EnvExperiment
):
"""Binary search - IR Laser power calibration with photodiode and a red pitaya """
def
build
(
self
):
self
.
setattr_device
(
"ccb"
)
self
.
setattr_device
(
"scheduler"
)
self
.
setattr_device
(
"core"
)
self
.
setattr_argument
(
"Calibration_freqs_IR"
,
Scannable
(
default
=
CenterScan
(
208
*
MHz
,
10
*
MHz
,
0.1
*
MHz
),
unit
=
"MHz"
,
scale
=
MHz
,
global_min
=
1
*
MHz
,
global_max
=
400
*
MHz
)
)
@
rpc
def
create_datasets
(
self
):
#self.set_dataset("PD_UV_counts", list(np.zeros(len(self.Calibration_freqs.sequence)*len(self.Calibration_amps.sequence), dtype=int)), broadcast=True, archive=True)
self
.
set_dataset
(
"Current_PD_IR"
,
np
.
array
([
0.05
]),
broadcast
=
True
,
archive
=
False
)
self
.
set_dataset
(
"Calibration_freqs"
,
self
.
Calibration_freqs_IR
.
sequence
,
broadcast
=
True
,
archive
=
True
)
self
.
set_dataset
(
"Experiment_freqs_IR_final"
,
self
.
Calibration_freqs_IR
.
sequence
,
broadcast
=
True
,
archive
=
True
)
self
.
set_dataset
(
"Experiment_amps_IR_final"
,
np
.
zeros
(
len
(
self
.
Calibration_freqs_IR
.
sequence
),
dtype
=
float
),
broadcast
=
True
,
archive
=
True
)
@
rpc
(
flags
=
{
"async"
})
def
run
(
self
):
Calibrated_Experiment_freqs
=
self
.
get_dataset
(
"Experiment_freqs_IR"
)
Calibrated_Experiment_amps
=
list
(
self
.
get_dataset
(
"Experiment_amps_IR"
))
def
run
(
self
):
self
.
create_datasets
()
self
.
init_kernel
()
artiq_master/repository/Calibrations/Power Calibration AOM/Photodiode_in_time.py
0 → 100644
View file @
a0718351
import
numpy
as
np
from
artiq.experiment
import
*
from
pyLIAF.artiq.controllers
import
UrukulCh
from
pyLIAF.RaspberryPi.PD_reader
import
PDreader
as
rpi
from
time
import
sleep
class
PMTCalibration
(
EnvExperiment
):
"""Plotting photodiode signal in time"""
def
build
(
self
):
self
.
setattr_device
(
"ccb"
)
self
.
setattr_device
(
"scheduler"
)
self
.
setattr_device
(
"core"
)
self
.
laserUV
=
UrukulCh
(
self
,
ch
=
2
,
freq
=
110.0
,
amp
=
0.3
,
name
=
"UV"
)
#corresponde a 0.7 Vpp
self
.
laserIR
=
UrukulCh
(
self
,
ch
=
1
,
freq
=
208.0
,
amp
=
0.35
,
name
=
"IR"
)
#corresponde a 0.8 Vpp
self
.
setattr_argument
(
f
"IR_freq"
,
NumberValue
(
210
*
MHz
,
unit
=
'MHz'
,
scale
=
MHz
,
min
=
1
*
MHz
,
max
=
400
*
MHz
),
"Laser params"
)
self
.
setattr_argument
(
f
"IR_amp"
,
NumberValue
(
0.3
,
min
=
0.01
,
max
=
0.35
),
"Laser params"
)
self
.
setattr_argument
(
f
"UV_freq"
,
NumberValue
(
110
*
MHz
,
unit
=
'MHz'
,
scale
=
MHz
,
min
=
1
*
MHz
,
max
=
400
*
MHz
),
"Laser params"
)
self
.
setattr_argument
(
f
"UV_amp"
,
NumberValue
(
0.3
,
min
=
0.01
,
max
=
0.3
),
"Laser params"
)
@
rpc
def
create_datasets
(
self
):
self
.
set_dataset
(
"Current_PD"
,
np
.
array
([
0.0
]),
broadcast
=
True
,
archive
=
False
)
@
rpc
def
create_applets
(
self
):
self
.
ccb
.
issue
(
"create_applet"
,
"PD_signal"
,
"${python} -m pyLIAF.artiq.applets.realtime "
"40 "
"Current_PD"
)
@
kernel
def
init_kernel
(
self
):
self
.
core
.
reset
()
#self.laserIR.initialize_channel()
#self.laserUV.channel.cpld.init()
#self.laserUV.channel.init()
#self.laserIR.channel.cpld.init()
#self.core.wait_until_mu(now_mu())
#self.laserIR.channel.init()
#self.laserUV.initialize_channel()
delay
(
1000
*
us
)
self
.
laserIR
.
set_channel
()
self
.
laserUV
.
set_channel
()
self
.
core
.
wait_until_mu
(
now_mu
())
delay
(
1
*
ms
)
self
.
laserIR
.
on
()
self
.
laserUV
.
on
()
self
.
laserUV
.
set_frequency
(
self
.
UV_freq
,
self
.
UV_amp
)
self
.
laserIR
.
set_frequency
(
self
.
IR_freq
,
self
.
IR_amp
)
def
run
(
self
):
self
.
create_datasets
()
self
.
create_applets
()
self
.
init_kernel
()
try
:
while
True
:
self
.
measure_PD
()
while
self
.
scheduler
.
check_pause
():
print
(
"PAUSED BLINKING"
)
self
.
core
.
comm
.
close
()
self
.
scheduler
.
pause
()
# TODO: reset freqs/amps
print
(
"RESUMED BLINKING"
)
except
TerminationRequested
:
print
(
"STOPPED BLINKING"
)
return
cuentas
@
rpc
(
flags
=
{
"async"
})
def
measure_PD
(
self
,
dump
=
False
):
value
=
rpi
.
ReadPD_average_pi
(
0
,
1
)
#print(type(value))
if
not
dump
:
self
.
mutate_dataset
(
"Current_PD"
,
0
,
np
.
abs
(
value
))
sleep
(
0.1
)
artiq_master/repository/Calibrations/Power Calibration AOM/Power_calibration_check.py
0 → 100644
View file @
a0718351
import
numpy
as
np
from
time
import
sleep
from
artiq.experiment
import
*
from
pyLIAF.artiq.controllers
import
UrukulCh
from
pyLIAF.RedPitaya
import
Read_analog
as
rp
from
scipy
import
interpolate
class
LaserPowerCalibration
(
EnvExperiment
):
"""Testing UV Laser power calibration with photodiode and a red pitaya """
def
build
(
self
):
self
.
setattr_device
(
"ccb"
)
self
.
setattr_device
(
"scheduler"
)
self
.
setattr_device
(
"core"
)
self
.
laserUV
=
UrukulCh
(
self
,
ch
=
2
,
freq
=
110.0
,
amp
=
0.3
,
name
=
"UV"
)
#corresponde a 0.7 Vpp
@
rpc
def
create_datasets
(
self
):
self
.
Test_Experiment_freqs
=
self
.
get_dataset
(
"Experiment_freqs"
)
self
.
Test_Experiment_amps
=
self
.
get_dataset
(
"Experiment_amps"
)
self
.
set_dataset
(
"Test_Experiment_freqs"
,
self
.
Test_Experiment_freqs
,
broadcast
=
True
,
archive
=
True
)
self
.
set_dataset
(
"Test_Experiment_amps"
,
self
.
Test_Experiment_amps
,
broadcast
=
True
,
archive
=
True
)
self
.
set_dataset
(
"Test_Measured_PD_UV_counts"
,
list
(
np
.
zeros
(
len
(
self
.
Test_Experiment_freqs
),
dtype
=
int
)),
broadcast
=
True
,
archive
=
True
)
@
rpc
(
flags
=
{
"async"
})
def
create_applets
(
self
):
self
.
ccb
.
issue
(
"create_applet"
,
"verification_powercalibration"
,
"${python} -m pyLIAF.artiq.applets.plot_xy "
"Test_Measured_PD_UV_counts "
"--x Test_Experiment_freqs"
)
"""
@rpc(flags={"async"})
def measure_PD(self, i):
#sleep(1)
value = rp.ReadVoltage()
print(np.abs(value))
self.mutate_dataset("Test_Measured_PD_UV_counts", i, np.abs(value))
"""
@
rpc
(
flags
=
{
"async"
})
def
measure_PD
(
self
,
i
,
dump
=
False
):
if
not
self
.
RPstatus
:
self
.
rp_s
=
rp
.
Initiate_comm
()
self
.
RPstatus
=
True
value
=
rp
.
ReadVoltage
(
self
.
rp_s
)
print
(
value
)
if
not
dump
:
self
.
mutate_dataset
(
f
"Test_Measured_PD_UV_counts"
,
i
,
np
.
abs
(
value
))
@
kernel
def
init_kernel
(
self
):
self
.
core
.
reset
()
self
.
laserUV
.
initialize_channel
()
delay
(
10
*
us
)
self
.
laserUV
.
set_channel
()
self
.
core
.
wait_until_mu
(
now_mu
())
delay
(
1
*
ms
)
self
.
laserUV
.
on
()
@
kernel
def
change_frequency
(
self
,
freq
,
amp
):
self
.
core
.
break_realtime
()
delay
(
50
*
ms
)
self
.
laserUV
.
set_frequency
(
freq
,
amp
)
delay
(
50
*
ms
)
def
run
(
self
):
self
.
create_datasets
()
self
.
create_applets
()
self
.
init_kernel
()
self
.
RPstatus
=
False
self
.
No_freqs
=
len
(
self
.
Test_Experiment_freqs
)
i
=
0
self
.
measure_PD
(
0
,
dump
=
True
)
for
amp
,
freq
in
zip
(
self
.
Test_Experiment_amps
,
self
.
Test_Experiment_freqs
):
print
(
amp
,
freq
)
#self.change_frequency(freq, 0.12)
self
.
change_frequency
(
freq
,
amp
)
self
.
measure_PD
(
0
,
dump
=
True
)
self
.
measure_PD
(
i
)
i
=
i
+
1
artiq_master/repository/Calibrations/Power
_calibration
.py
→
artiq_master/repository/Calibrations/Power
Calibration AOM/Power_calibration_inversed
.py
View file @
a0718351
...
@@ -5,8 +5,8 @@ from pyLIAF.artiq.controllers import UrukulCh
...
@@ -5,8 +5,8 @@ from pyLIAF.artiq.controllers import UrukulCh
from
pyLIAF.RedPitaya
import
Read_analog
as
rp
from
pyLIAF.RedPitaya
import
Read_analog
as
rp
from
scipy
import
interpolate
from
scipy
import
interpolate
class
LaserPowerCalibration
(
EnvExperiment
):
class
Inv
LaserPowerCalibration
(
EnvExperiment
):
"""UV Laser power calibration with photodiode and a red pitaya """
"""
INVERSED
UV Laser power calibration with photodiode and a red pitaya """
def
build
(
self
):
def
build
(
self
):
self
.
setattr_device
(
"ccb"
)
self
.
setattr_device
(
"ccb"
)
...
@@ -17,7 +17,7 @@ class LaserPowerCalibration(EnvExperiment):
...
@@ -17,7 +17,7 @@ class LaserPowerCalibration(EnvExperiment):
self
.
setattr_argument
(
"Do_calibration"
,
BooleanValue
(
False
),
"Calibration_parameters"
)
self
.
setattr_argument
(
"Do_calibration"
,
BooleanValue
(
False
),
"Calibration_parameters"
)
self
.
setattr_argument
(
"Calibration_PD_Value"
,
NumberValue
(
0.2
,
min
=
0.01
,
max
=
0.5
),
"Calibration_parameters"
)
self
.
setattr_argument
(
"Calibration_PD_Value"
,
NumberValue
(
0.2
,
min
=
0.01
,
max
=
0.5
,
ndecimals
=
5
),
"Calibration_parameters"
)
self
.
setattr_argument
(
"Calibration_freqs"
,
Scannable
(
self
.
setattr_argument
(
"Calibration_freqs"
,
Scannable
(
...
@@ -37,14 +37,14 @@ class LaserPowerCalibration(EnvExperiment):
...
@@ -37,14 +37,14 @@ class LaserPowerCalibration(EnvExperiment):
)
)
self
.
setattr_argument
(
"Experiment_frequencies"
,
Scannable
(
#
self.setattr_argument("Experiment_frequencies", Scannable(
default
=
CenterScan
(
110
*
MHz
,
10
*
MHz
,
0.1
*
MHz
),
#
default=CenterScan(110*MHz, 10*MHz, 0.1*MHz),
unit
=
"MHz"
,
#
unit="MHz",
scale
=
MHz
,
#
scale=MHz,
global_min
=
1
*
MHz
,
#
global_min = 1*MHz,
global_max
=
400
*
MHz
#
global_max = 400*MHz
)
#
)
)
#
)
@
rpc
@
rpc
...
@@ -55,8 +55,8 @@ class LaserPowerCalibration(EnvExperiment):
...
@@ -55,8 +55,8 @@ class LaserPowerCalibration(EnvExperiment):
self
.
set_dataset
(
"Calibration_amps"
,
self
.
Calibration_amps
.
sequence
,
broadcast
=
True
,
archive
=
True
)
self
.
set_dataset
(
"Calibration_amps"
,
self
.
Calibration_amps
.
sequence
,
broadcast
=
True
,
archive
=
True
)
self
.
set_dataset
(
"Experiment_freqs"
,
self
.
Experiment_frequencie
s
.
sequence
,
broadcast
=
True
,
archive
=
True
)
self
.
set_dataset
(
"Experiment_freqs"
,
self
.
Calibration_freq
s
.
sequence
,
broadcast
=
True
,
archive
=
True
)
self
.
set_dataset
(
"Experiment_amps"
,
np
.
zeros
(
len
(
self
.
Experiment_frequencie
s
.
sequence
),
dtype
=
float
),
broadcast
=
True
,
archive
=
True
)
self
.
set_dataset
(
"Experiment_amps"
,
np
.
zeros
(
len
(
self
.
Calibration_freq
s
.
sequence
),
dtype
=
float
),
broadcast
=
True
,
archive
=
True
)
@
rpc
(
flags
=
{
"async"
})
@
rpc
(
flags
=
{
"async"
})
...
@@ -104,7 +104,7 @@ class LaserPowerCalibration(EnvExperiment):
...
@@ -104,7 +104,7 @@ class LaserPowerCalibration(EnvExperiment):
for
i
in
range
(
len
(
PD_T
)):
for
i
in
range
(
len
(
PD_T
)):
#PD_values = np.array(PD_T[i][0])[0]
#PD_values = np.array(PD_T[i][0])[0]
PD_values
=
np
.
array
(
PD_T
[
i
])[
0
]
PD_values
=
np
.
array
(
PD_T
[
i
])[
0
]
f
=
interpolate
.
interp1d
(
PD_values
,
amps
,
kind
=
'
quadratic
'
)
f
=
interpolate
.
interp1d
(
PD_values
,
amps
,
kind
=
'
linear
'
)
Interpolation_functions
.
append
(
f
)
Interpolation_functions
.
append
(
f
)
...
@@ -121,17 +121,54 @@ class LaserPowerCalibration(EnvExperiment):
...
@@ -121,17 +121,54 @@ class LaserPowerCalibration(EnvExperiment):
#Freqs_withoutZeros, Calibs_withoutZeros = RemoveZeros(Calibs, freqs)
#Freqs_withoutZeros, Calibs_withoutZeros = RemoveZeros(Calibs, freqs)
Function_Calibs_vs_freq
=
interpolate
.
interp1d
(
self
.
Calibration_freqs
.
sequence
,
Calibrated_Amplitudes
,
kind
=
'
quadratic
'
)
Function_Calibs_vs_freq
=
interpolate
.
interp1d
(
self
.
Calibration_freqs
.
sequence
,
Calibrated_Amplitudes
,
kind
=
'
linear
'
)
i
=
0
i
=
0
for
freq
in
self
.
Experiment_frequencie
s
.
sequence
:
for
freq
in
self
.
Calibration_freq
s
.
sequence
:
calibamp
=
Function_Calibs_vs_freq
(
freq
)
calibamp
=
Function_Calibs_vs_freq
(
freq
)
print
(
calibamp
)
print
(
calibamp
)
self
.
mutate_dataset
(
"Experiment_amps"
,
i
,
calibamp
)
self
.
mutate_dataset
(
"Experiment_amps"
,
i
,
calibamp
)
i
=
i
+
1
i
=
i
+
1
print
(
'okarda con la calibreta'
)
print
(
'okarda con la calibreta'
)
@
rpc
(
flags
=
{
"async"
})
def
Calibrate_amplitudes_v2
(
self
):
Interpolation_functions
=
[]
PD_UV_counts
=
self
.
get_dataset
(
"PD_UV_counts"
)
n
=
len
(
self
.
Calibration_freqs
.
sequence
)
PD_split
=
np
.
matrix
([
PD_UV_counts
[
i
*
n
:(
i
+
1
)
*
n
]
for
i
in
range
((
len
(
PD_UV_counts
)
+
n
-
1
)
//
n
)])
PD_T
=
PD_split
#PD_T = PD_split
amps
=
self
.
Calibration_amps
.
sequence
Calibration_PD_Value
=
self
.
Calibration_PD_Value
Calibrated_Amplitudes
=
[]
for
i
in
range
(
len
(
PD_T
)):
PD_values
=
np
.
array
(
PD_T
[
i
])[
0
]
print
(
len
(
PD_values
))
print
(
len
(
amps
))
j
=
0
while
j
<
len
(
PD_values
):
if
PD_values
[
j
]
<
Calibration_PD_Value
:
j
=
j
+
1
elif
PD_values
[
j
]
>
Calibration_PD_Value
:
Calibrated_Amplitudes
.
append
(
amps
[
j
])
break
else
:
Calibrated_Amplitudes
.
append
(
0
)
print
(
'malardo'
)
break
i
=
0
for
i
in
range
(
len
(
Calibrated_Amplitudes
)):
self
.
mutate_dataset
(
"Experiment_amps"
,
i
,
Calibrated_Amplitudes
[
i
])
i
=
i
+
1
print
(
'okarda con la calibreta'
)
@
rpc
(
flags
=
{
"async"
})
@
rpc
(
flags
=
{
"async"
})
def
measure_PD
(
self
,
i
):
def
measure_PD
(
self
,
i
):
...
@@ -180,16 +217,16 @@ class LaserPowerCalibration(EnvExperiment):
...
@@ -180,16 +217,16 @@ class LaserPowerCalibration(EnvExperiment):
if
self
.
Do_calibration
:
if
self
.
Do_calibration
:
print
(
'Usaremos mediciones nuevas'
)
print
(
'Usaremos mediciones nuevas'
)
for
amp
in
self
.
Calibration_amp
s
.
sequence
:
for
freq
in
self
.
Calibration_freq
s
.
sequence
:
print
(
amp
)
print
(
freq
)
for
freq
in
self
.
Calibration_freq
s
.
sequence
:
for
amp
in
self
.
Calibration_amp
s
.
sequence
:
self
.
change_frequency
(
freq
,
amp
)
self
.
change_frequency
(
freq
,
amp
)
self
.
measure_PD
(
i
)
self
.
measure_PD
(
i
)
i
=
i
+
1
i
=
i
+
1
self
.
Calibrate_amplitudes
()
self
.
Calibrate_amplitudes
()
else
:
else
:
print
(
'Usando mediciones ya hechas'
)
print
(
'Usando mediciones ya hechas'
)
self
.
Calibrate_amplitudes
()
self
.
Calibrate_amplitudes
_v2
()
...
...
artiq_master/repository/Calibrations/Power Calibration AOM/Power_calibration_v2.py
0 → 100644
View file @
a0718351
import
numpy
as
np
from
time
import
sleep
from
artiq.experiment
import
*
from
pyLIAF.artiq.controllers
import
UrukulCh
from
pyLIAF.RedPitaya
import
Read_analog
as
rp
from
scipy
import
interpolate
class
LaserPowerCalibration_v2
(
EnvExperiment
):
"""V2 - Binary search - UV Laser power calibration with photodiode and a red pitaya """
def
build
(
self
):
self
.
setattr_device
(
"ccb"
)
self
.
setattr_device
(
"scheduler"
)
self
.
setattr_device
(
"core"
)
self
.
laserUV
=
UrukulCh
(
self
,
ch
=
2
,
freq
=
110.0
,
amp
=
0.3
,
name
=
"UV"
)
#corresponde a 0.7 Vpp
self
.
setattr_argument
(
"Target_PD_Value"
,
NumberValue
(
0.2
,
min
=
0.01
,
max
=
0.5
),
"Calibration_parameters"
)
self
.
setattr_argument
(
"Max_amplitude"
,
NumberValue
(
0.25
,
min
=
0.01
,
max
=
0.5
),
"Calibration_parameters"
)
self
.
setattr_argument
(
"Min_amplitude"
,
NumberValue
(
0.01
,
min
=
0.01
,
max
=
0.5
),
"Calibration_parameters"
)
self
.
setattr_argument
(
"tolerance"
,
NumberValue
(
0.005
,
max
=
0.5
),
"Calibration_parameters"
)
self
.
setattr_argument
(
"Calibration_freqs"
,
Scannable
(
default
=
CenterScan
(
110
*
MHz
,
10
*
MHz
,
0.1
*
MHz
),
unit
=
"MHz"
,
scale
=
MHz
,
global_min
=
1
*
MHz
,
global_max
=
400
*
MHz
)
)
@
rpc
def
create_datasets
(
self
):
#self.set_dataset("PD_UV_counts", list(np.zeros(len(self.Calibration_freqs.sequence)*len(self.Calibration_amps.sequence), dtype=int)), broadcast=True, archive=True)
self
.
set_dataset
(
"Current_PD_UV"
,
np
.
array
([
0.05
]),
broadcast
=
True
,
archive
=
False
)
self
.
set_dataset
(
"Calibration_freqs"
,
self
.
Calibration_freqs
.
sequence
,
broadcast
=
True
,
archive
=
True
)
self
.
set_dataset
(
"Experiment_freqs"
,
self
.
Calibration_freqs
.
sequence
,
broadcast
=
True
,
archive
=
True
)
self
.
set_dataset
(
"Experiment_amps"
,
np
.
zeros
(
len
(
self
.
Calibration_freqs
.
sequence
),
dtype
=
float
),
broadcast
=
True
,
archive
=
True
)
@
rpc
(
flags
=
{
"async"
})
def
create_applets
(
self
):
self
.
ccb
.
issue
(
"create_applet"
,
"v2_powercalibration"
,
"${python} -m pyLIAF.artiq.applets.plot_xy "
"Experiment_amps "
"--x Calibration_freqs"
)
@
rpc
(
flags
=
{
"async"
})
def
Binary_Search
(
self
,
pd_value
,
initial_amplitude
,
final_amplitude
,
current_freq
):
mid_amplitude
=
round
(
0.5
*
(
initial_amplitude
+
final_amplitude
),
4
)
print
(
f
'mid_amplitude: {mid_amplitude}'
)
if
abs
(
initial_amplitude
-
mid_amplitude
)
<
0.00001
or
abs
(
final_amplitude
-
mid_amplitude
)
<
0.00001
:
print
(
'toco un borde jejox'
)
return
mid_amplitude
#else:
if
mid_amplitude
>
self
.
Max_amplitude
or
mid_amplitude
<
self
.
Min_amplitude
:
raise
self
.
change_frequency
(
current_freq
,
mid_amplitude
)
self
.
measure_PD
()
measured_PD
=
self
.
get_dataset
(
"Current_PD_UV"
)[
0
]
if
np
.
abs
(
measured_PD
-
pd_value
)
>
0.0005
:
if
measured_PD
>
pd_value
:
return
self
.
Binary_Search
(
pd_value
,
initial_amplitude
,
mid_amplitude
,
current_freq
)
elif
measured_PD
<
pd_value
:
return
self
.
Binary_Search
(
pd_value
,
mid_amplitude
,
final_amplitude
,
current_freq
)
else
:
print
(
'no se, fijate, paso algo'
)
return
0
else
:
return
mid_amplitude
@
rpc
(
flags
=
{
"async"
})
def
measure_PD
(
self
):
value
=
rp
.
ReadVoltage
()
print
(
np
.
abs
(
value
))
self
.
mutate_dataset
(
f
"Current_PD_UV"
,
0
,
np
.
abs
(
value
))
@
kernel
def
init_kernel
(
self
):
self
.
core
.
reset
()
delay
(
1
*
ms
)
self
.
core
.
break_realtime
()
self
.
laserUV
.
initialize_channel
()
delay
(
100
*
us
)
self
.
laserUV
.
set_channel
()
self
.
core
.
wait_until_mu
(
now_mu
())
delay
(
1
*
ms
)
self
.
laserUV
.
on
()
@
kernel
def
change_frequency
(
self
,
freq
,
amp
):
self
.
core
.
break_realtime
()
delay
(
50
*
ms
)
self
.
laserUV
.
set_frequency
(
freq
,
amp
)
delay
(
10
*
ms
)
def
run
(
self
):
self
.
create_datasets
()
self
.
create_applets
()
self
.
init_kernel
()
i
=
0
initial_amplitude
=
self
.
Min_amplitude
final_amplitude
=
self
.
Max_amplitude
initial_PD
=
self
.
Target_PD_Value
for
freq
in
self
.
Calibration_freqs
.
sequence
:
self
.
change_frequency
(
freq
,
initial_amplitude
)
calibrated_amplitude
=
self
.
Binary_Search
(
initial_PD
,
initial_amplitude
,
final_amplitude
,
freq
)
print
(
f
'Done freq {freq}'
)
self
.
mutate_dataset
(
"Experiment_amps"
,
i
,
calibrated_amplitude
)
#initial_amplitude = calibrated_amplitude-0.1
#final_amplitude = calibrated_amplitude+0.1
i
=
i
+
1
artiq_master/repository/Calibrations/Power Calibration AOM/UV/UV_Power_calibration.py
0 → 100644
View file @
a0718351
import
numpy
as
np
from
time
import
sleep
from
artiq.experiment
import
*
from
pyLIAF.artiq.controllers
import
UrukulCh
from
pyLIAF.RedPitaya
import
Read_analog
as
rp
from
scipy
import
interpolate
class
LaserPowerCalibration
(
EnvExperiment
):
"""UV Laser power calibration with photodiode and a red pitaya """
def
build
(
self
):
self
.
setattr_device
(
"ccb"
)
self
.
setattr_device
(
"scheduler"
)
self
.
setattr_device
(
"core"
)
self
.
laserUV
=
UrukulCh
(
self
,
ch
=
2
,
freq
=
110.0
,
amp
=
0.3
,
name
=
"UV"
)
#corresponde a 0.7 Vpp
self
.
setattr_argument
(
"Do_calibration"
,
BooleanValue
(
False
),
"Calibration_parameters"
)
self
.
setattr_argument
(
"Calibration_PD_Value"
,
NumberValue
(
0.2
,
min
=
0.01
,
max
=
0.5
,
ndecimals
=
5
),
"Calibration_parameters"
)
self
.
setattr_argument
(
"Calibration_freqs"
,
Scannable
(
default
=
CenterScan
(
110
*
MHz
,
10
*
MHz
,
0.1
*
MHz
),
unit
=
"MHz"
,
scale
=
MHz
,
global_min
=
1
*
MHz
,
global_max
=
400
*
MHz
)
)
self
.
setattr_argument
(
"Calibration_amps"
,
Scannable
(
default
=
CenterScan
(
0.2
,
0.1
,
0.01
),
global_min
=
0
,
global_max
=
0.3
)
)
# self.setattr_argument("Experiment_frequencies", Scannable(
# default=CenterScan(110*MHz, 10*MHz, 0.1*MHz),
# unit="MHz",
# scale=MHz,
# global_min = 1*MHz,
# global_max = 400*MHz
# )
# )
@
rpc
def
create_datasets
(
self
):
if
self
.
Do_calibration
:
self
.
set_dataset
(
"PD_UV_counts"
,
list
(
np
.
zeros
(
len
(
self
.
Calibration_freqs
.
sequence
)
*
len
(
self
.
Calibration_amps
.
sequence
),
dtype
=
int
)),
broadcast
=
True
,
archive
=
True
)
self
.
set_dataset
(
"Calibration_freqs_UV"
,
len
(
self
.
Calibration_amps
.
sequence
)
*
self
.
Calibration_freqs
.
sequence
,
broadcast
=
True
,
archive
=
True
)
self
.
set_dataset
(
"Calibration_amps_UV"
,
self
.
Calibration_amps
.
sequence
,
broadcast
=
True
,
archive
=
True
)
self
.
set_dataset
(
"Experiment_freqs"
,
self
.
Calibration_freqs
.
sequence
,
broadcast
=
True
,
archive
=
True
)
self
.
set_dataset
(
"Experiment_amps"
,
np
.
zeros
(
len
(
self
.
Calibration_freqs
.
sequence
),
dtype
=
float
),
broadcast
=
True
,
archive
=
True
)
@
rpc
(
flags
=
{
"async"
})
def
create_applets
(
self
):
self
.
ccb
.
issue
(
"create_applet"
,
"powercalibration"
,
"${python} -m pyLIAF.artiq.applets.plot_xy "
"PD_UV_counts "
"--x Calibration_freqs"
)
@
rpc
(
flags
=
{
"async"
})
def
RemoveZeros
(
calib
,
freqs
):
i
,
j
=
0
,
1
new_calib
=
calib
while
i
<
len
(
calib
):
if
new_calib
[
0
]
==
0
:
new_calib
=
new_calib
[
1
:]
i
=
i
+
1
else
:
init_len
=
len
(
new_calib
)
final_calib
=
new_calib
while
j
<
init_len
:
if
final_calib
[
-
1
]
==
0
:
final_calib
=
final_calib
[:
-
1
]
j
=
j
+
1
else
:
if
j
==
1
:
return
freqs
[
i
:],
final_calib
else
:
return
freqs
[
i
:
-
j
+
1
],
final_calib
@
rpc
(
flags
=
{
"async"
})
def
Calibrate_amplitudes
(
self
):
Interpolation_functions
=
[]
PD_UV_counts
=
self
.
get_dataset
(
"PD_UV_counts"
)
n
=
len
(
self
.
Calibration_freqs
.
sequence
)
PD_split
=
np
.
matrix
([
PD_UV_counts
[
i
*
n
:(
i
+
1
)
*
n
]
for
i
in
range
((
len
(
PD_UV_counts
)
+
n
-
1
)
//
n
)])
PD_T
=
np
.
transpose
(
PD_split
)
amps
=
self
.
Calibration_amps
.
sequence
for
i
in
range
(
len
(
PD_T
)):
#PD_values = np.array(PD_T[i][0])[0]
PD_values
=
np
.
array
(
PD_T
[
i
])[
0
]
f
=
interpolate
.
interp1d
(
PD_values
,
amps
,
kind
=
'linear'
)
Interpolation_functions
.
append
(
f
)
Calibration_PD_Value
=
self
.
Calibration_PD_Value
Calibrated_Amplitudes
=
[]
for
fi
in
Interpolation_functions
:
try
:
Calibrated_Amplitudes
.
append
(
float
(
fi
(
Calibration_PD_Value
)))
except
:
Calibrated_Amplitudes
.
append
(
0
)
print
(
'no, rey'
)
#Freqs_withoutZeros, Calibs_withoutZeros = RemoveZeros(Calibs, freqs)
Function_Calibs_vs_freq
=
interpolate
.
interp1d
(
self
.
Calibration_freqs
.
sequence
,
Calibrated_Amplitudes
,
kind
=
'linear'
)
i
=
0
for
freq
in
self
.
Calibration_freqs
.
sequence
:
calibamp
=
Function_Calibs_vs_freq
(
freq
)
print
(
calibamp
)
self
.
mutate_dataset
(
"Experiment_amps"
,
i
,
calibamp
)
i
=
i
+
1
print
(
'okarda con la calibreta'
)
@
rpc
(
flags
=
{
"async"
})
def
Calibrate_amplitudes_v2
(
self
):
Interpolation_functions
=
[]
PD_UV_counts
=
self
.
get_dataset
(
"PD_UV_counts"
)
n
=
len
(
self
.
Calibration_freqs
.
sequence
)
PD_split
=
np
.
matrix
([
PD_UV_counts
[
i
*
n
:(
i
+
1
)
*
n
]
for
i
in
range
((
len
(
PD_UV_counts
)
+
n
-
1
)
//
n
)])
PD_T
=
np
.
transpose
(
PD_split
)
#PD_T = PD_split
amps
=
self
.
Calibration_amps
.
sequence
Calibration_PD_Value
=
self
.
Calibration_PD_Value
Calibrated_Amplitudes
=
[]
for
i
in
range
(
len
(
PD_T
)):
PD_values
=
np
.
array
(
PD_T
[
i
])[
0
]
print
(
len
(
PD_values
))
print
(
len
(
amps
))
j
=
0
while
j
<
len
(
PD_values
):
if
PD_values
[
j
]
<
Calibration_PD_Value
:
j
=
j
+
1
elif
PD_values
[
j
]
>
Calibration_PD_Value
:
Calibrated_Amplitudes
.
append
(
amps
[
j
])
break
else
:
Calibrated_Amplitudes
.
append
(
0
)
print
(
'malardo'
)
break
i
=
0
for
i
in
range
(
len
(
Calibrated_Amplitudes
)):
self
.
mutate_dataset
(
"Experiment_amps"
,
i
,
Calibrated_Amplitudes
[
i
])
i
=
i
+
1
print
(
'okarda con la calibreta'
)
@
rpc
(
flags
=
{
"async"
})
def
measure_PD
(
self
,
i
,
dump
=
False
):
if
not
self
.
RPstatus
:
self
.
rp_s
=
rp
.
Initiate_comm
()
self
.
RPstatus
=
True
value
=
rp
.
ReadVoltage
(
self
.
rp_s
)
print
(
value
)
if
not
dump
:
self
.
mutate_dataset
(
f
"PD_UV_counts"
,
i
,
np
.
abs
(
value
))
@
kernel
def
init_kernel
(
self
):
self
.
core
.
reset
()
self
.
laserUV
.
initialize_channel
()
delay
(
10
*
us
)
self
.
laserUV
.
set_channel
()
self
.
core
.
wait_until_mu
(
now_mu
())
delay
(
1
*
ms
)
self
.
laserUV
.
on
()
@
kernel
def
change_frequency
(
self
,
freq
,
amp
):
self
.
core
.
break_realtime
()
delay
(
50
*
ms
)
self
.
laserUV
.
set_frequency
(
freq
,
amp
)
delay
(
50
*
ms
)
#def GetTargetAmplitude(self, amplitudes, PD_values, i):
#f = interpolate.interp1d(amplitudes, PD_values)
#amplitudes_interpoladas = np.arange()
def
run
(
self
):
self
.
create_datasets
()
self
.
create_applets
()
self
.
init_kernel
()
self
.
RPstatus
=
False
self
.
No_freqs
=
len
(
self
.
Calibration_freqs
.
sequence
)
i
=
0
self
.
measure_PD
(
0
,
dump
=
True
)
if
self
.
Do_calibration
:
print
(
'Usaremos mediciones nuevas'
)
for
amp
in
self
.
Calibration_amps
.
sequence
:
print
(
amp
)
for
freq
in
self
.
Calibration_freqs
.
sequence
:
self
.
change_frequency
(
freq
,
amp
)
self
.
measure_PD
(
0
,
dump
=
True
)
self
.
measure_PD
(
i
)
i
=
i
+
1
self
.
Calibrate_amplitudes
()
else
:
print
(
'Usando mediciones ya hechas'
)
self
.
Calibrate_amplitudes_v2
()
artiq_master/repository/Calibrations/Power Calibration AOM/UV/UV_Power_calibration_BS.py
0 → 100644
View file @
a0718351
import
numpy
as
np
from
time
import
sleep
from
artiq.experiment
import
*
from
pyLIAF.artiq.controllers
import
UrukulCh
from
pyLIAF.RedPitaya
import
Read_analog
as
rp
from
scipy
import
interpolate
class
UV_LaserPowerCalibration_BS
(
EnvExperiment
):
"""Binary search - UV Laser power calibration with photodiode and a red pitaya """
def
build
(
self
):
self
.
setattr_device
(
"ccb"
)
self
.
setattr_device
(
"scheduler"
)
self
.
setattr_device
(
"core"
)
self
.
laserUV
=
UrukulCh
(
self
,
ch
=
2
,
freq
=
110.0
,
amp
=
0.3
,
name
=
"UV"
)
#corresponde a 0.7 Vpp
self
.
setattr_argument
(
"Target_PD_Value"
,
NumberValue
(
0.4
,
min
=
0.01
,
max
=
0.5
),
"Calibration_parameters"
)
self
.
setattr_argument
(
"Max_amplitude"
,
NumberValue
(
0.30
,
min
=
0.01
,
max
=
0.3
),
"Calibration_parameters"
)
self
.
setattr_argument
(
"Min_amplitude"
,
NumberValue
(
0.01
,
min
=
0.01
,
max
=
0.3
),
"Calibration_parameters"
)
#self.setattr_argument("tolerance", NumberValue(0.005, max=0.5), "Calibration_parameters")
self
.
setattr_argument
(
"Calibration_freqs_UV"
,
Scannable
(
default
=
CenterScan
(
110
*
MHz
,
10
*
MHz
,
0.1
*
MHz
),
unit
=
"MHz"
,
scale
=
MHz
,
global_min
=
1
*
MHz
,
global_max
=
400
*
MHz
)
)
@
rpc
def
create_datasets
(
self
):
#self.set_dataset("PD_UV_counts", list(np.zeros(len(self.Calibration_freqs.sequence)*len(self.Calibration_amps.sequence), dtype=int)), broadcast=True, archive=True)
self
.
set_dataset
(
"Current_PD_UV"
,
np
.
array
([
0.05
]),
broadcast
=
True
,
archive
=
False
)
self
.
set_dataset
(
"Calibration_freqs"
,
self
.
Calibration_freqs_UV
.
sequence
,
broadcast
=
True
,
archive
=
True
)
self
.
set_dataset
(
"Experiment_freqs_UV"
,
self
.
Calibration_freqs_UV
.
sequence
,
broadcast
=
True
,
archive
=
True
)
self
.
set_dataset
(
"Experiment_amps_UV"
,
np
.
zeros
(
len
(
self
.
Calibration_freqs_UV
.
sequence
),
dtype
=
float
),
broadcast
=
True
,
archive
=
True
)
@
rpc
(
flags
=
{
"async"
})
def
create_applets
(
self
):
self
.
ccb
.
issue
(
"create_applet"
,
"UV_powercalibration_BS"
,
"${python} -m pyLIAF.artiq.applets.plot_xy "
"Experiment_amps_UV "
"--x Calibration_freqs"
)
@
rpc
(
flags
=
{
"async"
})
def
Binary_Search
(
self
,
pd_value
,
initial_amplitude
,
final_amplitude
,
current_freq
):
mid_amplitude
=
round
(
0.5
*
(
initial_amplitude
+
final_amplitude
),
4
)
print
(
f
'mid_amplitude: {mid_amplitude}'
)
if
abs
(
initial_amplitude
-
mid_amplitude
)
<
0.00001
or
abs
(
final_amplitude
-
mid_amplitude
)
<
0.00001
:
print
(
'toco un borde jejox'
)
return
mid_amplitude
#else:
if
mid_amplitude
>
self
.
Max_amplitude
or
mid_amplitude
<
self
.
Min_amplitude
:
raise
self
.
change_frequency
(
current_freq
,
mid_amplitude
)
self
.
measure_PD
(
dump
=
True
)
self
.
measure_PD
()
measured_PD
=
self
.
get_dataset
(
"Current_PD_UV"
)[
0
]
if
np
.
abs
(
measured_PD
-
pd_value
)
>
0.00005
:
if
measured_PD
>
pd_value
:
return
self
.
Binary_Search
(
pd_value
,
initial_amplitude
,
mid_amplitude
,
current_freq
)
elif
measured_PD
<
pd_value
:
return
self
.
Binary_Search
(
pd_value
,
mid_amplitude
,
final_amplitude
,
current_freq
)
else
:
print
(
'no se, fijate, paso algo'
)
return
0
else
:
return
mid_amplitude
@
rpc
(
flags
=
{
"async"
})
def
measure_PD
(
self
,
dump
=
False
):
if
not
self
.
RPstatus
:
self
.
rp_s
=
rp
.
Initiate_comm
()
self
.
RPstatus
=
True
value
=
rp
.
ReadVoltage
(
self
.
rp_s
)
print
(
value
)
if
not
dump
:
self
.
mutate_dataset
(
f
"Current_PD_UV"
,
0
,
np
.
abs
(
value
))
@
kernel
def
init_kernel
(
self
):
self
.
core
.
reset
()
delay
(
1
*
ms
)
self
.
core
.
break_realtime
()
self
.
laserUV
.
initialize_channel
()
delay
(
100
*
us
)
self
.
laserUV
.
set_channel
()
self
.
core
.
wait_until_mu
(
now_mu
())
delay
(
1
*
ms
)
self
.
laserUV
.
on
()
@
kernel
def
change_frequency
(
self
,
freq
,
amp
):
self
.
core
.
break_realtime
()
delay
(
50
*
ms
)
self
.
laserUV
.
set_frequency
(
freq
,
amp
)
delay
(
50
*
ms
)
def
run
(
self
):
self
.
create_datasets
()
self
.
create_applets
()
self
.
init_kernel
()
self
.
RPstatus
=
False
i
=
0
self
.
measure_PD
(
dump
=
True
)
initial_amplitude
=
self
.
Min_amplitude
final_amplitude
=
self
.
Max_amplitude
initial_PD
=
self
.
Target_PD_Value
for
freq
in
self
.
Calibration_freqs_UV
.
sequence
:
self
.
change_frequency
(
freq
,
initial_amplitude
)
self
.
measure_PD
(
dump
=
True
)
calibrated_amplitude
=
self
.
Binary_Search
(
initial_PD
,
initial_amplitude
,
final_amplitude
,
freq
)
print
(
f
'Done freq {freq}'
)
self
.
mutate_dataset
(
"Experiment_amps_UV"
,
i
,
calibrated_amplitude
)
#initial_amplitude = calibrated_amplitude-0.1
#final_amplitude = calibrated_amplitude+0.1
i
=
i
+
1
artiq_master/repository/Calibrations/Power Calibration AOM/UV/UV_Power_calibration_BS_rpi.py
0 → 100644
View file @
a0718351
import
numpy
as
np
from
time
import
sleep
from
artiq.experiment
import
*
from
pyLIAF.artiq.controllers
import
UrukulCh
#from pyLIAF.RedPitaya import Read_analog as rp
from
pyLIAF.RaspberryPi.PD_reader
import
PDreader
as
rpi
from
scipy
import
interpolate
class
UV_LaserPowerCalibration_BS_rpi
(
EnvExperiment
):
"""Binary search - UV Laser power calibration with photodiode and a raspberry pi """
def
build
(
self
):
self
.
setattr_device
(
"ccb"
)
self
.
setattr_device
(
"scheduler"
)
self
.
setattr_device
(
"core"
)
self
.
laserUV
=
UrukulCh
(
self
,
ch
=
2
,
freq
=
110.0
,
amp
=
0.25
,
name
=
"UV"
)
#corresponde a 0.7 Vpp
self
.
setattr_argument
(
"Target_PD_Value"
,
NumberValue
(
0.4
,
min
=
0.001
,
max
=
0.5
),
"Calibration_parameters"
)
self
.
setattr_argument
(
"Max_amplitude"
,
NumberValue
(
0.30
,
min
=
0.01
,
max
=
0.3
),
"Calibration_parameters"
)
self
.
setattr_argument
(
"Min_amplitude"
,
NumberValue
(
0.01
,
min
=
0.01
,
max
=
0.3
),
"Calibration_parameters"
)
#self.setattr_argument("tolerance", NumberValue(0.005, max=0.5), "Calibration_parameters")
self
.
setattr_argument
(
"Calibration_freqs_UV"
,
Scannable
(
default
=
CenterScan
(
110
*
MHz
,
10
*
MHz
,
0.1
*
MHz
),
unit
=
"MHz"
,
scale
=
MHz
,
global_min
=
1
*
MHz
,
global_max
=
400
*
MHz
)
)
@
rpc
def
create_datasets
(
self
):
#self.set_dataset("PD_UV_counts", list(np.zeros(len(self.Calibration_freqs.sequence)*len(self.Calibration_amps.sequence), dtype=int)), broadcast=True, archive=True)
self
.
set_dataset
(
"Current_PD_UV"
,
np
.
array
([
0.05
]),
broadcast
=
True
,
archive
=
False
)
self
.
set_dataset
(
"Calibration_freqs"
,
self
.
Calibration_freqs_UV
.
sequence
,
broadcast
=
True
,
archive
=
True
)
self
.
set_dataset
(
"Experiment_freqs_UV"
,
self
.
Calibration_freqs_UV
.
sequence
,
broadcast
=
True
,
archive
=
True
)
self
.
set_dataset
(
"Experiment_amps_UV"
,
np
.
zeros
(
len
(
self
.
Calibration_freqs_UV
.
sequence
),
dtype
=
float
),
broadcast
=
True
,
archive
=
True
)
@
rpc
(
flags
=
{
"async"
})
def
create_applets
(
self
):
self
.
ccb
.
issue
(
"create_applet"
,
"UV_powercalibration_BS"
,
"${python} -m pyLIAF.artiq.applets.plot_xy "
"Experiment_amps_UV "
"--x Calibration_freqs"
)
@
rpc
(
flags
=
{
"async"
})
def
Binary_Search
(
self
,
pd_value
,
initial_amplitude
,
final_amplitude
,
current_freq
):
mid_amplitude
=
round
(
0.5
*
(
initial_amplitude
+
final_amplitude
),
4
)
print
(
f
'mid_amplitude: {mid_amplitude}'
)
if
abs
(
initial_amplitude
-
mid_amplitude
)
<
0.00001
or
abs
(
final_amplitude
-
mid_amplitude
)
<
0.00001
:
print
(
'toco un borde jejox'
)
return
mid_amplitude
#else:
if
mid_amplitude
>
self
.
Max_amplitude
or
mid_amplitude
<
self
.
Min_amplitude
:
print
(
'Pusiste al reves los limites'
)
raise
self
.
change_frequency
(
current_freq
,
mid_amplitude
)
self
.
measure_PD
(
dump
=
True
)
self
.
measure_PD
()
measured_PD
=
self
.
get_dataset
(
"Current_PD_UV"
)[
0
]
if
np
.
abs
(
measured_PD
-
pd_value
)
>
0.00005
:
if
measured_PD
>
pd_value
:
return
self
.
Binary_Search
(
pd_value
,
initial_amplitude
,
mid_amplitude
,
current_freq
)
elif
measured_PD
<
pd_value
:
return
self
.
Binary_Search
(
pd_value
,
mid_amplitude
,
final_amplitude
,
current_freq
)
else
:
#print('no se, fijate, paso algo')
return
0
else
:
return
mid_amplitude
@
rpc
(
flags
=
{
"async"
})
def
measure_PD
(
self
,
dump
=
False
):
value
=
rpi
.
ReadPD_average_pi
(
0
,
1
)
print
(
value
)
if
not
dump
:
self
.
mutate_dataset
(
f
"Current_PD_UV"
,
0
,
np
.
abs
(
value
))
@
kernel
def
init_kernel
(
self
):
self
.
core
.
reset
()
delay
(
1
*
ms
)
self
.
core
.
break_realtime
()
#self.laserUV.initialize_channel()
delay
(
100
*
us
)
self
.
laserUV
.
set_channel
()
self
.
core
.
wait_until_mu
(
now_mu
())
delay
(
1
*
ms
)
self
.
laserUV
.
on
()
@
kernel
def
change_frequency
(
self
,
freq
,
amp
):
self
.
core
.
break_realtime
()
delay
(
50
*
ms
)
self
.
laserUV
.
set_frequency
(
freq
,
amp
)
delay
(
50
*
ms
)
def
run
(
self
):
self
.
create_datasets
()
self
.
create_applets
()
self
.
init_kernel
()
i
=
0
self
.
measure_PD
(
dump
=
True
)
initial_amplitude
=
self
.
Min_amplitude
final_amplitude
=
self
.
Max_amplitude
initial_PD
=
self
.
Target_PD_Value
for
freq
in
self
.
Calibration_freqs_UV
.
sequence
:
self
.
change_frequency
(
freq
,
initial_amplitude
)
self
.
measure_PD
(
dump
=
True
)
calibrated_amplitude
=
self
.
Binary_Search
(
initial_PD
,
initial_amplitude
,
final_amplitude
,
freq
)
print
(
f
'Done freq {freq}'
)
self
.
mutate_dataset
(
"Experiment_amps_UV"
,
i
,
calibrated_amplitude
)
#initial_amplitude = calibrated_amplitude-0.1
#final_amplitude = calibrated_amplitude+0.1
i
=
i
+
1
artiq_master/repository/Calibrations/Power Calibration AOM/UV/UV_Power_calibration_check.py
0 → 100644
View file @
a0718351
import
numpy
as
np
from
time
import
sleep
from
artiq.experiment
import
*
from
pyLIAF.artiq.controllers
import
UrukulCh
from
pyLIAF.RedPitaya
import
Read_analog
as
rp
from
scipy
import
interpolate
class
LaserPowerCalibration
(
EnvExperiment
):
"""v5 - Testing UV Laser power calibration with photodiode and a red pitaya """
def
build
(
self
):
self
.
setattr_device
(
"ccb"
)
self
.
setattr_device
(
"scheduler"
)
self
.
setattr_device
(
"core"
)
self
.
laserUV
=
UrukulCh
(
self
,
ch
=
2
,
freq
=
110.0
,
amp
=
0.3
,
name
=
"UV"
)
#corresponde a 0.7 Vpp
@
rpc
def
create_datasets
(
self
):
self
.
Test_Experiment_freqs
=
self
.
get_dataset
(
"Experiment_freqs_UV"
)
self
.
Test_Experiment_amps
=
self
.
get_dataset
(
"Experiment_amps_UV"
)
self
.
set_dataset
(
"Test_Experiment_freqs"
,
self
.
Test_Experiment_freqs
,
broadcast
=
True
,
archive
=
True
)
self
.
set_dataset
(
"Test_Experiment_amps"
,
self
.
Test_Experiment_amps
,
broadcast
=
True
,
archive
=
True
)
self
.
set_dataset
(
"Test_Measured_PD_UV_counts"
,
list
(
np
.
zeros
(
len
(
self
.
Test_Experiment_freqs
),
dtype
=
int
)),
broadcast
=
True
,
archive
=
True
)
@
rpc
(
flags
=
{
"async"
})
def
create_applets
(
self
):
self
.
ccb
.
issue
(
"create_applet"
,
"verification_powercalibration"
,
"${python} -m pyLIAF.artiq.applets.plot_xy "
"Test_Measured_PD_UV_counts "
"--x Test_Experiment_freqs"
)
"""
@rpc(flags={"async"})
def measure_PD(self, i):
#sleep(1)
value = rp.ReadVoltage()
print(np.abs(value))
self.mutate_dataset("Test_Measured_PD_UV_counts", i, np.abs(value))
"""
@
rpc
(
flags
=
{
"async"
})
def
measure_PD
(
self
,
i
,
dump
=
False
):
if
not
self
.
RPstatus
:
self
.
rp_s
=
rp
.
Initiate_comm
()
self
.
RPstatus
=
True
value
=
rp
.
ReadVoltage
(
self
.
rp_s
)
print
(
value
)
if
not
dump
:
self
.
mutate_dataset
(
f
"Test_Measured_PD_UV_counts"
,
i
,
np
.
abs
(
value
))
@
kernel
def
init_kernel
(
self
):
self
.
core
.
reset
()
self
.
laserUV
.
initialize_channel
()
delay
(
10
*
us
)
self
.
laserUV
.
set_channel
()
self
.
core
.
wait_until_mu
(
now_mu
())
delay
(
1
*
ms
)
self
.
laserUV
.
on
()
@
kernel
def
change_frequency
(
self
,
freq
,
amp
):
self
.
core
.
break_realtime
()
delay
(
50
*
ms
)
self
.
laserUV
.
set_frequency
(
freq
,
amp
)
delay
(
50
*
ms
)
def
run
(
self
):
self
.
create_datasets
()
self
.
create_applets
()
self
.
init_kernel
()
self
.
RPstatus
=
False
self
.
No_freqs
=
len
(
self
.
Test_Experiment_freqs
)
i
=
0
self
.
measure_PD
(
0
,
dump
=
True
)
for
amp
,
freq
in
zip
(
self
.
Test_Experiment_amps
,
self
.
Test_Experiment_freqs
):
print
(
amp
,
freq
)
#self.change_frequency(freq, 0.25)
self
.
change_frequency
(
freq
,
amp
)
self
.
measure_PD
(
0
,
dump
=
True
)
self
.
measure_PD
(
i
)
i
=
i
+
1
artiq_master/repository/Calibrations/Power Calibration AOM/UV/UV_Power_calibration_check_rpi.py
0 → 100644
View file @
a0718351
import
numpy
as
np
from
time
import
sleep
from
artiq.experiment
import
*
from
pyLIAF.artiq.controllers
import
UrukulCh
#from pyLIAF.RedPitaya import Read_analog as rp
from
pyLIAF.RaspberryPi.PD_reader
import
PDreader
as
rpi
from
scipy
import
interpolate
class
LaserPowerCalibration
(
EnvExperiment
):
"""Testing UV Laser power calibration with photodiode and a raspberry pi """
def
build
(
self
):
self
.
setattr_device
(
"ccb"
)
self
.
setattr_device
(
"scheduler"
)
self
.
setattr_device
(
"core"
)
self
.
laserUV
=
UrukulCh
(
self
,
ch
=
2
,
freq
=
110.0
,
amp
=
0.3
,
name
=
"UV"
)
#corresponde a 0.7 Vpp
@
rpc
def
create_datasets
(
self
):
self
.
Test_Experiment_freqs
=
self
.
get_dataset
(
"Experiment_freqs_UV"
)
self
.
Test_Experiment_amps
=
self
.
get_dataset
(
"Experiment_amps_UV"
)
self
.
set_dataset
(
"Test_Experiment_freqs"
,
self
.
Test_Experiment_freqs
,
broadcast
=
True
,
archive
=
True
)
self
.
set_dataset
(
"Test_Experiment_amps"
,
self
.
Test_Experiment_amps
,
broadcast
=
True
,
archive
=
True
)
self
.
set_dataset
(
"Test_Measured_PD_UV_counts"
,
list
(
np
.
zeros
(
len
(
self
.
Test_Experiment_freqs
),
dtype
=
int
)),
broadcast
=
True
,
archive
=
True
)
@
rpc
(
flags
=
{
"async"
})
def
create_applets
(
self
):
self
.
ccb
.
issue
(
"create_applet"
,
"verification_powercalibration"
,
"${python} -m pyLIAF.artiq.applets.plot_xy "
"Test_Measured_PD_UV_counts "
"--x Test_Experiment_freqs"
)
"""
@rpc(flags={"async"})
def measure_PD(self, i):
#sleep(1)
value = rp.ReadVoltage()
print(np.abs(value))
self.mutate_dataset("Test_Measured_PD_UV_counts", i, np.abs(value))
"""
@
rpc
(
flags
=
{
"async"
})
def
measure_PD
(
self
,
i
,
dump
=
False
):
value
=
rpi
.
ReadPD_average_pi
(
0
,
1
)
print
(
value
)
if
not
dump
:
self
.
mutate_dataset
(
f
"Test_Measured_PD_UV_counts"
,
i
,
np
.
abs
(
value
))
@
kernel
def
init_kernel
(
self
):
self
.
core
.
reset
()
#self.laserUV.initialize_channel()
delay
(
1000
*
us
)
self
.
laserUV
.
set_channel
()
self
.
core
.
wait_until_mu
(
now_mu
())
delay
(
1
*
ms
)
self
.
laserUV
.
on
()
@
kernel
def
change_frequency
(
self
,
freq
,
amp
):
self
.
core
.
break_realtime
()
delay
(
50
*
ms
)
self
.
laserUV
.
set_frequency
(
freq
,
amp
)
delay
(
50
*
ms
)
def
run
(
self
):
self
.
create_datasets
()
self
.
create_applets
()
self
.
init_kernel
()
self
.
RPstatus
=
False
self
.
No_freqs
=
len
(
self
.
Test_Experiment_freqs
)
i
=
0
self
.
measure_PD
(
0
,
dump
=
True
)
for
amp
,
freq
in
zip
(
self
.
Test_Experiment_amps
,
self
.
Test_Experiment_freqs
):
print
(
amp
,
freq
)
#self.change_frequency(freq, 0.25)
self
.
change_frequency
(
freq
,
amp
)
self
.
measure_PD
(
0
,
dump
=
True
)
self
.
measure_PD
(
i
)
i
=
i
+
1
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment