lots of tweaks

This commit is contained in:
2018-03-17 08:53:30 +01:00
parent 246d88bbce
commit 9872e00b43
8 changed files with 296 additions and 281 deletions
+9 -5
View File
@@ -6,7 +6,7 @@ from time import sleep
import traceback
class ScanSimple:
def __init__(self,adjustables,values,counterCallers,fina,Npulses=100,basepath='',scan_info_dir='',checker=None):
def __init__(self,adjustables,values,counterCallers,fina,Npulses=100,basepath='',scan_info_dir='',checker=None,scan_directories=False):
self.Nsteps = len(values)
self.pulses_per_step = Npulses
self.adjustables = adjustables
@@ -30,6 +30,7 @@ class ScanSimple:
'scan_step_info':[]}
self.scan_info_filename = os.path.join(self.scan_info_dir,fina)
self.scan_info_filename += '_scan_info.json'
self._scan_directories = scan_directories
self.checker = checker
self.initial_values = []
for adj in self.adjustables:
@@ -40,6 +41,8 @@ class ScanSimple:
def get_filename(self,stepNo,Ndigits=4):
fina = os.path.join(self.basepath,self.fina)
if self._scan_directories:
fina = os.path.join(fina,self.fina)
fina += '_step%04d'%stepNo
return fina
@@ -116,16 +119,17 @@ class ScanSimple:
class Scans:
def __init__(self,data_base_dir='',scan_info_dir='',default_counters=[],checker=None):
def __init__(self,data_base_dir='',scan_info_dir='',default_counters=[],checker=None,scan_directories=False):
self.data_base_dir = data_base_dir
self.scan_info_dir = scan_info_dir
self._default_counters = default_counters
self.checker = checker
self._scan_directories = scan_directories
def ascan(self,adjustable,start_pos,end_pos,N_intervals,N_pulses,file_name=None,start_immediately=True):
positions = np.linspace(start_pos,end_pos,N_intervals+1)
values = [[tp] for tp in positions]
s = ScanSimple([adjustable],values,self._default_counters,file_name,Npulses=N_pulses,basepath=self.data_base_dir,scan_info_dir=self.scan_info_dir,checker=self.checker)
s = ScanSimple([adjustable],values,self._default_counters,file_name,Npulses=N_pulses,basepath=self.data_base_dir,scan_info_dir=self.scan_info_dir,checker=self.checker,scan_directories=self._scan_directories)
if start_immediately:
s.scanAll()
return s
@@ -134,7 +138,7 @@ class Scans:
positions = np.linspace(start_pos,end_pos,N_intervals+1)
current = adjustable.get_current_value()
values = [[tp+current] for tp in positions]
s = ScanSimple([adjustable],values,self._default_counters,file_name,Npulses=N_pulses,basepath=self.data_base_dir,scan_info_dir=self.scan_info_dir,checker=self.checker)
s = ScanSimple([adjustable],values,self._default_counters,file_name,Npulses=N_pulses,basepath=self.data_base_dir,scan_info_dir=self.scan_info_dir,checker=self.checker,scan_directories=self._scan_directories)
if start_immediately:
s.scanAll()
return s
@@ -146,7 +150,7 @@ class Scans:
def ascanList(self,adjustable,posList,N_pulses,file_name=None,start_immediately=True):
positions = posList
values = [[tp] for tp in positions]
s = ScanSimple([adjustable],values,self._default_counters,file_name,Npulses=N_pulses,basepath=self.data_base_dir,scan_info_dir=self.scan_info_dir,checker=self.checker)
s = ScanSimple([adjustable],values,self._default_counters,file_name,Npulses=N_pulses,basepath=self.data_base_dir,scan_info_dir=self.scan_info_dir,checker=self.checker,scan_directories=self._scan_directories)
if start_immediately:
s.scanAll()
return s
+1 -1
View File
@@ -170,7 +170,7 @@ aliases = {
'alias' : 'DetJF',
'z_und' : 142,
'desc' : '1.5M Jungfrau detector',
'eco_type' : 'devices_general.detectors.JF'},
'eco_type' : 'devices_general.detectors.DIAClient'},
'SLAAR21-LTIM01-EVR0' : {
'alias' : 'LaserShutter',
'z_und' : 142,
+113 -66
View File
@@ -267,47 +267,76 @@ def parseChannelListFile(fina):
if not d[0]=='#':
out.append(d.strip())
return out
# JF client thing
class JF_BS_writer:
def __init__(self, Id,api_address = "http://sf-daq-2:10000"):
class DIAClient:
def __init__(self, Id, api_address = "http://sf-daq-2:10000"):
self._api_address = api_address
self.client = DetectorIntegrationClient(api_address)
print("\nJungfrau Integration API on %s" % api_address)
print("\nDetector Integration API on %s" % api_address)
# No pgroup by default
self.pgroup = 0
self.n_frames = 100
self.jf_name = "JF 4.5M"
self.pede_file = ""
self.gain_file = ""
self.update_config()
def update_config(self, ):
self.writer_config = {
"output_file": "/sf/alvra/data/raw/p16581/test_data.h5",
"process_uid": 16581,
"process_gid": 16581,
"dataset_name": "jungfrau/data",
"n_messages": 100
}
"output_file": "/sf/alvra/data/raw/p%d/test_data.h5" % self.pgroup,
"user_id": self.pgroup,
"n_frames": self.n_frames,
"general/user": str(self.pgroup),
"general/process": __name__,
"general/created": str(datetime.now()),
"general/instrument": self.jf_name,
# "general/correction": "test"
}
self.backend_config = {
"n_frames": 100,
"gain_corrections_filename": "/sf/alvra/config/jungfrau/jungfrau_4p5_gaincorrections_v0.h5",
"gain_corrections_dataset": "gains",
"pede_corrections_filename": "/sf/alvra/data/res/p16581/pedestal_20171210_1628_res.h5",
"pede_corrections_dataset": "gains",
"pede_mask_dataset": "pixel_mask",
"activate_corrections_preview": True,
"n_frames": self.n_frames,
"bit_depth": 16,
"gain_corrections_filename": self.gain_file, # "/sf/alvra/config/jungfrau/jungfrau_4p5_gaincorrections_v0.h5",
#"gain_corrections_dataset": "gains",
#"pede_corrections_filename": "/sf/alvra/data/res/p%d/pedestal_20171210_1628_res.h5" % self.pgroup,
#"pede_corrections_dataset": "gains",
#"pede_mask_dataset": "pixel_mask",
#"activate_corrections_preview": True,
"is_HG0": True
}
if self.pede_file != "":
self.backend_config["gain_corrections_filename"] = self.gain_file # "/sf/alvra/config/jungfrau/jungfrau_4p5_gaincorrections_v0.h5",
self.backend_config["gain_corrections_dataset"] = "gains"
self.backend_config["pede_corrections_filename"] = self.pede_file # "/sf/alvra/data/res/p%d/pedestal_20171210_1628_res.h5" % self.pgroup,
self.backend_config["pede_corrections_dataset"] = "gains"
self.backend_config["pede_mask_dataset"] = "pixel_mask"
self.backend_config["activate_corrections_preview"] = True
self.detector_config = {
"timing": "trigger",
"exptime": 0.000005,
"cycles": 100,
"delay" : 0.001992,
"frames" : 1
}
"timing": "trigger",
"exptime": 0.000005,
"cycles": self.n_frames,
#"delay" : 0.001992,
"frames" : 1,
"dr": 16,
}
default_channels_list = parseChannelListFile(
'/sf/alvra/config/com/channel_lists/default_channel_list')
# Not needed anymore?
#default_channels_list = parseChannelListFile(
# '/sf/alvra/config/com/channel_lists/default_channel_list')
self.bsread_config = {
'output_file': '/sf/alvra/data/raw/p16581/test_bsread.h5',
'process_uid': 16581,
'process_gid': 16581,
'n_pulses':100,
'channels': default_channels_list
}
'output_file': '/sf/alvra/data/raw/p%d/test_bsread.h5' % self.pgroup,
'user_id': self.pgroup,
"general/user": str(self.pgroup),
"general/process": __name__,
"general/created": str(datetime.now()),
"general/instrument": self.jf_name,
#'Npulses':100,
#'channels': default_channels_list
}
# self.default_channels_list = jungfrau_utils.load_default_channel_list()
def reset(self):
@@ -321,32 +350,22 @@ class JF_BS_writer:
config = self.client.get_config()
return config
def set_pgroup(self, pgroup):
self.pgroup = pgroup
self.update_config()
def set_bs_channels(self, ):
print("Please update /sf/alvra/config/com/channel_lists/default_channel_list and restart all services on the DAQ server")
def set_config(self):
self.reset()
self.client.set_config(writer_config=self.writer_config, backend_config=self.backend_config, detector_config=self.detector_config, bsread_config=self.bsread_config)
# def record(self,file_name,Npulses):
# self.detector_config.update(dict(cycles=Npulses))
# self.writer_config.update(dict(output_file=file_name))
# self.reset()
# DetectorIntegrationClient.set_config(self,self.writer_config, self.backend_config, self.detector_config)
# self.client.start()
#
# def check_running(self,time_interval=.5):
# cfg = self.get_config()
# running = False
# while not running:
# if self.get_status()['status'][-7:]=='RUNNING':
# running = True
# break
# else:
# sleep(time_interval)
self.client.set_config({"writer": self.writer_config, "backend": self.backend_config, "detector": self.detector_config, "bsread": self.bsread_config})
def check_still_running(self,time_interval=.5):
def check_still_running(self, time_interval=.5):
cfg = self.get_config()
running = True
while running:
if not self.get_status()['status'][-7:]=='RUNNING':
if not self.get_status()['status'][-7:] == 'RUNNING':
running = False
break
# elif not self.get_status()['status'][-20:]=='BSREAD_STILL_RUNNING':
@@ -354,11 +373,21 @@ class JF_BS_writer:
# break
else:
sleep(time_interval)
def take_pedestal(self, n_frames, analyze=True, n_bad_modules=0, update_config=True):
import jungfrau_utils as ju
directory = '/sf/alvra/data/raw/p%d/' % self.pgroup
filename = "pedestal_%s.h5" % datetime.now().strftime("%Y%m%d_%H%M")
ju.jungfrau_run_pedestals.run(self._api_address, filename, directory, self.pgroup, 0.1, self.detector_config["exptime"],
n_frames, 1, analyze, n_bad_modules)
if update_config:
self.pede_file = filename.replace("raw/", "res/").replace(".h5", "_res.h5")
print("Pedestal file updated to %s" % self.pede_file)
return self.pede_file
def start(self):
subprocess.check_call(["caput", "SIN-TIMAST-TMA:Evt-24-Ena-Sel", "0"])
self.client.start()
subprocess.check_call(["caput", "SIN-TIMAST-TMA:Evt-24-Ena-Sel", "1"])
print("start acquisition")
pass
@@ -376,26 +405,46 @@ class JF_BS_writer:
def wait_for_status(self,*args,**kwargs):
return self.client.wait_for_status(*args,**kwargs)
def acquire(self,file_name=None,Npulses=100,JF_factor=2,bsread_padding=50):
file_name_JF = file_name + '_JF4p5M.h5'
file_name_bsread = file_name+'.h5'
def acquire(self, file_name=None, Npulses=100, JF_factor=1, bsread_padding=0):
"""
JF_factor?
bsread_padding?
"""
file_rootdir = '/sf/alvra/data/raw/p%d/' % self.pgroup
if file_name is None:
print("Not saving any data, as file_name is not set")
file_name_JF = "/dev/null"
file_name_bsread = "/dev/null"
else:
file_name_JF = file_rootdir +file_name + '_JF4p5M.h5'
file_name_bsread = file_rootdir + file_name + '.h5'
if self.pgroup == 0:
raise ValueError("Please use set_pgroup() to set a pgroup value.")
def acquire():
self.detector_config.update({
'cycles':Npulses*JF_factor})
self.n_frames = Npulses * JF_factor
self.update_config()
#self.detector_config.update({
# 'cycles': n_frames})
self.writer_config.update({
'output_file':file_name_JF,
'n_messages':Npulses*JF_factor})
self.backend_config.update({
'n_frames':Npulses*JF_factor})
'output_file': file_name_JF,
# 'n_messages': n_frames
})
#self.backend_config.update({
# 'n_frames': n_frames})
self.bsread_config.update({
'output_file':file_name_bsread,
'n_pulses':Npulses+bsread_padding
# 'Npulses': Npulses + bsread_padding
})
self.reset()
self.set_config()
print(self.get_config())
self.client.start()
done = False
while not done:
stat = self.get_status()
if stat['status'] =='IntegrationStatus.FINISHED':
@@ -408,9 +457,7 @@ class JF_BS_writer:
done = True
sleep(.1)
return Acquisition(acquire=acquire,acquisition_kwargs={'file_names':[file_name_bsread,file_name_JF], 'Npulses':Npulses},hold=False)
return Acquisition(acquire=acquire, acquisition_kwargs={'file_names': [file_name_bsread, file_name_JF], 'Npulses': Npulses},hold=False)
def wait_done(self):
self.check_running()
+136 -199
View File
@@ -10,6 +10,7 @@ import subprocess
import h5py
from time import sleep
from threading import Thread
from datetime import datetime
from ..acquisition.utilities import Acquisition
@@ -17,7 +18,8 @@ try:
import sys, os
tpath = os.path.dirname(__file__)
sys.path.insert(0,os.path.join(tpath,'../../detector_integration_api'))
sys.path.insert(0,os.path.join(tpath,'../../jungfrau_utils'))
#ask Leo(2018.03.14):
#sys.path.insert(0,os.path.join(tpath,'../../jungfrau_utils'))
from detector_integration_api import DetectorIntegrationClient
except:
print('NB: detector integration could not be imported!')
@@ -129,183 +131,93 @@ class DiodeDigitizer:
class JF:
def __init__(self, Id):
self.writer_config = ""
self.backend_config = ""
self.detector_config = ""
class DIAClient:
def __init__(self, Id, instrument=None, api_address = "http://sf-daq-2:10000", jf_name="JF_1.5M"):
self.Id = Id
self.api_address = self.Id
self.client = DetectorIntegrationClient(self.Id)
def reset(self):
self.client.reset()
pass
def get_status(self):
status = self.client.get_status()
return status
def get_config(self):
config = self.client.get_config()
return config
def set_config(self, pedestal_fname = '/sf/bernina/data/res/p16582/JF_pedestal/pedestal_20180302_1512_res.h5', fname = "/sf/bernina/data/raw/p16582/JF.h5", N = 1000):
self.reset()
self.detector_config = {
"timing": "trigger",
"exptime": 0.00001,
"delay" : 0.001987, # this is the magic aldo number
"frames" : 1,
"cycles": N}
self.writer_config = {
"output_file": fname,
"process_uid": 16582,
"process_gid": 16582,
"dataset_name": "jungfrau/data",
"n_messages": N}
self.backend_config = {
"n_frames": N,
"gain_corrections_filename": "/sf/bernina/data/res/p16582/gains_I0.h5",
"gain_corrections_dataset": "gains",
"pede_corrections_filename": pedestal_fname,
"pede_corrections_dataset": "gains",
"pede_mask_dataset" : "pixel_mask",
"activate_corrections_preview": True}
DetectorIntegrationClient.set_config(self,self.writer_config, self.backend_config, self.detector_config)
pass
def record(self,file_name,Npulses):
self.detector_config.update(dict(cycles=Npulses))
self.writer_config.update(dict(output_file=file_name))
self.reset()
DetectorIntegrationClient.set_config(self,self.writer_config, self.backend_config, self.detector_config)
self.client.start()
def check_running(self,time_interval=.5):
cfg = self.get_config()
running = False
while not running:
if self.get_status()['status'][-7:]=='RUNNING':
running = True
break
else:
sleep(time_interval)
def check_still_running(self,time_interval=.5):
cfg = self.get_config()
running = True
while running:
if not self.get_status()['status'][-7:]=='RUNNING':
running = False
break
else:
sleep(time_interval)
def start(self):
self.client.start()
print("start acquisition")
pass
def stop(self):
self.client.stop()
print("stop acquisition")
pass
def config_and_start_test(self):
self.reset()
self.set_config()
self.start()
pass
def acquire(self,file_name=None,Npulses=100):
file_name += '_JF1p5M.h5'
def acquire():
self.reset()
self.detector_config.update(dict(cycles=Npulses))
self.writer_config.update(dict(output_file=file_name))
self.set_config(f = file_name, N = Npulses)
self.client.start()
self.check_running()
self.check_still_running()
return Acquisition(acquire=acquire,acquisition_kwargs={'file_names':[file_name], 'Npulses':Npulses},hold=False)
def wait_done(self):
self.check_running()
self.check_still_running()
def parseChannelListFile(fina):
out = []
with open(fina,'r') as f:
done = False
while not done:
d = f.readline()
if not d:
done=True
if len(d)>0:
if not d.isspace():
if not d[0]=='#':
out.append(d.strip())
return out
# JF client thing
class JF_BS_writer:
def __init__(self, Id,api_address = "http://sf-daq-1:10000"):
self._api_address = api_address
self.client = DetectorIntegrationClient(api_address)
print("\nJungfrau Integration API on %s" % api_address)
print("\nDetector Integration API on %s" % api_address)
# No pgroup by default
self.pgroup = 0
self.n_frames = 100
self.jf_name = jf_name
self.pede_file = ""
self.gain_file = ""
self.instrument = instrument
if instrument is None:
print("ERROR: please configure the instrument parameter in DIAClient")
self.update_config()
def update_config(self, ):
self.writer_config = {
"output_file": "/sf/bernina/data/raw/p16582/test_data.h5",
"process_uid": 16582,
"process_gid": 16582,
"dataset_name": "jungfrau/data",
"n_messages": 100
}
"output_file": "/sf/%s/data/raw/p%d/test_data.h5" % (self.instrument, self.pgroup),
"user_id": self.pgroup,
"n_frames": self.n_frames,
"general/user": str(self.pgroup),
"general/process": __name__,
"general/created": str(datetime.now()),
"general/instrument": self.instrument,
# "general/correction": "test"
}
self.backend_config = {
"n_frames": 100,
"gain_corrections_filename": "/sf/bernina/data/res/p16582/gains.h5",
"gain_corrections_dataset": "gains",
"pede_corrections_filename": "/sf/bernina//data/res/p16582/JF_pedestal/pedestal_20171128_1048_res.h5",
"pede_corrections_dataset": "gains",
"activate_corrections_preview": True
}
"n_frames": self.n_frames,
"bit_depth": 16,
"gain_corrections_filename": self.gain_file, # "/sf/alvra/config/jungfrau/jungfrau_4p5_gaincorrections_v0.h5",
#"gain_corrections_dataset": "gains",
#"pede_corrections_filename": "/sf/alvra/data/res/p%d/pedestal_20171210_1628_res.h5" % self.pgroup,
#"pede_corrections_dataset": "gains",
#"pede_mask_dataset": "pixel_mask",
#"activate_corrections_preview": True,
# FIXME: HARDCODED!!!
"is_HG0": False
}
if self.pede_file != "":
self.backend_config["gain_corrections_filename"] = self.gain_file # "/sf/alvra/config/jungfrau/jungfrau_4p5_gaincorrections_v0.h5",
self.backend_config["gain_corrections_dataset"] = "gains"
self.backend_config["pede_corrections_filename"] = self.pede_file # "/sf/alvra/data/res/p%d/pedestal_20171210_1628_res.h5" % self.pgroup,
self.backend_config["pede_corrections_dataset"] = "gains"
self.backend_config["pede_mask_dataset"] = "pixel_mask"
self.backend_config["activate_corrections_preview"] = True
else:
self.backend_config["pede_corrections_dataset"] = "gains"
self.backend_config["pede_mask_dataset"] = "pixel_mask"
self.backend_config["gain_corrections_filename"] = ""
self.backend_config["pede_corrections_filename"] = ""
self.backend_config["activate_corrections_preview"] = False
self.detector_config = {
"timing": "trigger",
"exptime": 0.00001,
"cycles": 100,
"delay" : 0.00199,
"frames" : 1
}
"timing": "trigger",
# FIXME: HARDCODED
"exptime": 0.000010,
"cycles": self.n_frames,
#"delay" : 0.001992,
"frames" : 1,
"dr": 16,
}
default_channels_list = parseChannelListFile(
'/sf/bernina/config/com/channel_lists/default_channel_list')
# Not needed anymore?
#default_channels_list = parseChannelListFile(
# '/sf/alvra/config/com/channel_lists/default_channel_list')
self.bsread_config = {
'output_file': '/sf/bernina/data/raw/p16582/test_bsread.h5',
'process_uid': 16582,
'process_gid': 16582,
'n_pulses':100,
'channels': default_channels_list
}
'output_file': '/sf/%s/data/raw/p%d/test_bsread.h5' % (self.instrument, self.pgroup),
'user_id': self.pgroup,
"general/user": str(self.pgroup),
"general/process": __name__,
"general/created": str(datetime.now()),
"general/instrument": self.instrument,
#'Npulses':100,
#'channels': default_channels_list
}
# self.default_channels_list = jungfrau_utils.load_default_channel_list()
def reset(self):
self.client.reset()
pass
#pass
def get_status(self):
return self.client.get_status()
@@ -314,31 +226,22 @@ class JF_BS_writer:
config = self.client.get_config()
return config
def set_config(self):
self.client.set_config(writer_config=self.writer_config, backend_config=self.backend_config, detector_config=self.detector_config, bsread_config=self.bsread_config)
def set_pgroup(self, pgroup):
self.pgroup = pgroup
self.update_config()
# def record(self,file_name,Npulses):
# self.detector_config.update(dict(cycles=Npulses))
# self.writer_config.update(dict(output_file=file_name))
# self.reset()
# DetectorIntegrationClient.set_config(self,self.writer_config, self.backend_config, self.detector_config)
# self.client.start()
#
# def check_running(self,time_interval=.5):
# cfg = self.get_config()
# running = False
# while not running:
# if self.get_status()['status'][-7:]=='RUNNING':
# running = True
# break
# else:
# sleep(time_interval)
def set_bs_channels(self, ):
print("Please update /sf/%s/config/com/channel_lists/default_channel_list and restart all services on the DAQ server" % self.instrument)
def set_config(self):
self.reset()
self.client.set_config({"writer": self.writer_config, "backend": self.backend_config, "detector": self.detector_config, "bsread": self.bsread_config})
def check_still_running(self,time_interval=.5):
def check_still_running(self, time_interval=.5):
cfg = self.get_config()
running = True
while running:
if not self.get_status()['status'][-7:]=='RUNNING':
if not self.get_status()['status'][-7:] == 'RUNNING':
running = False
break
# elif not self.get_status()['status'][-20:]=='BSREAD_STILL_RUNNING':
@@ -346,7 +249,19 @@ class JF_BS_writer:
# break
else:
sleep(time_interval)
def take_pedestal(self, n_frames, analyze=True, n_bad_modules=0, update_config=True):
from jungfrau_utils.scripts.jungfrau_run_pedestals import run as jungfrau_utils_run
directory = '/sf/%s/data/raw/p%d/JF_pedestal/' % (self.instrument, self.pgroup)
filename = "pedestal_%s.h5" % datetime.now().strftime("%Y%m%d_%H%M")
jungfrau_utils_run(self._api_address, filename, directory, self.pgroup, 0.1, self.detector_config["exptime"],
n_frames, 1, analyze, n_bad_modules, self.instrument, self.jf_name)
if update_config:
self.pede_file = (directory + filename).replace("raw/", "res/").replace(".h5", "_res.h5")
print("Pedestal file updated to %s" % self.pede_file)
return self.pede_file
def start(self):
self.client.start()
print("start acquisition")
@@ -366,26 +281,47 @@ class JF_BS_writer:
def wait_for_status(self,*args,**kwargs):
return self.client.wait_for_status(*args,**kwargs)
def acquire(self,file_name=None,Npulses=100,JF_factor=2,bsread_padding=50):
file_name_JF = file_name + '_JF1p5M.h5'
file_name_bsread = file_name+'.h5'
def acquire(self, file_name=None, Npulses=100, JF_factor=1, bsread_padding=0):
"""
JF_factor?
bsread_padding?
"""
file_rootdir = '/sf/%s/data/raw/p%d/' % (self.instrument, self.pgroup)
if file_name is None:
print("Not saving any data, as file_name is not set")
file_name_JF = "/dev/null"
file_name_bsread = "/dev/null"
else:
# FIXME hardcoded
file_name_JF = file_rootdir +file_name + '_JF1p5M.h5'
file_name_bsread = file_rootdir + file_name + '.h5'
if self.pgroup == 0:
raise ValueError("Please use set_pgroup() to set a pgroup value.")
def acquire():
self.detector_config.update({
'cycles':Npulses*JF_factor})
self.n_frames = Npulses * JF_factor
self.update_config()
#self.detector_config.update({
# 'cycles': n_frames})
self.writer_config.update({
'output_file':file_name_JF,
'n_messages':Npulses*JF_factor})
self.backend_config.update({
'n_frames':Npulses*JF_factor})
'output_file': file_name_JF,
# 'n_messages': n_frames
})
#self.backend_config.update({
# 'n_frames': n_frames})
self.bsread_config.update({
'output_file':file_name_bsread,
'n_pulses':Npulses+bsread_padding
# 'Npulses': Npulses + bsread_padding
})
self.reset()
self.set_config()
#print(self.get_config())
self.client.start()
done = False
while not done:
stat = self.get_status()
if stat['status'] =='IntegrationStatus.FINISHED':
@@ -398,10 +334,11 @@ class JF_BS_writer:
done = True
sleep(.1)
return Acquisition(acquire=acquire,acquisition_kwargs={'file_names':[file_name_bsread,file_name_JF], 'Npulses':Npulses},hold=False)
return Acquisition(acquire=acquire, acquisition_kwargs={'file_names': [file_name_bsread, file_name_JF], 'Npulses': Npulses},hold=False)
def wait_done(self):
self.check_running()
self.check_still_running()
+2 -2
View File
@@ -10,8 +10,8 @@ class GPS:
### motors heavy load gps table ###
self.xhl = MotorRecord(Id+':MOT_TBL_TX')
self.yhl = MotorRecord(Id+':MOT_TBL_TZ')
self.zhl = MotorRecord(Id+':MOT_TBL_TY')
self.zhl = MotorRecord(Id+':MOT_TBL_TZ')
self.yhl = MotorRecord(Id+':MOT_TBL_TY')
self.th = MotorRecord(Id+':MOT_MY_RYTH')
try:
self.rxhl = MotorRecord(Id+':MOT_TBL_RX')
+3 -3
View File
@@ -123,9 +123,9 @@ channellistPhotonDiag = dict(alvra_channel_list=
bsdaq = BStools(default_channel_list=channellist,default_file_path='%s')
bsdaqPhotonDiag = BStools(default_channel_list=channellistPhotonDiag,default_file_path='%s')
from eco.devices_general.alvradetectors import JF_BS_writer
JF_4p5M = JF_BS_writer('JF_4p5M', api_address = "http://sf-daq-2:10000")
from eco.devices_general.alvradetectors import DIAClient
#JF_4p5M = JF_BS_writer('JF_4p5M', api_address = "http://sf-daq-2:10000")
dia = DIAClient('JF_4p5M', api_address = "http://sf-daq-2:10000", instrument="bernina")
checkerPV=PV('SARFE10-PBPG050:HAMP-INTENSITY-CAL')
+23 -5
View File
@@ -2,8 +2,9 @@
from ..aliases.bernina import elog as _elog_info
from ..utilities.elog import Elog as _Elog
from ..utilities.elog import Screenshot as _Screenshot
from ..utilities.config import loadConfig
from epics import PV
import sys,os
from colorama import Fore as _color
import traceback
@@ -11,8 +12,14 @@ import traceback
elog = _Elog(_elog_info['url'],user='gac-bernina',screenshot_directory=_elog_info['screenshot_directory'])
screenshot = _Screenshot(screenshot_directory=_elog_info['screenshot_directory'])
########### configurations ########################
currexp_file_path = '/sf/bernina/config/current_experiment.json'
if os.path.exists(currexp_file_path):
exp_config = loadConfig(currexp_file_path)
else:
print('NB: Could not load experiment config in path %s .'%currexp_file_path)
########### GENERAL IMPLEMENTATIONS ##################
from ..aliases.bernina import aliases as _aliases
def _attach_device(devDict,devId,args,kwargs):
imp_p = devDict['eco_type'].split(sep='.')
@@ -34,6 +41,7 @@ def _attach_device(devDict,devId,args,kwargs):
print((_color.GREEN+'OK'+_color.RESET).rjust(5))
except Exception as e:
print((_color.RED+'FAILED'+_color.RESET).rjust(5))
print(sys.exc_info())
error = e
return error
@@ -65,6 +73,7 @@ if len(errors)>0:
########### DAQ SECTION ########################
# configuring bs daq
def parseChannelListFile(fina):
@@ -95,9 +104,15 @@ channellistioxos = dict(bernina_channel_list=
ioxosdaq = Ioxostools(default_channel_list=channellistioxos,default_file_path='%s')
from eco.devices_general.detectors import JF_BS_writer
bsdaqJF = JF_BS_writer('bsdaqJF')
#from eco.devices_general.detectors import JF_BS_writer
#bsdaqJF = JF_BS_writer('bsdaqJF') d
from eco.devices_general.detectors import DIAClient
bsdaqJF = DIAClient('bsdaqJF', instrument="bernina", api_address = "http://sf-daq-1:10000")
try:
bsdaqJF.pgroup = int(exp_config['pgroup'][1:])
except:
print('Could not set p group in bsdaqJF !!')
checkerPV=PV('SARFE10-PBPG050:HAMP-INTENSITY-CAL')
@@ -117,9 +132,12 @@ checker['wait_time'] = 3
scansIoxos = _scan.Scans(data_base_dir='/sf/bernina/config/com/data/scan_data',scan_info_dir='/sf/bernina/config/com/data/scan_info',default_counters=[ioxosdaq])
scansJF = _scan.Scans(data_base_dir='/sf/bernina/config/com/data/scan_data',scan_info_dir='/sf/bernina/config/com/data/scan_info',default_counters=[bsdaqJF],checker=checker)
scansJF = _scan.Scans(data_base_dir='scan_data',scan_info_dir='/sf/bernina/data/%s/res/scan_info'%exp_config['pgroup'],default_counters=[bsdaqJF],checker=checker,scan_directories=True)
scansBsreadLocal = _scan.Scans(data_base_dir='/sf/bernina/config/com/data/scan_data',scan_info_dir='/sf/bernina/config/com/data/scan_info',default_counters=[bsdaq])
########### ADHOC IMPLEMENTED ########################
from ..timing.lasertiming import Lxt as _Lxt
lxt = _Lxt()
+9
View File
@@ -0,0 +1,9 @@
import json
def loadConfig(fina):
with open(fina,'r') as f:
return json.load(f)
def writeConfig(fina,obj):
with open(fina,'w') as f:
json.dump(obj,f)