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
9e0fc099
Commit
9e0fc099
authored
Jun 09, 2023
by
Nicolas Nunez Barreto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
agrego meds con camara
parent
98fe4007
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
646 additions
and
0 deletions
+646
-0
Saturation_camerareading.py
...sitory/Experiments/Saturation/Saturation_camerareading.py
+270
-0
cp.log
...ory/Experiments/Spectrum/With_calibration/Motional/cp.log
+10
-0
scan_roi_test.py
...ments/Spectrum/With_calibration/Motional/scan_roi_test.py
+60
-0
urukul_RAM_AM_scan2_andor.py
...um/With_calibration/Motional/urukul_RAM_AM_scan2_andor.py
+306
-0
No files found.
artiq_master/repository/Experiments/Saturation/Saturation_camerareading.py
0 → 100644
View file @
9e0fc099
from
artiq.experiment
import
*
#Imports everything from experiment library
from
pyLIAF.artiq.controllers
import
UrukulCh
from
artiq.coredevice.ad9910
import
(
#Imports RAM destination amplitude scale factor and RAM mode bidirectional ramp methods from AD9910 Source
RAM_DEST_ASF
,
RAM_MODE_BIDIR_RAMP
,
RAM_MODE_CONT_RAMPUP
)
from
numpy
import
load
,
sin
,
linspace
,
pi
,
array
import
numpy
as
np
from
time
import
sleep
,
time
# This code demonstrates use of the urukul RAM.
# It produces a 50 MHz square waveform attenuated
# import pyximport;
# # pyximport.install(reload_support=True)
# # from importlib import reload
# pyximport.install()
#from freq_syn import optimal_param, optimal_param2, optimal_param3
# import freq_syn
# reload(freq_syn)
# optimal_param = freq_syn.optimal_param
PORT
=
60000
PASS
=
b
'Secr3t Pa55W0rd'
from
multiprocessing.connection
import
Client
class
MeltingExperiment
(
EnvExperiment
):
'''Melting experiment varying amp and reading roi of Andor'''
def
build
(
self
):
#this code runs on the host computer
self
.
setattr_device
(
"core"
)
#sets core device drivers as attributes
self
.
setattr_device
(
"ccb"
)
self
.
laserUV
=
UrukulCh
(
self
,
ch
=
2
,
freq
=
110.0
,
amp
=
0.3
,
name
=
"UV"
)
#corresponde a 0.7 Vpp
self
.
laserIR1
=
UrukulCh
(
self
,
ch
=
1
,
freq
=
208.0
,
amp
=
0.35
,
name
=
"IR1"
)
#corresponde a 0.8 Vpp
self
.
laserIR2
=
UrukulCh
(
self
,
ch
=
3
,
freq
=
80.0
,
amp
=
0.2
,
name
=
"IR2"
)
#corresponde a 0.8 Vpp
self
.
laserIR2shift
=
UrukulCh
(
self
,
ch
=
0
,
freq
=
270.0
,
amp
=
0.7
,
name
=
"IR2shift"
)
#corresponde a 0.8 Vpp
self
.
pmt
=
self
.
get_device
(
"ttl0"
)
# GUI
self
.
_channel_list
=
list
(
[
f
'Ch{jj}'
for
jj
in
range
(
4
)
]
)
self
.
setattr_argument
(
"channel"
,
EnumerationValue
(
self
.
_channel_list
))
self
.
_channel
=
0
self
.
setattr_argument
(
f
"IR1_measurement_freq"
,
NumberValue
(
229
*
MHz
,
unit
=
'MHz'
,
scale
=
MHz
,
min
=
1
*
MHz
,
max
=
400
*
MHz
),
"Measurement params"
)
self
.
setattr_argument
(
f
"IR1_measurement_amp"
,
NumberValue
(
0.25
,
min
=
0.0
,
max
=
0.35
),
"Measurement params"
)
self
.
setattr_argument
(
f
"UV_measurement_freq"
,
NumberValue
(
112
*
MHz
,
unit
=
'MHz'
,
scale
=
MHz
,
min
=
1
*
MHz
,
max
=
400
*
MHz
),
"Measurement params"
)
self
.
setattr_argument
(
f
"UV_measurement_amp"
,
NumberValue
(
0.1
,
min
=
0.0
,
max
=
0.3
),
"Measurement params"
)
self
.
setattr_argument
(
f
"IR2_measurement_freq"
,
NumberValue
(
80
*
MHz
,
unit
=
'MHz'
,
scale
=
MHz
,
min
=
1
*
MHz
,
max
=
400
*
MHz
),
"Measurement params"
)
self
.
setattr_argument
(
f
"IR2_measurement_amp"
,
NumberValue
(
0.3
,
min
=
0.0
,
max
=
0.8
),
"Measurement params"
)
self
.
setattr_argument
(
f
"IR1_final_freq"
,
NumberValue
(
229
*
MHz
,
unit
=
'MHz'
,
scale
=
MHz
,
min
=
1
*
MHz
,
max
=
400
*
MHz
),
"Final params"
)
self
.
setattr_argument
(
f
"IR1_final_amp"
,
NumberValue
(
0.23
,
min
=
0.0
,
max
=
0.35
),
"Final params"
)
self
.
setattr_argument
(
f
"UV_final_freq"
,
NumberValue
(
115
*
MHz
,
unit
=
'MHz'
,
scale
=
MHz
,
min
=
1
*
MHz
,
max
=
400
*
MHz
),
"Final params"
)
self
.
setattr_argument
(
f
"UV_final_amp"
,
NumberValue
(
0.11
,
min
=
0.0
,
max
=
0.3
),
"Final params"
)
self
.
setattr_argument
(
f
"IR2_final_freq"
,
NumberValue
(
80
*
MHz
,
unit
=
'MHz'
,
scale
=
MHz
,
min
=
1
*
MHz
,
max
=
400
*
MHz
),
"Final params"
)
self
.
setattr_argument
(
f
"IR2_final_amp"
,
NumberValue
(
0.3
,
min
=
0.0
,
max
=
0.8
),
"Final params"
)
self
.
scan_time_step
=
self
.
get_argument
(
f
"Scan time step"
,
NumberValue
(
0.5
,
min
=
0.01
,
max
=
60
,
unit
=
"s"
)
)
self
.
sorted
=
self
.
get_argument
(
f
"sorted"
,
BooleanValue
(
True
))
self
.
setattr_argument
(
"Amplitudes"
,
Scannable
(
default
=
CenterScan
(
0.2
,
0.02
,
0.01
),
global_min
=
0
,
global_max
=
0.5
)
)
self
.
setattr_argument
(
f
"t_readout"
,
NumberValue
(
300
*
ms
,
unit
=
'ms'
,
scale
=
ms
,
min
=
0.001
*
ms
),
"Experiment params"
)
self
.
setattr_argument
(
f
"t_trans"
,
NumberValue
(
10
*
us
,
unit
=
'us'
,
scale
=
us
,
min
=
1
*
us
),
"Experiment params"
)
def
run
(
self
):
t0
=
time
()
self
.
_channel
=
self
.
_channel_list
.
index
(
self
.
channel
)
address
=
(
'localhost'
,
PORT
)
conn
=
Client
(
address
,
authkey
=
PASS
)
sleep
(
0.1
)
print
(
"canal:"
,
self
.
_channel
)
# assert self._channel==3
if
self
.
sorted
:
sequence
=
sorted
(
self
.
Amplitudes
.
sequence
)
else
:
sequence
=
self
.
freqs
.
sequence
self
.
create_datasets
()
self
.
create_applets
()
self
.
init_kernel
()
#configura y setea amplitudes y frecuencias de los canales
for
ind
,
ampli
in
enumerate
(
sequence
):
print
(
f
"Amp: {ampli}"
)
self
.
set_measurement_amplitude
(
ampli
,
self
.
_channel
)
conn
.
send
([
'rois'
])
rta
=
conn
.
recv
()
val
=
rta
self
.
mutate_dataset
(
"counts_roi1"
,
ind
,
val
[
0
]
)
self
.
mutate_dataset
(
"counts_roi2"
,
ind
,
val
[
1
]
)
sleep
(
self
.
scan_time_step
)
self
.
finish_measurement
()
print
(
"FFIIINNN"
)
@
rpc
def
create_datasets
(
self
):
self
.
set_dataset
(
"counts_roi1"
,
np
.
zeros
(
len
(
self
.
Amplitudes
.
sequence
)
,
dtype
=
int
),
broadcast
=
True
,
archive
=
True
)
self
.
set_dataset
(
"counts_roi2"
,
np
.
zeros
(
len
(
self
.
Amplitudes
.
sequence
)
,
dtype
=
int
),
broadcast
=
True
,
archive
=
True
)
self
.
set_dataset
(
"amplitudes"
,
self
.
Amplitudes
.
sequence
,
broadcast
=
True
,
archive
=
True
)
self
.
set_dataset
(
"channel"
,
self
.
channel
,
broadcast
=
False
,
archive
=
True
)
self
.
set_dataset
(
"IR1_measurement_freq"
,
self
.
IR1_measurement_freq
,
broadcast
=
False
,
archive
=
True
)
self
.
set_dataset
(
"IR1_measurement_amp"
,
self
.
IR1_measurement_amp
,
broadcast
=
False
,
archive
=
True
)
self
.
set_dataset
(
"UV_measurement_freq"
,
self
.
UV_measurement_freq
,
broadcast
=
False
,
archive
=
True
)
self
.
set_dataset
(
"UV_measurement_amp"
,
self
.
UV_measurement_amp
,
broadcast
=
False
,
archive
=
True
)
self
.
set_dataset
(
"IR2_measurement_freq"
,
self
.
IR2_measurement_freq
,
broadcast
=
False
,
archive
=
True
)
self
.
set_dataset
(
"IR2_measurement_amp"
,
self
.
IR2_measurement_amp
,
broadcast
=
False
,
archive
=
True
)
@
rpc
(
flags
=
{
"async"
})
def
create_applets
(
self
):
self
.
ccb
.
issue
(
"create_applet"
,
"ROI1_Fluo_vs_amplitude_andor"
,
"${python} -m pyLIAF.artiq.applets.plot_xy "
"counts_roi1 "
"--x amplitudes"
)
self
.
ccb
.
issue
(
"create_applet"
,
"ROI2_Fluo_vs_amplitude_andor"
,
"${python} -m pyLIAF.artiq.applets.plot_xy "
"counts_roi2 "
"--x amplitudes"
)
#comento la funcion de lectura del pmt pero se podria si se quisiera
# @kernel
# def readout(self) -> TInt64:
# """Registro de cuentas emitidas"""
#
# # delay(self.t_trans)
#
# here = self.pmt.gate_rising(self.t_readout) # Que mida durante t_readout
# # self.enfriar_ion() # ya pongo a enfriar, asi todos los retardos estan enfriando
#
# return self.pmt.count(here) # recupero las cuentas medidas
@
kernel
def
init_kernel
(
self
):
self
.
core
.
reset
()
self
.
pmt
.
input
()
delay
(
100
*
ms
)
# Seteo los perfiles 0 y 1 con los mismos valores
# el 0 va a ser el de ENFRIADO, el 1 va a ser el de MEDICION y el 2 va a ser de CALENTAMIENTO
self
.
laserIR1
.
set_channel
()
self
.
laserUV
.
set_channel
()
self
.
laserIR2
.
set_channel
()
self
.
laserIR2shift
.
set_channel
()
self
.
laserIR1
.
set_frequency
(
self
.
IR1_measurement_freq
,
self
.
IR1_measurement_amp
,
profile
=
0
)
self
.
laserIR2shift
.
set_frequency
(
270
*
MHz
,
0.7
,
profile
=
0
)
self
.
laserUV
.
set_frequency
(
self
.
UV_measurement_freq
,
self
.
UV_measurement_amp
,
profile
=
0
)
self
.
laserIR2
.
set_frequency
(
self
.
IR2_measurement_freq
,
self
.
IR2_measurement_amp
,
profile
=
0
)
self
.
laserIR1
.
set_channel
(
profile
=
1
)
self
.
core
.
break_realtime
()
self
.
laserUV
.
set_channel
(
profile
=
1
)
self
.
core
.
break_realtime
()
self
.
laserIR2shift
.
set_channel
(
profile
=
1
)
self
.
core
.
break_realtime
()
self
.
laserIR2
.
set_channel
(
profile
=
1
)
self
.
core
.
break_realtime
()
self
.
laserUV
.
set_frequency
(
self
.
UV_final_freq
,
self
.
UV_final_amp
,
profile
=
1
)
self
.
core
.
break_realtime
()
self
.
laserIR1
.
set_frequency
(
self
.
IR1_final_freq
,
self
.
IR1_final_amp
,
profile
=
1
)
self
.
core
.
break_realtime
()
self
.
laserIR2
.
set_frequency
(
self
.
IR2_final_freq
,
self
.
IR2_final_amp
,
profile
=
1
)
self
.
core
.
break_realtime
()
self
.
laserIR2shift
.
set_frequency
(
270
*
MHz
,
0.7
,
profile
=
1
)
self
.
core
.
break_realtime
()
# Me aseguro que todo termine antes de seguir
self
.
core
.
break_realtime
()
self
.
core
.
wait_until_mu
(
now_mu
())
delay
(
5
*
ms
)
self
.
laserUV
.
select_profile
(
0
)
self
.
laserIR1
.
select_profile
(
0
)
self
.
laserIR2
.
select_profile
(
0
)
delay
(
5
*
ms
)
self
.
laserIR1
.
on
()
self
.
laserIR2
.
on
()
self
.
laserIR2shift
.
on
()
self
.
laserUV
.
on
()
self
.
core
.
break_realtime
()
@
kernel
def
set_measurement_amplitude
(
self
,
amp
,
ch
):
self
.
core
.
break_realtime
()
delay
(
10
*
ms
)
if
amp
<
0.5
:
if
ch
==
1
:
self
.
laserIR1
.
set_frequency
(
self
.
IR1_measurement_freq
,
amp
,
profile
=
0
)
if
ch
==
2
:
self
.
laserUV
.
set_frequency
(
self
.
UV_measurement_freq
,
amp
,
profile
=
0
)
if
ch
==
3
:
self
.
laserIR2
.
set_frequency
(
self
.
IR2_measurement_freq
,
amp
,
profile
=
0
)
else
:
print
(
'ey, casi le mandas mucha amplitud a un AOM, cuidado rufian!'
)
raise
@
kernel
def
finish_measurement
(
self
):
self
.
core
.
break_realtime
()
delay
(
5
*
ms
)
self
.
core
.
break_realtime
()
self
.
laserUV
.
set_frequency
(
self
.
UV_final_freq
,
self
.
UV_final_amp
,
profile
=
0
)
self
.
core
.
break_realtime
()
self
.
laserIR1
.
set_frequency
(
self
.
IR1_final_freq
,
self
.
IR1_final_amp
,
profile
=
0
)
self
.
core
.
break_realtime
()
self
.
laserIR2
.
set_frequency
(
self
.
IR2_final_freq
,
self
.
IR2_final_amp
,
profile
=
0
)
artiq_master/repository/Experiments/Spectrum/With_calibration/Motional/cp.log
0 → 100644
View file @
9e0fc099
INFO: Platform: linux
INFO: Version Info: v0.3.0
DEBUG: Log Path: cp.log
DEBUG: command: ['/home/liaf-ankylosaurus-admin/anaconda3/bin/python', '/home/liaf-ankylosaurus-admin/Documents/artiq/artiq_master/repository/Experiments/Spectrum/With_calibration/Motional/scan_roi_test.py']
DEBUG: file: None
DEBUG: pause: True
DEBUG: repl: /home/liaf-ankylosaurus-admin/anaconda3/bin/python
DEBUG: args: ['/home/liaf-ankylosaurus-admin/Documents/artiq/artiq_master/repository/Experiments/Spectrum/With_calibration/Motional/scan_roi_test.py']
INFO: return code: 1 (0x1)
INFO: elapsed time: 0.033690
artiq_master/repository/Experiments/Spectrum/With_calibration/Motional/scan_roi_test.py
0 → 100644
View file @
9e0fc099
from
artiq.experiment
import
*
#Imports everything from experiment library
from
artiq.coredevice.ad9910
import
(
#Imports RAM destination amplitude scale factor and RAM mode bidirectional ramp methods from AD9910 Source
RAM_DEST_ASF
,
RAM_MODE_BIDIR_RAMP
,
RAM_MODE_CONT_RAMPUP
)
from
numpy
import
load
,
sin
,
linspace
,
pi
,
array
import
numpy
as
np
from
time
import
sleep
,
time
# This code demonstrates use of the urukul RAM.
# It produces a 50 MHz square waveform attenuated
PORT
=
60000
PASS
=
b
'Secr3t Pa55W0rd'
from
multiprocessing.connection
import
Client
class
roitest
(
EnvExperiment
):
'''Scan Roi Test'''
def
build
(
self
):
#this code runs on the host computer
self
.
setattr_device
(
"core"
)
#sets core device drivers as attributes
self
.
setattr_device
(
"ccb"
)
self
.
scan_time_step
=
self
.
get_argument
(
f
"Scan time step"
,
NumberValue
(
0.5
,
min
=
0.01
,
max
=
60
,
unit
=
"s"
)
)
def
run
(
self
):
# print(self.am_freq)
# for am_delta in range(1000,5000,1000):
# parameters = get_urukul_params( self.am_freq + am_delta )
print
(
"START"
)
self
.
create_datasets
()
t0
=
time
()
address
=
(
'localhost'
,
PORT
)
conn
=
Client
(
address
,
authkey
=
PASS
)
sleep
(
0.1
)
for
jj
in
range
(
20
):
conn
.
send
([
'rois'
])
rta
=
conn
.
recv
()
val
=
rta
print
(
f
'{round(time()-t0,1)}: val({jj})={val}'
)
self
.
mutate_dataset
(
"counts1"
,
jj
,
val
[
0
]
)
self
.
mutate_dataset
(
"counts2"
,
jj
,
val
[
1
]
)
sleep
(
self
.
scan_time_step
)
print
(
"FFIIINNN"
)
@
rpc
def
create_datasets
(
self
):
self
.
set_dataset
(
"counts1"
,
np
.
zeros
(
20
,
dtype
=
int
),
broadcast
=
True
,
archive
=
True
)
self
.
set_dataset
(
"counts2"
,
np
.
zeros
(
20
,
dtype
=
int
),
broadcast
=
True
,
archive
=
True
)
artiq_master/repository/Experiments/Spectrum/With_calibration/Motional/urukul_RAM_AM_scan2_andor.py
0 → 100644
View file @
9e0fc099
from
artiq.experiment
import
*
#Imports everything from experiment library
from
artiq.coredevice.ad9910
import
(
#Imports RAM destination amplitude scale factor and RAM mode bidirectional ramp methods from AD9910 Source
RAM_DEST_ASF
,
RAM_MODE_BIDIR_RAMP
,
RAM_MODE_CONT_RAMPUP
)
from
numpy
import
load
,
sin
,
linspace
,
pi
,
array
import
numpy
as
np
from
time
import
sleep
,
time
# This code demonstrates use of the urukul RAM.
# It produces a 50 MHz square waveform attenuated
# import pyximport;
# # pyximport.install(reload_support=True)
# # from importlib import reload
# pyximport.install()
from
freq_syn
import
optimal_param
,
optimal_param2
,
optimal_param3
# import freq_syn
# reload(freq_syn)
# optimal_param = freq_syn.optimal_param
PORT
=
60000
PASS
=
b
'Secr3t Pa55W0rd'
from
multiprocessing.connection
import
Client
def
test_fail
(
x
):
if
int
(
x
-
1
)
&
840
==
840
:
return
True
if
int
(
x
-
1
)
&
900
==
900
:
return
True
def
get_urukul_array
(
frec
:
TInt32
,
num_samples
:
TInt32
,
n_harmonic
:
TInt32
)
->
list
:
"""
get the array values for AM modulation in urukul for the frequency f0
params:
f0 (float): frequency to set on AM
"""
xx
=
linspace
(
0
,
2
*
pi
*
n_harmonic
,
num
=
num_samples
,
endpoint
=
False
)
modulation
=
sin
(
xx
)
return
modulation
.
tolist
()
def
convert_amp_to_data
(
amp
):
"""
takes amp values (from 0 to 1) and returns data values (suitable for DDS load)
"""
MAX
=
2
**
9
-
1
# N = 10
# if not iterable(amp):
# amp = [amp]
# return list([ int(round(val*MAX)) << 23 for val in amp ])
return
list
([
int
(
round
(
val
*
MAX
))
for
val
in
amp
])
class
AD9910RAM_andor
(
EnvExperiment
):
'''Amplitude Modulation SCAN (V2) - Reads fluo with andor camera'''
def
build
(
self
):
#this code runs on the host computer
self
.
setattr_device
(
"core"
)
#sets core device drivers as attributes
self
.
setattr_device
(
"ccb"
)
self
.
u
=
[
self
.
get_device
(
"urukul0_ch0"
),
self
.
get_device
(
"urukul0_ch1"
),
self
.
get_device
(
"urukul0_ch2"
),
self
.
get_device
(
"urukul0_ch3"
)]
self
.
pmt
=
self
.
get_device
(
"ttl0"
)
# self.data=[0]*512 + [1000<<23]*512
self
.
data
=
[
0
]
*
1024
self
.
data_len
=
1024
# GUI
self
.
_channel_list
=
list
(
[
f
'Ch{jj}'
for
jj
in
range
(
4
)
]
)
self
.
setattr_argument
(
"channel"
,
EnumerationValue
(
self
.
_channel_list
))
self
.
frequency
=
self
.
get_argument
(
f
"frequency"
,
NumberValue
(
100
*
MHz
,
unit
=
'MHz'
,
scale
=
MHz
,
min
=
1
*
MHz
,
max
=
400
*
MHz
))
self
.
amplitude
=
self
.
get_argument
(
f
"amplitude"
,
NumberValue
(
0.25
,
min
=
0.000
,
max
=
1.000
))
self
.
depth
=
self
.
get_argument
(
f
"AM Depth"
,
NumberValue
(
0.15
,
min
=
0.000
,
max
=
1.000
))
# self.am_freq = self.get_argument(f"AM frequency",NumberValue(700*kHz, unit='kHz', scale=kHz, min=100*kHz, max=2000*kHz))
self
.
_channel
=
0
self
.
scan_time_step
=
self
.
get_argument
(
f
"Scan time step"
,
NumberValue
(
1
,
min
=
0.01
,
max
=
60
,
unit
=
"s"
)
)
self
.
sorted
=
self
.
get_argument
(
f
"sorted"
,
BooleanValue
(
True
))
self
.
setattr_argument
(
"freqs"
,
Scannable
(
default
=
CenterScan
(
700
*
kHz
,
20
*
kHz
,
1
*
kHz
),
unit
=
"kHz"
,
scale
=
kHz
,
global_min
=
1
,
global_max
=
2
*
MHz
)
)
self
.
setattr_argument
(
f
"t_readout"
,
NumberValue
(
300
*
ms
,
unit
=
'ms'
,
scale
=
ms
,
min
=
0.001
*
ms
),
"Experiment params"
)
self
.
setattr_argument
(
f
"t_trans"
,
NumberValue
(
10
*
us
,
unit
=
'us'
,
scale
=
us
,
min
=
1
*
us
),
"Experiment params"
)
def
run
(
self
):
t0
=
time
()
self
.
_channel
=
self
.
_channel_list
.
index
(
self
.
channel
)
print
(
"canal:"
,
self
.
_channel
)
# assert self._channel==3
if
self
.
sorted
:
sequence
=
sorted
(
self
.
freqs
.
sequence
)
else
:
sequence
=
self
.
freqs
.
sequence
self
.
create_datasets
()
self
.
create_applets
()
for
ind
,
am_freq
in
enumerate
(
sequence
):
self
.
mutate_dataset
(
"real_freq"
,
ind
,
am_freq
)
for
ind
,
am_freq
in
enumerate
(
sequence
):
t0
=
time
()
#; jj=0
# print(f"{jj}: {time()-t0}") ; jj += 1
parameters
=
optimal_param2
(
am_freq
)
for
jj
in
range
(
0
,
12
,
4
):
# print(f"1step time: {round(time()-t0,2)}")
frec
,
num_samples
,
n_harmonic
,
clock_step
=
parameters
[
jj
:
jj
+
4
]
modulation
=
get_urukul_array
(
frec
,
num_samples
,
n_harmonic
)
#modulation = (array(modulation)/2 * self.depth ) + (self.amplitude-self.depth)
# print(f"2step time: {round(time()-t0,2)}")
modulation
=
self
.
amplitude
*
(
1
+
0.5
*
(
1
-
self
.
depth
)
*
(
array
(
modulation
)
-
1
))
data
=
convert_amp_to_data
(
modulation
)
self
.
clock_step
=
clock_step
self
.
data_len
=
int
(
num_samples
)
self
.
ind
=
ind
# print(f"3step time: {round(time()-t0,2)}")
if
test_fail
(
num_samples
):
self
.
fix
=
True
data
=
data
+
[
0
]
*
10
self
.
data
=
[
0
]
*
len
(
data
)
for
ii
in
range
(
len
(
data
)):
self
.
data
[
ii
]
=
data
[
ii
]
else
:
self
.
fix
=
False
self
.
data
=
[
0
]
*
len
(
data
)
for
ii
in
range
(
len
(
data
)):
self
.
data
[
ii
]
=
data
[
ii
]
print
(
f
"frec: {frec} | am_freq: {am_freq} | num_samples:{num_samples} | clock_step: {clock_step}"
)
try
:
# print(f"4step time: {round(time()-t0,2)}")
self
.
run_kernel
()
# print(f"5step time: {round(time()-t0,2)}")
self
.
mutate_dataset
(
"set_freq"
,
ind
,
am_freq
)
self
.
mutate_dataset
(
"real_freq"
,
ind
,
frec
)
break
except
:
print
(
f
"HUBO UNA FALLA DEL run_kernel() (intento {int(jj/4+1)})"
)
self
.
mutate_dataset
(
"error_freq"
,
ind
,
1
)
if
jj
==
8
:
print
(
F
"NO SE PUDO SINTETIZAR F_am={am_freq} Hz POR ERRORES DEL KERNEL"
)
self
.
mutate_dataset
(
"error_freq"
,
ind
,
2
)
conn
.
send
([
'rois'
])
rta
=
conn
.
recv
()
val
=
rta
self
.
mutate_dataset
(
"counts_roi1"
,
ind
,
val
[
0
]
)
self
.
mutate_dataset
(
"counts_roi2"
,
ind
,
val
[
1
]
)
# print(f"6step time: {round(time()-t0,2)}")
sleep
(
self
.
scan_time_step
)
print
(
f
"step time: {round(time()-t0,2)}"
)
print
(
"FFIIINNN"
)
@
rpc
def
create_datasets
(
self
):
self
.
set_dataset
(
"counts"
,
np
.
zeros
(
len
(
self
.
freqs
.
sequence
)
,
dtype
=
int
),
broadcast
=
True
,
archive
=
True
)
self
.
set_dataset
(
"set_freq"
,
np
.
zeros
(
len
(
self
.
freqs
.
sequence
)
,
dtype
=
float
),
broadcast
=
True
,
archive
=
True
)
self
.
set_dataset
(
"real_freq"
,
np
.
zeros
(
len
(
self
.
freqs
.
sequence
)
,
dtype
=
float
),
broadcast
=
True
,
archive
=
True
)
self
.
set_dataset
(
"error_freq"
,
np
.
zeros
(
len
(
self
.
freqs
.
sequence
)
,
dtype
=
float
),
broadcast
=
True
,
archive
=
True
)
self
.
set_dataset
(
"channel"
,
self
.
channel
,
broadcast
=
False
,
archive
=
True
)
self
.
set_dataset
(
"freq_carrier"
,
str
(
self
.
frequency
),
broadcast
=
False
,
archive
=
True
)
self
.
set_dataset
(
"amplitude_carrier"
,
str
(
self
.
amplitude
),
broadcast
=
False
,
archive
=
True
)
self
.
set_dataset
(
"AM_depth_mod"
,
str
(
self
.
depth
),
broadcast
=
False
,
archive
=
True
)
self
.
set_dataset
(
"counts_roi1"
,
np
.
zeros
(
len
(
self
.
freqs
.
sequence
)
,
dtype
=
int
),
broadcast
=
True
,
archive
=
True
)
self
.
set_dataset
(
"counts_roi2"
,
np
.
zeros
(
len
(
self
.
freqs
.
sequence
)
,
dtype
=
int
),
broadcast
=
True
,
archive
=
True
)
@
rpc
(
flags
=
{
"async"
})
def
create_applets
(
self
):
self
.
ccb
.
issue
(
"create_applet"
,
"Motional_spectrum_AM"
,
"${python} -m pyLIAF.artiq.applets.plot_xy "
"counts "
"--x real_freq"
)
@
kernel
def
readout
(
self
)
->
TInt64
:
"""Registro de cuentas emitidas"""
# delay(self.t_trans)
here
=
self
.
pmt
.
gate_rising
(
self
.
t_readout
)
# Que mida durante t_readout
# self.enfriar_ion() # ya pongo a enfriar, asi todos los retardos estan enfriando
return
self
.
pmt
.
count
(
here
)
# recupero las cuentas medidas
@
kernel
#this code runs on the FPGA
def
run_kernel
(
self
):
if
self
.
fix
:
local_data_len
=
self
.
data_len
+
10
else
:
local_data_len
=
self
.
data_len
data
=
[
0
]
*
local_data_len
for
ii
in
range
(
local_data_len
):
data
[
ii
]
=
self
.
data
[
ii
]
<<
23
self
.
core
.
break_realtime
()
# modulation, frec, clock_step = get_urukul_array( self.am_freq )
# modulation = (modulation/2 * self.depth )+0.9
# data = convert_amp_to_data( modulation )
# data = [0]*512 + [1000<<23]*512
# clock_step = 1
#reset core
# self.core.reset()
# Esto último hace saltar un error de de underflow
#initialise
self
.
u
[
self
.
_channel
]
.
cpld
.
init
()
self
.
core
.
break_realtime
()
self
.
u
[
self
.
_channel
]
.
init
()
delay
(
1
*
ms
)
#set ram profile 0 -----------------------------
self
.
u
[
self
.
_channel
]
.
set_profile_ram
(
start
=
0
,
end
=
0
+
self
.
data_len
-
1
,
step
=
self
.
clock_step
,
profile
=
0
,
mode
=
RAM_MODE_CONT_RAMPUP
)
self
.
u
[
self
.
_channel
]
.
cpld
.
set_profile
(
0
)
self
.
u
[
self
.
_channel
]
.
cpld
.
io_update
.
pulse_mu
(
8
)
delay
(
1
*
ms
)
# ES ESTE
#write to ram
self
.
u
[
self
.
_channel
]
.
write_ram
(
data
)
delay
(
10
*
ms
)
self
.
core
.
break_realtime
()
# --------------------------
# self.u.cpld.set_profile(0)
# self.u.cpld.io_update.pulse_mu(8)
# delay(1*ms)
#write to cfr
self
.
u
[
self
.
_channel
]
.
set_cfr1
(
ram_enable
=
1
,
ram_destination
=
RAM_DEST_ASF
,
internal_profile
=
0
)
self
.
u
[
self
.
_channel
]
.
sw
.
on
()
#set urukuln parameters and turn channel on
self
.
u
[
self
.
_channel
]
.
set_frequency
(
self
.
frequency
)
self
.
u
[
self
.
_channel
]
.
cpld
.
io_update
.
pulse_mu
(
8
)
# self.u.set_att(10*dB)
# self.core.break_realtime()
# delay(1*ms)
#self.u.sw.off()
delay
(
self
.
t_trans
)
#cuentas = self.readout()
#delay(1*ms)
#self.mutate_dataset("counts", self.ind, cuentas )
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