Commit 6b044331 authored by Nicolas Nunez Barreto's avatar Nicolas Nunez Barreto

mediciones de perfil de haz

parent 00337876
......@@ -92,7 +92,7 @@ T0 = -0.4e-6
#files = [20577,20578,20579,20580,20581] #el 19613 es el que muestra el pico en 48.5 Hz
files = [22809,22813,22817,22818,22819,22820]
files = [22820]
files = [23178]
def bin_time_arrivals(arrival_times, tau):
"""
......@@ -134,8 +134,8 @@ for i, fname in enumerate(files):
Amplitud en funcion de la frecuencia de bineo de la rf
"""
freqrf = 7.186226e6
freqrfvec = np.arange(-4,4,0.01) + freqrf
freqrf = 7.186226e6 -29
freqrfvec = np.arange(-4,4,0.1) + freqrf
amps = []
......
"""
Created on 25/7/2025
@author: muri y marce
"""
import numpy as np
from artiq.experiment import *
from time import sleep,time
PORT = 60000
PASS = b'Secr3t Pa55W0rd'
ADDRESS="10.99.48.39"
from multiprocessing.connection import Client
# from client_import import *
PORT = 60000
PASS = b'Secr3t Pa55W0rd'
CACHE_FILE = 'CCCP_commands_cache.npy'
ADDRESS="10.99.48.39"
address = (ADDRESS, PORT)
# Create a TCP/IP socket
client = Client(address, authkey=PASS)
# cwd = os.getcwd()
# print(f"Connected to server. CWD: {cwd}")
def cmd(message):
client.send(message)
sleep(0.01)
response = client.recv()
if isinstance( response , BaseException ):
raise response
else:
return(response)
class ReadCameraTrigg(EnvExperiment):
"""
ReadCameraTrigg
"""
def build(self):
self.setattr_device("core")
self.setattr_device("ccb")
self.ttl0 = self.get_device("ttl0")
# self.ttl4 = self.get_device("ttl4")
# self.ttl6 = self.get_device("ttl6")
self.setattr_argument("t_exp",
NumberValue(1*ms, unit='s', scale=s, min=1*us, max=500*ms),
"Experiment params")
self.setattr_argument("waiting_time",
NumberValue(60*ms, unit='s',min=1*ms, max=300*ms),
"Experiment params")
self.setattr_argument("N",
NumberValue(10, min=1, max=10000, ndecimals=0, step=1),
"Experiment params")
print('lolo')
@rpc
def read_cam(self) -> TInt64:
# address = (ADDRESS, PORT)
# self.conn = Client(address, authkey=PASS)
# sleep(0.1)
# print(str(self.cmd("terminal_get_commands")))
# print('lolo')
return int(cmd(['camera_grab_roi',[],{}])[0])
@rpc
def read_cam_N(self):
t0 = time()
# rta = cmd(['camera_grab_roi',[self.N],{}])
cmd(['camera_grab_roi',[self.N],{'block':False}])
sleep(0.1)
rta = cmd('get_response(0)')
print(rta)
print(f'tiempo: {time()-t0}')
@rpc
def fin(self):
tt = self.get_dataset('time')
t0 = tt[0]
print([ self.core.mu_to_seconds(t-t0) for t in tt ])
@rpc(flags={"async"})
def create_datasets(self):
self.set_dataset('time', np.zeros(self.N, dtype=int), broadcast=True, archive=True)
self.set_dataset('counts', np.zeros(self.N, dtype=int), broadcast=True, archive=True)
@rpc(flags={"async"})
def create_applets(self):
self.ccb.issue("create_applet", "test_histogram_realtime_indefinite",
"${python} -m pyLIAF.artiq.applets.realtime "
"400 "
"counts_indefinite")
self.ccb.issue("create_applet", "test_N_ions",
"${python} -m pyLIAF.artiq.applets.plot_xy "
"counts ")
#Cuerpo principal del código
@kernel
def run(self):
#Inicializacion artiq
self.create_datasets()
self.create_applets()
#Canales
self.core.reset()
#for jj in range(self.N):
# val = self.read_cam()
# self.mutate_dataset("counts", jj, val)
# count_mu = self.core.get_rtio_counter_mu()
# self.mutate_dataset("time", jj, count_mu)
self.core.break_realtime()
self.fin()
self.run2()
@kernel
def run2(self):
#Inicializacion artiq
self.core.break_realtime()
self.read_cam_N()
self.core.break_realtime()
# import socket
import os
import time
from multiprocessing.connection import Client
from numpy import save,load
PORT = 60000
PASS = b'Secr3t Pa55W0rd'
CACHE_FILE = 'CCCP_commands_cache.npy'
address = ('localhost', PORT)
# Create a TCP/IP socket
client = Client(address, authkey=PASS)
# cwd = os.getcwd()
# print(f"Connected to server. CWD: {cwd}")
def cmd(message):
client.send(message)
time.sleep(0.01)
response = client.recv()
if isinstance( response , BaseException ):
raise response
else:
return(response)
# CWD: C:\Users\liaf-elegassen\Desktop\ARTIQ
if os.path.isfile(CACHE_FILE):
rta = load(CACHE_FILE,allow_pickle=True).tolist()
print(f'commands read from CACHE_FILE: "{os.path.join(os.getcwd(),CACHE_FILE)}"')
print(F'IF YOU NEED TO UPDATE THE CACHE OF COMMANDS, REMOVE THE FILE ("{CACHE_FILE}") AND RUN THE SCRIPT AGAIN')
else:
rta = cmd('terminal_get_commands')
save(CACHE_FILE,rta)
print(f'CACHE_FILE was updated: "{os.path.join(os.getcwd(),CACHE_FILE)}"')
import inspect
def new_command(name,cmd_string="", doc="", sig=None):
def inner(*args, **kwargs):
client.send([name,args,kwargs])
# client.send(name)
# print(f'sent: {name}')
# print(args,kwargs)
response = client.recv()
# response = None
return response
inner.__name__ = name
inner.__doc__ = cmd_string + doc if not doc is None else ''
inner.__signature__ = sig
return inner
# l1 = new_command('lolo','lol',sig=rta['rois_add_roi']['signature'])
for name, properties in rta.items():
if isinstance(properties,dict):
globals()[name] = new_command(name,
cmd_string=properties['cmd_string'],
doc=properties['doc'],
sig=properties['signature'])
else:
globals()[name] = properties
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