adjusted the new daq to work with scans

This commit is contained in:
2020-06-18 15:47:00 +02:00
parent 89630cf9f8
commit 7df6c50504
3 changed files with 76 additions and 46 deletions
+22 -14
View File
@@ -18,6 +18,7 @@ class Daq:
channels_JF=None,
channels_BS=None,
channels_BSCAM=None,
name=None,
):
self.channels = {}
if channels_JF:
@@ -36,21 +37,28 @@ class Daq:
self.running = []
self._event_master = event_master
self._detectors_event_code = detectors_event_code
self.name = name
def acquire(self, file_name=None, Npulses=100):
print(file_name, Npulses)
acquisition = Acquisition(
acquire=None,
acquisition_kwargs={"file_names": outputfilenames, "Npulses": Npulses},
hold=False,
)
def acquire():
runno, file_names = acquire_pulses()
acquisition.acquisition_kwargs.update({'file_names':file_names})
acquisition.set_acquire_foo(acquire)
return acquisition
acquire=None, acquisition_kwargs={"Npulses": Npulses},
)
def acquire():
runno, file_names = self.acquire_pulses(
Npulses,
directory_relative=Path(file_name).parents[0],
wait=True,
channels_JF=self.channels["channels_JF"].get_current_value(),
)
acquisition.acquisition_kwargs.update({"file_names": file_names})
for key, val in acquisition.acquisition_kwargs.items():
acquisition.__dict__[key] = val
acquisition.set_acquire_foo(acquire, hold=False)
return acquisition
def acquire_pulses(self, Npulses, label=None, wait=True, **kwargs):
ix = self.start(label=label, **kwargs)
@@ -142,9 +150,9 @@ class Daq:
)
filenames = [
(directory_base / Path(filename_format.format(runno))).with_suffix(
f".{ext}.h5"
)
(directory_base / Path(filename_format.format(runno)))
.with_suffix(f".{ext}.h5")
.as_posix()
for ext in files_extensions
]
+20 -17
View File
@@ -59,26 +59,29 @@ class Scan:
tv = adj.get_current_value()
self.initial_values.append(adj.get_current_value())
print("Initial value of %s : %g" % (adj.name, tv))
if self._run_table:
runname = os.path.basename(fina).split('.')[0]
runno = int(runname.split('run')[1].split('_')[0])
metadata = {
"type": "scan",
"name": runname.split('_', 1)[1],
if self._run_table:
runname = os.path.basename(fina).split(".")[0]
runno = int(runname.split("run")[1].split("_")[0])
metadata = {
"type": "scan",
"name": runname.split("_", 1)[1],
}
for n, adj in enumerate(self.adjustables):
metadata.update({
f'scan_motor_{n}': adj.name,
f'from_motor_{n}': self.values_todo[0][n],
f'to_motor_{n}': self.values_todo[-1][n]
})
metadata.update({
metadata.update(
{
f"scan_motor_{n}": adj.name,
f"from_motor_{n}": self.values_todo[0][n],
f"to_motor_{n}": self.values_todo[-1][n],
}
)
metadata.update(
{
"steps": len(self.values_todo),
"pulses_per_step": Npulses,
"counters": [daq.name for daq in counterCallers],
})
}
)
run_table.append_run(runno, metadata=metadata)
def get_filename(self, stepNo, Ndigits=4):
@@ -130,14 +133,14 @@ class Scan:
readbacks_step.append(adj.get_current_value())
if verbose:
print("Moved variables, now starting acquisition")
filenames = []
acs = []
for ctr in self.counterCallers:
acq = ctr.acquire(file_name=fina, Npulses=self.pulses_per_step)
filenames.extend(acq.file_names)
acs.append(acq)
filenames = []
for ta in acs:
ta.wait()
filenames.extend(ta.file_names)
if verbose:
print("Done with acquisition")
@@ -206,7 +209,7 @@ class Scans:
scan_directories=False,
run_table=None,
):
self._run_table=run_table
self._run_table = run_table
self.data_base_dir = data_base_dir
scan_info_dir = Path(scan_info_dir)
if not scan_info_dir.exists():
+34 -15
View File
@@ -66,13 +66,13 @@ components = [
"type": "eco.dbase.archiver:DataApi",
"kwargs": {"pv_pulse_id": "SARES20-CVME-01-EVR0:RX-PULSEID"},
},
{
"name": "slit_und",
"type": "eco.xoptics.slits:SlitFourBlades_old",
"args": ["SARFE10-OAPU044"],
"kwargs": {},
"desc": "Slit after Undulator",
},
# {
# "name": "slit_und",
# "type": "eco.xoptics.slits:SlitFourBlades_old",
# "args": ["SARFE10-OAPU044"],
# "kwargs": {},
# "desc": "Slit after Undulator",
# },
{
"name": "pshut_und",
"type": "eco.xoptics.shutters:PhotonShutter",
@@ -472,7 +472,8 @@ components = [
"kwargs": {
"data_base_dir": "scan_data",
"scan_info_dir": f"/sf/bernina/data/{config['pgroup']}/res/scan_info",
"default_counters": [Component("daq")],
# "default_counters": [Component("daq")],
"default_counters": [],
"checker": Component("checker"),
"scan_directories": True,
"run_table": Component("run_table"),
@@ -531,6 +532,14 @@ components = [
"kwargs": {},
"lazy": True,
},
{
"args": ["/photonics/home/gac-bernina/eco/configuration/channels_JF"],
"name": "channels_JF",
"desc": "jf detector channels",
"type": "eco.devices_general.adjustable:AdjustableFS",
"kwargs": {},
"lazy": True,
},
{
"args": [],
"name": "default_channel_list",
@@ -614,14 +623,24 @@ components = [
"kwargs": {"right": "LIC7", "left": "LIC8", "up": "LIC6", "down": "LIC5"},
"lazy": True,
},
# {
# "args": [
# [
# Component("slit_und"),
# Component("slit_switch"),
# Component("slit_att"),
# Component("slit_kb"),
# ]
# ],
# "name": "slits",
# "desc": "collection of all slits",
# "type": "eco.utilities.beamline:Slits",
# "kwargs": {},
# "lazy": False,
# },
{
"args": [
[
Component("slit_und"),
Component("slit_switch"),
Component("slit_att"),
Component("slit_kb"),
]
[Component("slit_switch"), Component("slit_att"), Component("slit_kb"),]
],
"name": "slits",
"desc": "collection of all slits",
@@ -681,7 +700,7 @@ components = [
"kwargs": {
"instrument": "bernina",
"pgroup": config["pgroup"],
"channels_JF": config["jf_channels"],
"channels_JF": Component("channels_JF"),
"pulse_id_adj": "SARES20-CVME-01-EVR0:RX-PULSEID",
"event_master": Component("event_master"),
"detectors_event_code": 50,