Commit 950bbbd9 authored by Nicolas Nunez Barreto's avatar Nicolas Nunez Barreto

meds

parent 24d6fa8b
......@@ -44,7 +44,7 @@ class roitest(EnvExperiment):
for jj in range(20):
conn.send(['rois'])
conn.send(['roi_count'])
rta = conn.recv()
val = rta
print(f'{round(time()-t0,1)}: val({jj})={val}')
......
"""
Created on Mon Apr 15 13:47:37 2024
Created on Fri May 3 22:37:57 2024
@author: liaf
@author: juamp y rom
"""
import numpy as np
......@@ -19,27 +19,39 @@ class InOut(EnvExperiment):
self.ttl4 = self.get_device("ttl4")
self.setattr_argument(f"t_med",
NumberValue(20*ms, unit='ms', scale=ms, min=0.1*ms, max=1000*ms),
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=1*s, max=1000*s),
NumberValue(200*s, unit='s', scale=s, min=5*s, max=3000*s),
"Experiment params")
#self.setattr_argument("N_ions", NumberValue(1, min=1, max=15, ndecimals=0, step=1), "Experiment params")
self.setattr_argument("N_ions_objective",
NumberValue(1, min=1, max=15, ndecimals=0, step=1),
"Experiment params")
self.setattr_argument("Measurement_type",
EnumerationValue(["indefinite_time", "finite_time"]),
EnumerationValue(["finite_time", "indefinite_time"]),
"Scan params")
def create_datasets(self):
self.set_dataset('time', np.linspace(0,self.t_exp,int(self.t_exp/self.t_med)), broadcast=True, archive=True)
self.set_dataset('counts', np.zeros(int(self.t_exp/self.t_med), dtype=int) , broadcast=True, archive=True)
#self.set_dataset('counts', [], broadcast=True, archive=True)
# self.setattr_argument("Nsigma",
# NumberValue(5, min=2, max=8,ndecimals=0, step=1),
# "Scan params")
self.setattr_argument("tsub",
NumberValue(2*s,unit='s',scale=s,min=1*s, max=3*s),
"Scan params")
self.setattr_argument("tbaj",
NumberValue(2*s,unit='s',scale=s,min=2*s, max=5*s),
"Scan params")
@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", self.N_ions, broadcast=False, archive=True)
self.set_dataset("N_ions", [], broadcast=False, archive=True)
@rpc(flags={"async"})
......@@ -60,33 +72,19 @@ class InOut(EnvExperiment):
"400 "
"counts_indefinite")
# @rpc(flags={"async"})
# def record_result(self, x):
# self.ticks.append(x)
#
# def unload_txt(self, save=False):
# difs = np.diff(self.ticks)
# print('\ntiempo\t diff')
# for i, tick in enumerate(self.ticks[:-1]):
# print(f"{tick:.4f}", end='')
# if i>0:
# print(f"\t {difs[i-1]}")
# else:
# print()
#
# print(f"\ntotal: {len(self.ticks)}")
# print(f"repetidos: {np.count_nonzero(difs<1e-4)-1}")
#
# if save:
# np.savetxt('escribo_ticks.dat', self.ticks[:-1])
@rpc
def TurnOnRF(self):
pass
@rpc
def TurnOffRF(self):
pass
@rpc
def Varianza(self,sig) -> TList(TFloat):
ruido=np.std(sig)
print(ruido)
return [ruido]
@kernel
def run(self):
......@@ -111,12 +109,24 @@ class InOut(EnvExperiment):
self.core.break_realtime()
else:
for i in range(int(self.t_exp/self.t_med)):
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(10*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.mutate_dataset("counts",i,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()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment