added stages
This commit is contained in:
@@ -27,8 +27,9 @@ 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)
|
||||
self._append(AdjustableFS, f"/sf/slab/config/eco/reference_values/ioxos_{name}_chopper_ch", name="chopper_ch", is_setting=True, default_value=0)
|
||||
self._append(AdjustableFS, f"/sf/slab/config/eco/reference_values/ioxos_{name}_chopper_thr", name="chopper_thr", is_setting=True, default_value=1000)
|
||||
self._append(AdjustableFS, f"/sf/slab/config/eco/reference_values/ioxos_{name}_chopper_inv", name="chopper_inv", is_setting=True, default_value=True)
|
||||
|
||||
class Slab_Ioxos(Assembly):
|
||||
def __init__(
|
||||
@@ -60,7 +61,7 @@ class Slab_Ioxos_Daq(Assembly):
|
||||
):
|
||||
super().__init__(name=name)
|
||||
self.ioxos = ioxos
|
||||
self._append(AdjustableFS, "/photonics/home/gac-slab/config/eco/reference_values/ioxos_daq_single_shots", name="save_single_shots", is_setting=True)
|
||||
self._append(AdjustableFS, "/sf/slab/config/eco/reference_values/ioxos_daq_single_shots", name="save_single_shots", is_setting=True)
|
||||
self._done = False
|
||||
self._default_file_path = default_file_path
|
||||
self._N_acqs = 0
|
||||
@@ -77,35 +78,14 @@ class Slab_Ioxos_Daq(Assembly):
|
||||
self.ioxos.data.add_callback(callback = cb_get_data)
|
||||
|
||||
def get_data(self, N_pulses=None):
|
||||
|
||||
N_channels = 8
|
||||
if N_pulses > 10:
|
||||
N_acqs = N_pulses // 10
|
||||
N_samples = 10
|
||||
else:
|
||||
N_samples = N_pulses
|
||||
N_pulses=10
|
||||
N_acqs = 1
|
||||
#self.ioxos.blocks(N_blocks)
|
||||
#self.ioxos.samples(N_samples)
|
||||
|
||||
#block_len = N_channels*N_samples
|
||||
#meta_len = 12
|
||||
self._data=np.zeros((N_channels*N_pulses))
|
||||
#data_acc = np.ndarray((N_channels*N_pulses,))
|
||||
#meta_acc = np.ndarray((N_blocks))
|
||||
#self._m = 0
|
||||
#
|
||||
# def cb_getdata(pv=None, *args, **kwargs):
|
||||
# data_acc[self._m*block_len:(self._m+1)*block_len] = kwargs["value"][meta_len:]
|
||||
# self._m = self._m + 1
|
||||
# if self._m == N_blocks:
|
||||
# pv.clear_callbacks()
|
||||
# self._done = True
|
||||
|
||||
|
||||
|
||||
#self._done = False
|
||||
#self.ioxos.data.add_callback(callback=cb_getdata, pv=self.ioxos.data)
|
||||
#self.ioxos.restart(1)
|
||||
self._N_acqs = N_acqs
|
||||
while(True):
|
||||
if self._N_acqs == 0:
|
||||
@@ -124,11 +104,14 @@ class Slab_Ioxos_Daq(Assembly):
|
||||
N_channels = data.shape[0]
|
||||
d = {f"ch{n}": data[n] for n in range(N_channels)}
|
||||
np.savez_compressed(file_name, **d)
|
||||
fp = Path(file_name)
|
||||
fp.chmod(0o775)
|
||||
|
||||
def save_av(self, file_name, data, adjs_rb, adjs_name, N_pulses):
|
||||
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)])
|
||||
chopper_invs = [self.ioxos.__dict__[f"ch{n}"].chopper_inv() for n in range(8)]
|
||||
w = np.array([data[ch]<thr if inv else data[ch]>thr for ch, thr, inv in zip(chopper_chs, chopper_thrs, chopper_invs)])
|
||||
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)
|
||||
@@ -151,6 +134,8 @@ class Slab_Ioxos_Daq(Assembly):
|
||||
head.extend([f"ch{n}_off_npulses, " for n in range(8)])
|
||||
header = "".join(head)
|
||||
np.savetxt(f,[d],header=header)
|
||||
fp = Path(filename_av)
|
||||
fp.chmod(0o775)
|
||||
|
||||
def acquire(self, file_name=None, N_pulses=100, adjs_rb = [], adjs_name=[], default_path=True):
|
||||
|
||||
|
||||
+59
-35
@@ -9,7 +9,7 @@ os.sys.path.insert(0,"/sf/slab/config/src/python/py_scilog")
|
||||
_eco_lazy_init = False
|
||||
|
||||
config = Configuration(
|
||||
"/photonics/home/gac-slab/config/eco/slab_config_eco.json", name="slab_config"
|
||||
"/sf/slab/config/eco/slab_config_eco.json", name="config"
|
||||
)
|
||||
|
||||
path_aliases = PathAlias()
|
||||
@@ -24,7 +24,7 @@ namespace.alias_namespace.data = []
|
||||
|
||||
namespace.append_obj(
|
||||
"set_global_memory_dir",
|
||||
"/photonics/home/gac-slab/config/eco/memory",
|
||||
"/sf/slab/config/eco/memory",
|
||||
module_name="eco.elements.memory",
|
||||
name="path_memory",
|
||||
)
|
||||
@@ -51,7 +51,8 @@ namespace.append_obj(
|
||||
"Slab_Ioxos_Daq",
|
||||
name="daq",
|
||||
module_name="eco.acquisition.ioxos_slab",
|
||||
default_file_path='/photonics/home/gac-slab/test/',
|
||||
default_file_path=f'/sf/slab/data/{config["pgroup"]}/res/',
|
||||
#default_file_path=f'/sf/slab/config/eco/test_acq/',
|
||||
ioxos=ioxos,
|
||||
lazy=True,
|
||||
)
|
||||
@@ -65,21 +66,32 @@ namespace.append_obj(
|
||||
|
||||
## Utilities
|
||||
|
||||
|
||||
|
||||
namespace.append_obj(
|
||||
"Run_Table2",
|
||||
name="run_table",
|
||||
module_name="eco.utilities.runtable",
|
||||
exp_id= config["pgroup"],
|
||||
folder_id= "1DpbE8al9__P2sYkzdE0ZJsmTOGTzxVx5",
|
||||
folder_id= "1n10Sfib-P9xqUhIQ0UuYUEkb_DpY3pcd",
|
||||
exp_path= f"/sf/slab/data/{config['pgroup']}/res/run_table/",
|
||||
#exp_path= f"/sf/slab/config/eco/test_acq/",
|
||||
devices= "slab",
|
||||
keydf_fname= "/photonics/home/gac-slab/config/eco/run_table/gspread_keys.pkl",
|
||||
cred_fname= "/photonics/home/gac-slab/config/eco/run_table/pandas_push",
|
||||
gsheet_key_path= "/photonics/home/gac-slab/config/eco/run_table/run_table_gsheet_keys",
|
||||
keydf_fname= "/sf/slab/config/eco/run_table/gspread_keys.pkl",
|
||||
cred_fname= "/sf/slab/config/eco/run_table/pandas_push",
|
||||
gsheet_key_path= "/sf/slab/config/eco/run_table/run_table_gsheet_keys",
|
||||
lazy=True,
|
||||
)
|
||||
|
||||
|
||||
namespace.append_obj(
|
||||
"Lakeshore_331",
|
||||
pvname = "SLAB-LLS-UNIT1",
|
||||
name = "cryostat_janis",
|
||||
module_name="eco.devices_general.temperature_controllers",
|
||||
lazy=True,
|
||||
)
|
||||
|
||||
namespace.append_obj(
|
||||
"Env_Sensors",
|
||||
name="env_sensors",
|
||||
@@ -87,39 +99,65 @@ namespace.append_obj(
|
||||
lazy=True,
|
||||
)
|
||||
|
||||
## SmarAct delay stages
|
||||
## 800pp setup stages
|
||||
namespace.append_obj(
|
||||
"SmaractStreamdevice",
|
||||
pvname = f"SLAB-LMTS-LAM11",
|
||||
accuracy=1e-3,
|
||||
name="delay_1_stg",
|
||||
name="delay_800pp_stg",
|
||||
module_name="eco.devices_general.motors",
|
||||
offset_file=f"/photonics/home/gac-slab/config/eco/reference_values/smaract_delay_1_stg",
|
||||
offset_file=f"/sf/slab/config/eco/reference_values/smaract_delay_800pp_stg",
|
||||
lazy=True,
|
||||
)
|
||||
namespace.append_obj(
|
||||
"DelayTime",
|
||||
module_name="eco.loptics.bernina_laser",
|
||||
stage=delay_1_stg,
|
||||
name="delay_1",
|
||||
stage=delay_800pp_stg,
|
||||
name="delay_800pp",
|
||||
)
|
||||
namespace.append_obj(
|
||||
"MotorRecord",
|
||||
module_name="eco.devices_general.motors",
|
||||
pvname="SLAB-LMOT-M002:MOT",
|
||||
name="rotation_wp",
|
||||
lazy=True,
|
||||
)
|
||||
|
||||
|
||||
## Mid-IR setup stages
|
||||
namespace.append_obj(
|
||||
"SmaractStreamdevice",
|
||||
pvname = f"SLAB-LMTS-LAM12",
|
||||
accuracy=1e-3,
|
||||
name="delay_2_stg",
|
||||
"MotorRecord",
|
||||
module_name="eco.devices_general.motors",
|
||||
offset_file=f"/photonics/home/gac-slab/config/eco/reference_values/smaract_delay_2_stg",
|
||||
pvname="SLAB-LMOT-M001:MOT",
|
||||
name="delay_mirpp_stg",
|
||||
lazy=True,
|
||||
)
|
||||
namespace.append_obj(
|
||||
"DelayTime",
|
||||
module_name="eco.loptics.bernina_laser",
|
||||
stage=delay_2_stg,
|
||||
name="delay_2",
|
||||
stage=delay_mirpp_stg,
|
||||
name="delay_mirpp",
|
||||
)
|
||||
|
||||
## Other stages
|
||||
|
||||
namespace.append_obj(
|
||||
"MotorRecord",
|
||||
module_name="eco.devices_general.motors",
|
||||
pvname="SLAB-LMOT-M003:MOT",
|
||||
name="rotation_micos_1",
|
||||
lazy=True,
|
||||
)
|
||||
namespace.append_obj(
|
||||
"MotorRecord",
|
||||
module_name="eco.devices_general.motors",
|
||||
pvname="SLAB-LMOT-M004:MOT",
|
||||
name="rotation_micos_2",
|
||||
lazy=True,
|
||||
)
|
||||
|
||||
|
||||
|
||||
## Scan callback functions
|
||||
|
||||
def _message_end_scan(scan):
|
||||
@@ -196,7 +234,8 @@ callbacks_start_scan.append(_create_metadata_structure_start_scan)
|
||||
namespace.append_obj(
|
||||
"Scans",
|
||||
data_base_dir="scan_data",
|
||||
scan_info_dir="/photonics/home/gac-slab/test/scan_info",
|
||||
#scan_info_dir="/sf/slab/config/eco/test_acq/scan_info",
|
||||
scan_info_dir=f"/sf/slab/data/{config['pgroup']}/res/scan_info",
|
||||
default_counters=[daq],
|
||||
checker=False,
|
||||
scan_directories=True,
|
||||
@@ -209,19 +248,4 @@ namespace.append_obj(
|
||||
lazy=True,
|
||||
)
|
||||
|
||||
############## experiment specific #############
|
||||
|
||||
# try to append pgroup folder to path !!!!! This caused eco to run in a timeout without error traceback !!!!!
|
||||
try:
|
||||
import sys
|
||||
from ..utilities import TimeoutPath
|
||||
if ~TimeoutPath(f'/sf/slab/data/{config["pgroup"]}/res/').exists():
|
||||
print(
|
||||
"Could not access experiment folder, could be due to more systematic file system failure!"
|
||||
)
|
||||
except:
|
||||
print("Did not succed to touch prgoup")
|
||||
|
||||
|
||||
#### pgroup specific appending, might be temporary at this location ####
|
||||
|
||||
|
||||
@@ -730,9 +730,12 @@ class Gsheet_API:
|
||||
name="gsheet_keys",
|
||||
default_value="metadata thc gps xrd att att_usd kb",
|
||||
)
|
||||
self.folder_id = folder_id
|
||||
self.init_runtable(exp_id)
|
||||
|
||||
def create_rt_spreadsheet(self, exp_id):
|
||||
def create_rt_spreadsheet(self, exp_id, folder_id=None):
|
||||
if folder_id is None:
|
||||
folder_id = self.folder_id
|
||||
self.gc = gspread.authorize(self._credentials)
|
||||
spreadsheet = self.gc.create(
|
||||
title=f"run_table_{exp_id}", folder_id=folder_id
|
||||
@@ -754,6 +757,8 @@ class Gsheet_API:
|
||||
def init_runtable(self, exp_id):
|
||||
if os.path.exists(self._keydf_fname):
|
||||
self._key_df = pd.read_pickle(self._keydf_fname)
|
||||
else:
|
||||
self._key_df = pd.DataFrame()
|
||||
if self._key_df is not None and str(exp_id) in self._key_df.index:
|
||||
spreadsheet_key = self._key_df["keys"][f"{exp_id}"]
|
||||
else:
|
||||
@@ -1107,6 +1112,8 @@ class Run_Table_DataFrame(DataFrame):
|
||||
data_dir.chmod(0o775)
|
||||
print(f"Tried to change permissions to 775")
|
||||
pd.DataFrame(self).to_pickle(self.fname + "tmp")
|
||||
fp = Path(self.fname + "tmp")
|
||||
fp.chmod(0o775)
|
||||
call(["mv", self.fname + "tmp", self.fname])
|
||||
|
||||
def load(self):
|
||||
|
||||
Reference in New Issue
Block a user