Added sorting of shots by chopper
This commit is contained in:
@@ -27,6 +27,8 @@ class IoxosChannel(Assembly):
|
||||
self._append(AdjustablePv, self.pvbase + f":CH{ch}:START_NEW", name = "sig_start", is_setting=True)
|
||||
self._append(AdjustablePv, self.pvbase + f":CH{ch}:END_NEW", name = "sig_end", is_setting=True)
|
||||
self._append(AdjustablePvEnum, self.pvbase + f":BOX_STAT{ch}", name = "boxcar_calculation", is_setting=True)
|
||||
self._append(AdjustableFS, f"/photonics/home/gac-slab/config/eco/reference_values/ioxos_{name}_chopper_ch", name="chopper_ch", is_setting=True, default_value=0)
|
||||
self._append(AdjustableFS, f"/photonics/home/gac-slab/config/eco/reference_values/ioxos_{name}_chopper_thr", name="chopper_thr", is_setting=True, default_value=1000)
|
||||
|
||||
class Slab_Ioxos(Assembly):
|
||||
def __init__(
|
||||
@@ -124,19 +126,29 @@ class Slab_Ioxos_Daq(Assembly):
|
||||
np.savez_compressed(file_name, **d)
|
||||
|
||||
def save_av(self, file_name, data, adjs_rb, adjs_name, N_pulses):
|
||||
print(adjs_name, "in saveav")
|
||||
chopper_chs = [self.ioxos.__dict__[f"ch{n}"].chopper_ch() for n in range(8)]
|
||||
chopper_thrs = [self.ioxos.__dict__[f"ch{n}"].chopper_thr() for n in range(8)]
|
||||
w = np.array([data[ch]>thr for ch, thr in zip(chopper_chs, chopper_thrs)])
|
||||
d_av_on = np.mean(data, axis=1, where=w)
|
||||
d_av_off = np.mean(data, axis=1, where=~w)
|
||||
d_std_on = np.std(data, axis=1, where=w)
|
||||
d_std_off = np.std(data, axis=1, where=~w)
|
||||
d_npulses_on = np.sum(w, axis=1)
|
||||
d_npulses_off = np.sum(~w, axis=1)
|
||||
filename_av = file_name.split("_step")[0] + ".txt"
|
||||
d_av = np.mean(data, axis=1)
|
||||
d_err = np.std(data, axis=1)/np.sqrt(N_pulses)
|
||||
d = np.hstack([adjs_rb, d_av, d_err])
|
||||
d = np.hstack([adjs_rb, d_av_on, d_av_off, d_std_on, d_std_off, d_npulses_on, d_npulses_off])
|
||||
exists = os.path.isfile(filename_av)
|
||||
with open(filename_av, "a") as f:
|
||||
if exists:
|
||||
np.savetxt(f,[d])
|
||||
else:
|
||||
head = [f"{n}, " for n in adjs_name]
|
||||
head.extend([f"ch{n}, " for n in range(8)])
|
||||
head.extend([f"ch{n}_err, " for n in range(8)])
|
||||
head.extend([f"ch{n}_on, " for n in range(8)])
|
||||
head.extend([f"ch{n}_off, " for n in range(8)])
|
||||
head.extend([f"ch{n}_on_std, " for n in range(8)])
|
||||
head.extend([f"ch{n}_off_std, " for n in range(8)])
|
||||
head.extend([f"ch{n}_on_npulses, " for n in range(8)])
|
||||
head.extend([f"ch{n}_off_npulses, " for n in range(8)])
|
||||
header = "".join(head)
|
||||
np.savetxt(f,[d],header=header)
|
||||
|
||||
|
||||
@@ -188,7 +188,6 @@ class Scan:
|
||||
file_name=fina, Npulses=self.pulses_per_step, acq_pars=acq_pars
|
||||
)
|
||||
elif isinstance(ctr, Slab_Ioxos_Daq):
|
||||
print([adj.name for adj in self.adjustables], "in scan")
|
||||
acq = ctr.acquire(file_name=fina, N_pulses=self.pulses_per_step, adjs_rb=readbacks_step, adjs_name=[adj.name for adj in self.adjustables])
|
||||
else:
|
||||
acq = ctr.acquire(file_name=fina, Npulses=self.pulses_per_step)
|
||||
|
||||
@@ -2,8 +2,10 @@ import numpy as np
|
||||
from epics import caget
|
||||
from epics import PV
|
||||
from eco.epics.utilities_epics import EnumWrapper
|
||||
|
||||
from bsread import source, SUB
|
||||
try:
|
||||
from bsread import source, SUB
|
||||
except:
|
||||
pass
|
||||
import subprocess
|
||||
import h5py
|
||||
from time import sleep
|
||||
|
||||
+44
-19
@@ -4,6 +4,7 @@ import pyttsx3
|
||||
from ..utilities.path_alias import PathAlias
|
||||
import os
|
||||
|
||||
|
||||
os.sys.path.insert(0,"/sf/slab/config/src/python/py_scilog")
|
||||
_eco_lazy_init = False
|
||||
|
||||
@@ -42,7 +43,7 @@ namespace.append_obj(
|
||||
name="ioxos",
|
||||
module_name="eco.acquisition.ioxos_slab",
|
||||
pvbase="SLAB-LSCP1-ESB1",
|
||||
lazy=False,
|
||||
lazy=True,
|
||||
)
|
||||
|
||||
#f"/sf/bernina/data/{config['pgroup']}/res/",
|
||||
@@ -52,15 +53,9 @@ namespace.append_obj(
|
||||
module_name="eco.acquisition.ioxos_slab",
|
||||
default_file_path='/photonics/home/gac-slab/test/',
|
||||
ioxos=ioxos,
|
||||
lazy=False,
|
||||
lazy=True,
|
||||
)
|
||||
|
||||
#namespace.append_obj(
|
||||
# "BerninaEnv",
|
||||
# name="env_log",
|
||||
# module_name="eco.fel.atmosphere",
|
||||
# lazy=True,
|
||||
#)
|
||||
|
||||
# adding all stuff from the config components the "old" way of configuring.
|
||||
# whatever is added, it is available by the configured name in this module
|
||||
@@ -85,6 +80,46 @@ namespace.append_obj(
|
||||
)
|
||||
|
||||
|
||||
namespace.append_obj(
|
||||
"Env_Sensors",
|
||||
name="env_sensors",
|
||||
module_name="eco.sample_env.environment_sensors",
|
||||
lazy=True,
|
||||
)
|
||||
|
||||
## SmarAct delay stages
|
||||
namespace.append_obj(
|
||||
"SmaractStreamdevice",
|
||||
pvname = f"SLAB-LMTS-LAM11",
|
||||
accuracy=1e-3,
|
||||
name="delay_1_stg",
|
||||
module_name="eco.devices_general.motors",
|
||||
offset_file=f"/photonics/home/gac-slab/config/eco/reference_values/smaract_delay_1_stg",
|
||||
lazy=True,
|
||||
)
|
||||
namespace.append_obj(
|
||||
"DelayTime",
|
||||
module_name="eco.loptics.bernina_laser",
|
||||
stage=delay_1_stg,
|
||||
name="delay_1",
|
||||
)
|
||||
|
||||
|
||||
namespace.append_obj(
|
||||
"SmaractStreamdevice",
|
||||
pvname = f"SLAB-LMTS-LAM12",
|
||||
accuracy=1e-3,
|
||||
name="delay_2_stg",
|
||||
module_name="eco.devices_general.motors",
|
||||
offset_file=f"/photonics/home/gac-slab/config/eco/reference_values/smaract_delay_2_stg",
|
||||
lazy=True,
|
||||
)
|
||||
namespace.append_obj(
|
||||
"DelayTime",
|
||||
module_name="eco.loptics.bernina_laser",
|
||||
stage=delay_2_stg,
|
||||
name="delay_2",
|
||||
)
|
||||
## Scan callback functions
|
||||
|
||||
def _message_end_scan(scan):
|
||||
@@ -94,18 +129,8 @@ def _message_end_scan(scan):
|
||||
e.stop()
|
||||
|
||||
|
||||
#def _copy_scan_info_to_raw(scan, daq=daq):
|
||||
# run_number = daq.get_last_run_number()
|
||||
# pgroup = daq.pgroup
|
||||
# print(f"Copying info file to run {run_number} to the raw directory of {pgroup}.")
|
||||
# response = daq.append_aux(
|
||||
# scan.scan_info_filename, pgroup=pgroup, run_number=run_number
|
||||
# )
|
||||
# print(f"Status: {response.json()['status']} Message: {response.json()['message']}")
|
||||
|
||||
|
||||
callbacks_start_scan = []
|
||||
callbacks_end_scan = [_message_end_scan]
|
||||
callbacks_end_scan = []
|
||||
|
||||
elog=None
|
||||
def _create_metadata_structure_start_scan(scan, run_table=run_table, elog=elog):
|
||||
|
||||
Reference in New Issue
Block a user