Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Jun 3 15:38:39 2024
@author: liaf-ankylosaurus-admin
"""
import numpy as np
from artiq.experiment import *
from time import sleep
#from pyLIAF.GenFunc.generador import Generador
PORT = 60000
PASS = b'Secr3t Pa55W0rd'
from multiprocessing.connection import Client
class InOut(EnvExperiment):
"""
Long trapping
"""
def build(self):
self.setattr_device("core")
self.setattr_device("ccb")
self.ttl0 = self.get_device("ttl0")
self.ttl4 = self.get_device("ttl4")
self.setattr_argument(f"t_med",
NumberValue(300*ms, unit='ms', scale=ms, min=0.1*ms, max=1000*ms),
"Experiment params")
self.setattr_argument("t_exp",
NumberValue(200*s, unit='s', scale=s, min=5*s, max=3000*s),
"Experiment params")
self.setattr_argument("N_ions_objective",
NumberValue(1, min=1, max=1000, ndecimals=0, step=1),
"Experiment params")
self.setattr_argument("Measurement_type",
EnumerationValue(["finite_time", "indefinite_time"]),
"Scan params")
@rpc
def initialize_tca_com(self):
address = ('localhost', PORT)
self.conn = Client(address, authkey=PASS)
sleep(0.1)
@rpc
def blinkRF(self,cmd='turnOnOffRF'):
self.conn.send(f'{cmd} blink')
rta = self.conn.recv()
@rpc(flags={"async"})
def create_datasets(self):
self.set_dataset('time', [], broadcast=True, archive=True)
self.set_dataset('counts', [], broadcast=True, archive=True)
self.set_dataset('counts_indefinite',np.array([0.0]), broadcast=True, archive=False)
self.set_dataset("N_ions", [], broadcast=False, archive=True)
@rpc(flags={"async"})
def create_applets(self):
self.ccb.issue("create_applet", "longtrapping",
"${python} -m pyLIAF.artiq.applets.plot_xy "
"counts "#Tiene que estar el espacio!!!
"--x time") #Aca habria que definir bien el vector que se use en el eje x
@rpc
def Varianza(self,sig) -> TList(TFloat):
ruido=np.std(sig)
print(ruido)
return [ruido]
@kernel
def run(self):
self.initialize_tca_com()
#Preparamos las variables y los graficos
self.create_datasets()
self.create_applets()
#Se prenden los "canales" a usar
self.core.reset()
self.ttl4.output()
self.ttl0.input()
self.ttl4.on()
delay(20*ms) # time for the artiq init.
if self.Measurement_type=="indefinite_time":
while True:
cuentas=self.ttl0.gate_rising(self.t_med)
cuentas=self.ttl0.count(cuentas)
self.mutate_dataset("counts_indefinite",0,cuentas)
print(cuentas)
self.core.break_realtime()
else:
sig=[]
for i in range(int(3/self.t_med)):
cuentas=self.ttl0.gate_rising(self.t_med)
sig=sig+[self.ttl0.count(cuentas)]
self.append_to_dataset("counts",sig[-1])
self.append_to_dataset("time",i/int(self.t_exp/self.t_med))
self.core.break_realtime()
ruido=self.Varianza(sig)[0]
delay(20*ms)
for i in range(int(3/self.t_med),int(self.t_exp/self.t_med)):
cuentas=self.ttl0.gate_rising(self.t_med)
cuentas=self.ttl0.count(cuentas)
self.append_to_dataset("counts",cuentas)
self.append_to_dataset("time",i/int(self.t_exp/self.t_med))
print(cuentas)
self.core.break_realtime()
start_time = now_mu() # Record the start timeself.core.break_realtime()
self.core.break_realtime()