From 7ccb05479a1c5151404bbf8dfd41bd8ec34bc94c Mon Sep 17 00:00:00 2001 From: Mathias Sander Date: Fri, 29 Sep 2023 13:33:30 +0200 Subject: [PATCH] fixed some deprecation errors in run_table, fixes in xrd kappa --- eco/bernina/bernina.py | 317 +++++++------ eco/devices_general/motors.py | 440 ++++++++++++++++++ eco/endstations/bernina_diffractometers.py | 16 +- .../bernina_sample_environments.py | 46 +- eco/loptics/bernina_laser.py | 6 +- eco/microscopes/microscopes.py | 37 ++ eco/timing/timing_diag.py | 2 +- eco/utilities/elog_scilog.py | 2 +- eco/utilities/runtable.py | 15 +- eco/xdiagnostics/profile_monitors.py | 2 +- eco/xoptics/att_usd.py | 4 +- eco/xoptics/reflaser.py | 2 +- 12 files changed, 712 insertions(+), 177 deletions(-) diff --git a/eco/bernina/bernina.py b/eco/bernina/bernina.py index c27f2e3..84d0b3b 100644 --- a/eco/bernina/bernina.py +++ b/eco/bernina/bernina.py @@ -44,35 +44,38 @@ from eco.elements.adj_obj import AdjustableObject namespace.append_obj(AdjustableObject, _config_bernina_dict, name="config_bernina") -#namespace.append_obj( -# "Elog", -# "https://elog-gfa.psi.ch/Bernina", -# screenshot_directory="/tmp", -# name="elog_gfa", -# module_name="eco.utilities.elog", -#) - -#namespace.append_obj( -# "Elog", -# pgroup_adj=config_bernina.pgroup, -# name="scilog", -# module_name="eco.utilities.elog_scilog", -#) - -#namespace.append_obj( -# "ElogsMultiplexer", -# scilog, -# elog_gfa, -# name="elog", -# module_name="eco.utilities.elog", -#) namespace.append_obj( "Elog", "https://elog-gfa.psi.ch/Bernina", screenshot_directory="/tmp", + name="elog_gfa", + module_name="eco.utilities.elog", + lazy=True, +) + +namespace.append_obj( + "Elog", + pgroup_adj=config_bernina.pgroup, + name="scilog", + module_name="eco.utilities.elog_scilog", + lazy=True, +) + +namespace.append_obj( + "ElogsMultiplexer", + scilog, + elog_gfa, name="elog", module_name="eco.utilities.elog", + lazy=True, ) +# namespace.append_obj( +# "Elog", +# "https://elog-gfa.psi.ch/Bernina", +# screenshot_directory="/tmp", +# name="elog", +# module_name="eco.utilities.elog", +# ) eco.ELOG = elog namespace.append_obj( @@ -109,7 +112,7 @@ namespace.append_obj( "EventWorker", name="bs_worker", module_name="escape.stream", - lazy=False, + lazy=True, ) namespace.append_obj( @@ -200,19 +203,19 @@ namespace.append_obj( "SlitBladesGeneral", name="slit_kb", def_blade_up={ - "args": [SmaractRecord, "SARES23:LIC2"], + "args": [SmaractRecord, "SARES23-LIC:MOT_2"], "kwargs": {}, }, def_blade_down={ - "args": [SmaractRecord, "SARES23:LIC1"], + "args": [SmaractRecord, "SARES23-LIC:MOT_1"], "kwargs": {}, }, def_blade_left={ - "args": [SmaractRecord, "SARES23:LIC9"], + "args": [SmaractRecord, "SARES23-LIC:MOT_9"], "kwargs": {}, }, def_blade_right={ - "args": [SmaractRecord, "SARES23:LIC4"], + "args": [SmaractRecord, "SARES23-LIC:MOT_4"], "kwargs": {}, }, module_name="eco.xoptics.slits", @@ -254,19 +257,19 @@ namespace.append_obj( "SlitBladesGeneral", name="slit_cleanup", def_blade_up={ - "args": [SmaractRecord, "SARES23:LIC6"], + "args": [SmaractRecord, "SARES23-LIC:MOT_6"], "kwargs": {}, }, def_blade_down={ - "args": [SmaractRecord, "SARES23:LIC5"], + "args": [SmaractRecord, "SARES23-LIC:MOT_5"], "kwargs": {}, }, def_blade_left={ - "args": [SmaractRecord, "SARES23:LIC8"], + "args": [SmaractRecord, "SARES23-LIC:MOT_8"], "kwargs": {}, }, def_blade_right={ - "args": [SmaractRecord, "SARES23:LIC7"], + "args": [SmaractRecord, "SARES23-LIC:MOT_7"], "kwargs": {}, }, module_name="eco.xoptics.slits", @@ -473,7 +476,7 @@ namespace.append_obj( namespace.append_obj( "SolidTargetDetectorBerninaUSD", - "SARES23:LIC12", + "SARES23-LIC:MOT_12", # diode_channels_raw={ # "up": "", # "down": "", @@ -552,13 +555,13 @@ namespace.append_obj( "ProfKbBernina", module_name="eco.xdiagnostics.profile_monitors", name="prof_kb", - pvname_mirror="SARES23:LIC11", + pvname_mirror="SARES23-LIC:MOT_11", lazy=True, ) namespace.append_obj( "TimetoolBerninaUSD", module_name="eco.timing.timing_diag", - pvname_mirror="SARES23:LIC11", + pvname_mirror="SARES23-LIC:MOT_11", name="tt_kb", lazy=True, ) @@ -797,7 +800,6 @@ namespace.append_obj( configuration=config_bernina.xrd_config(), detectors=[ {"name": "det_diff", "jf_id": "JF01T03V01"}, - {"name": "det_fluo", "jf_id": "JF04T01V01"}, ], pgroup_adj=config_bernina.pgroup, configsjf_adj=config_JFs, @@ -879,15 +881,16 @@ namespace.append_obj( lazy=True, ) -namespace.append_obj( - "DetectorRobot", - JF_detector_id="JF01T03V01", - JF_detector_name="det_diff", - pgroup_adj=config_bernina.pgroup, - config_adj=config_JFs, - module_name="eco.endstations.bernina_robot", - name="robot", -) +#namespace.append_obj( +# "DetectorRobot", +# JF_detector_id="JF01T03V01", +# JF_detector_name="det_diff", +# pgroup_adj=config_bernina.pgroup, +# config_adj=config_JFs, +# module_name="eco.endstations.bernina_robot", +# lazy=True, +# name="robot", +#) namespace.append_obj( "MpodModule", @@ -896,6 +899,7 @@ namespace.append_obj( ["ch1", "ch2", "ch3", "ch4"], module_string="LV_OMPV_1", name="power_LV_patch1", + lazy=True, module_name="eco.devices_general.powersockets", ) @@ -906,6 +910,7 @@ namespace.append_obj( ["ch1", "ch2", "ch3", "ch4"], module_string="LV_OMPV_1", name="power_LV_patch2", + lazy=True, module_name="eco.devices_general.powersockets", ) @@ -1036,12 +1041,15 @@ def _append_namesace_status_to_scan( def _write_namespace_status_to_scan( - scan, daq=daq, namespace=namespace, append_status_info=True, **kwargs + scan, daq=daq, namespace=namespace, append_status_info=True, end_scan=True, **kwargs ): if not append_status_info: return - namespace_status = namespace.get_status(base=None) - scan.status["status_run_end"] = namespace_status + if end_scan: + namespace_status = namespace.get_status(base=None) + scan.status["status_run_end"] = namespace_status + if (not end_scan) and not (len(scan.values_done) == 1): + return runno = daq.get_last_run_number() pgroup = daq.pgroup tmpdir = Path(f"/sf/bernina/data/{pgroup}/res/tmp/stat_run{runno:04d}") @@ -1066,30 +1074,44 @@ def _write_namespace_status_to_scan( scan.scan_info["scan_parameters"]["status"] = "aux/status.json" -def _write_namespace_aliases_to_scan(scan, daq=daq, **kwargs): - namespace_aliases = namespace.alias.get_all() - runno = daq.get_last_run_number() - pgroup = daq.pgroup - tmpdir = Path(f"/sf/bernina/data/{pgroup}/res/tmp/aliases_run{runno:04d}") - tmpdir.mkdir(exist_ok=True, parents=True) - aliasfile = tmpdir / Path("aliases.json") - if not Path(aliasfile).exists(): - with open(aliasfile, "w") as f: - json.dump(namespace_aliases, f, sort_keys=True, cls=NumpyEncoder, indent=4) - else: - with open(aliasfile, "r+") as f: - f.seek(0) - json.dump(namespace_aliases, f, sort_keys=True, cls=NumpyEncoder, indent=4) - f.truncate() - response = daq.append_aux( - aliasfile.resolve().as_posix(), - pgroup=pgroup, - run_number=runno, - ) - print("####### transfer aliases #######") - print(response.json()) - print("################################") - scan.scan_info["scan_parameters"]["aliases"] = "aux/aliases.json" +def _write_namespace_aliases_to_scan(scan, daq=daq, force=False, **kwargs): + if force or (len(scan.values_done) == 1): + namespace_aliases = namespace.alias.get_all() + runno = daq.get_last_run_number() + pgroup = daq.pgroup + tmpdir = Path(f"/sf/bernina/data/{pgroup}/res/tmp/aliases_run{runno:04d}") + tmpdir.mkdir(exist_ok=True, parents=True) + aliasfile = tmpdir / Path("aliases.json") + if not Path(aliasfile).exists(): + with open(aliasfile, "w") as f: + json.dump( + namespace_aliases, f, sort_keys=True, cls=NumpyEncoder, indent=4 + ) + else: + with open(aliasfile, "r+") as f: + f.seek(0) + json.dump( + namespace_aliases, f, sort_keys=True, cls=NumpyEncoder, indent=4 + ) + f.truncate() + + scan.remaining_tasks.append( + Thread( + target=daq.append_aux, + args=[aliasfile.resolve().as_posix()], + kwargs=dict(pgroup=pgroup, run_number=runno), + ) + ) + scan.remaining_tasks[-1].start() + # response = daq.append_aux( + # aliasfile.resolve().as_posix(), + # pgroup=pgroup, + # run_number=runno, + # ) + print("####### transfer aliases started #######") + # print(response.json()) + # print("################################") + scan.scan_info["scan_parameters"]["aliases"] = "aux/aliases.json" def _message_end_scan(scan, **kwargs): @@ -1163,7 +1185,16 @@ def _copy_scan_info_to_raw(scan, daq=daq, **kwargs): f.truncate() # print(f"Copying info file to run {runno} to the raw directory of {pgroup}.") - response = daq.append_aux(scaninfofile.as_posix(), pgroup=pgroup, run_number=runno) + + scan.remaining_tasks.append( + Thread( + target=daq.append_aux, + args=[scaninfofile.as_posix()], + kwargs=dict(pgroup=pgroup, run_number=runno), + ) + ) + scan.remaining_tasks[-1].start() + # response = daq.append_aux(scaninfofile.as_posix(), pgroup=pgroup, run_number=runno) # print(f"Status: {response.json()['status']} Message: {response.json()['message']}") # print( # f"--> creating and copying file took{time.time()-t_start} s, presently adding to deadtime." @@ -1344,15 +1375,29 @@ callbacks_start_scan.append(_increment_daq_run_number) callbacks_start_scan.append(append_scan_monitors) callbacks_end_step = [] callbacks_end_step.append(_copy_scan_info_to_raw) +callbacks_end_step.append(_write_namespace_aliases_to_scan) +callbacks_end_step.append( + lambda scan, daq=daq, namespace=namespace, append_status_info=True, end_scan=True, **kwargs: _write_namespace_status_to_scan( + scan, + daq=daq, + namespace=namespace, + append_status_info=append_status_info, + end_scan=False, + **kwargs, + ) +) callbacks_end_scan = [] callbacks_end_scan.append(_write_namespace_status_to_scan) -callbacks_end_scan.append(_write_namespace_aliases_to_scan) callbacks_end_scan.append(_copy_scan_info_to_raw) +callbacks_end_scan.append( + lambda scan, daq=daq, force=True, **kwargs: _write_namespace_aliases_to_scan( + scan, daq=daq, force=force, **kwargs + ) +) callbacks_end_scan.append(_copy_selected_JF_pedestals_to_raw) callbacks_end_scan.append(end_scan_monitors) callbacks_end_scan.append(_message_end_scan) - # >>>> Extract for run_table and elog @@ -1421,7 +1466,8 @@ def _create_metadata_structure_start_scan( {"elog_post_link": scan._elog[1]._log._url + str(scan._elog_id)} ) except: - print("elog posting failed") + print("Elog posting failed with:") + traceback.print_exc() if not append_status_info: return d = {} @@ -1449,6 +1495,7 @@ namespace.append_obj( pvname="SLAAR21-LTIM01-EVR0:CALCI", thresholds=[0.2, 10], required_fraction=0.6, + lazy=True, name="checker_ioxos_old", ) @@ -1458,6 +1505,7 @@ namespace.append_obj( bs_channel="SAROP21-PBPS133:INTENSITY", thresholds=[0.2, 10], required_fraction=0.6, + lazy=True, name="checker", ) @@ -1653,16 +1701,16 @@ from ..epics.adjustable import AdjustablePv, AdjustablePvEnum # self.motor_configuration = { # "delaystage_both": { -# "id": "SARES23:ESB15", +# "id": "SARES23-USR:MOT_15", # }, # "delaystage_pulse2": { -# "id": "SARES23:ESB1", +# "id": "SARES23-USR:MOT_1", # }, # "wp_both": { -# "id": "SARES23:ESB3", +# "id": "SARES23-USR:MOT_3", # }, # "wp_pulse2": { -# "id": "SARES23:ESB2", +# "id": "SARES23-USR:MOT_2", # }, # } # for name, config in self.motor_configuration.items(): @@ -1740,9 +1788,9 @@ class N2jet(Assembly): class Incoupling(Assembly): def __init__(self, name=None): super().__init__(name=name) - self._append(SmaractRecord, "SARES23:ESB12", name="ver", is_setting=True) - self._append(SmaractRecord, "SARES23:ESB11", name="hor", is_setting=True) - # self._append(SmaractRecord, "SARES23:ESB11", name="x", is_setting=True) + self._append(SmaractRecord, "SARES23-USR:MOT_12", name="ver", is_setting=True) + self._append(SmaractRecord, "SARES23-USR:MOT_11", name="hor", is_setting=True) + # self._append(SmaractRecord, "SARES23-USR:MOT_11", name="x", is_setting=True) # self._append( # MotorRecord, # "SLAAR21-LMOT-M521:MOTOR_1", @@ -1821,20 +1869,20 @@ namespace.append_obj( # class LaserSteering(Assembly): # def __init__(self, name=None): # super().__init__(name=name) -# self._append(SmaractRecord, "SARES23:ESB3", name="mirr1_pitch", is_setting=True) -# self._append(SmaractRecord, "SARES23:ESB4", name="mirr1_roll", is_setting=True) -# self._append(SmaractRecord, "SARES23:ESB14", name="mirr2_pitch", is_setting=True) -# self._append(SmaractRecord, "SARES23:ESB12", name="mirr2_roll", is_setting=True) +# self._append(SmaractRecord, "SARES23-USR:MOT_3", name="mirr1_pitch", is_setting=True) +# self._append(SmaractRecord, "SARES23-USR:MOT_4", name="mirr1_roll", is_setting=True) +# self._append(SmaractRecord, "SARES23-USR:MOT_14", name="mirr2_pitch", is_setting=True) +# self._append(SmaractRecord, "SARES23-USR:MOT_12", name="mirr2_roll", is_setting=True) # class THzGeneration(Assembly): # def __init__(self, name=None): # super().__init__(name=name) -# self._append(SmaractRecord, "SARES23:LIC16", name="par_x", is_setting=True) -# self._append(SmaractRecord, "SARES23:ESB8", name="mirr_x", is_setting=True) -# self._append(SmaractRecord, "SARES23:ESB7", name="mirr_z", is_setting=True) -# self._append(SmaractRecord, "SARES23:LIC18", name="mirr_ry", is_setting=True) -# self._append(SmaractRecord, "SARES23:ESB9", name="mirr_rz", is_setting=True) -# self._append(SmaractRecord, "SARES23:LIC15", name="polarizer", is_setting=True) +# self._append(SmaractRecord, "SARES23-LIC:MOT_16", name="par_x", is_setting=True) +# self._append(SmaractRecord, "SARES23-USR:MOT_8", name="mirr_x", is_setting=True) +# self._append(SmaractRecord, "SARES23-USR:MOT_7", name="mirr_z", is_setting=True) +# self._append(SmaractRecord, "SARES23-LIC:MOT_18", name="mirr_ry", is_setting=True) +# self._append(SmaractRecord, "SARES23-USR:MOT_9", name="mirr_rz", is_setting=True) +# self._append(SmaractRecord, "SARES23-LIC:MOT_15", name="polarizer", is_setting=True) # class THzVirtualStages(Assembly): @@ -1914,12 +1962,12 @@ namespace.append_obj( # class THz(Assembly): # def __init__(self, name=None): # super().__init__(name=name) -# self._append(SmaractRecord, "SARES23:ESB6", name="par_x", is_setting=True) +# self._append(SmaractRecord, "SARES23-USR:MOT_6", name="par_x", is_setting=True) # self._append(MotorRecord, "SARES20-MF1:MOT_10", name="par_y", is_setting=True) -# self._append(SmaractRecord, "SARES23:LIC13", name="par_z", is_setting=True) -# self._append(SmaractRecord, "SARES23:LIC14", name="par_rx", is_setting=True) -# self._append(SmaractRecord, "SARES23:ESB15", name="par_ry", is_setting=True) -# self._append(SmaractRecord, "SARES23:ESB1", name="delaystage_thz", is_setting=True,) +# self._append(SmaractRecord, "SARES23-LIC:MOT_13", name="par_z", is_setting=True) +# self._append(SmaractRecord, "SARES23-LIC:MOT_14", name="par_rx", is_setting=True) +# self._append(SmaractRecord, "SARES23-USR:MOT_15", name="par_ry", is_setting=True) +# self._append(SmaractRecord, "SARES23-USR:MOT_1", name="delaystage_thz", is_setting=True,) # self._append(DelayTime, self.delaystage_thz, name="delay_thz", is_setting=False, is_display=True,) # self._append(LaserSteering, name="ir_pointing", is_setting=False) # self._append(THzGeneration, name="generation", is_setting=False) @@ -1945,18 +1993,18 @@ namespace.append_obj( # def __init__(self, name=None): # super().__init__(name=name) -# self._append(SmaractRecord, "SARES23:ESB5", name="crystal_ROT", is_setting=True) -# self._append(SmaractRecord, "SARES23:LIC15", name="ir_1_z", is_setting=True) -# self._append(SmaractRecord, "SARES23:LIC13", name="ir_1_Ry", is_setting=True) -# self._append(SmaractRecord, "SARES23:LIC14", name="ir_1_Rx", is_setting=True) -# self._append(SmaractRecord, "SARES23:ESB10", name="ir_2_Rx", is_setting=True) -# self._append(SmaractRecord, "SARES23:ESB7", name="ir_2_Ry", is_setting=True) -# self._append(SmaractRecord, "SARES23:ESB9", name="para_2_x", is_setting=True) -# self._append(SmaractRecord, "SARES23:ESB3", name="thz_mir_x", is_setting=True) -# self._append(SmaractRecord, "SARES23:ESB1", name="thz_mir_z", is_setting=True) -# self._append(SmaractRecord, "SARES23:ESB8", name="thz_mir_Ry", is_setting=True) -# self._append(SmaractRecord, "SARES23:ESB2", name="thz_mir_Rz", is_setting=True) -# self._append(SmaractRecord, "SARES23:ESB6", name="focus_z", is_setting=True) +# self._append(SmaractRecord, "SARES23-USR:MOT_5", name="crystal_ROT", is_setting=True) +# self._append(SmaractRecord, "SARES23-LIC:MOT_15", name="ir_1_z", is_setting=True) +# self._append(SmaractRecord, "SARES23-LIC:MOT_13", name="ir_1_Ry", is_setting=True) +# self._append(SmaractRecord, "SARES23-LIC:MOT_14", name="ir_1_Rx", is_setting=True) +# self._append(SmaractRecord, "SARES23-USR:MOT_10", name="ir_2_Rx", is_setting=True) +# self._append(SmaractRecord, "SARES23-USR:MOT_7", name="ir_2_Ry", is_setting=True) +# self._append(SmaractRecord, "SARES23-USR:MOT_9", name="para_2_x", is_setting=True) +# self._append(SmaractRecord, "SARES23-USR:MOT_3", name="thz_mir_x", is_setting=True) +# self._append(SmaractRecord, "SARES23-USR:MOT_1", name="thz_mir_z", is_setting=True) +# self._append(SmaractRecord, "SARES23-USR:MOT_8", name="thz_mir_Ry", is_setting=True) +# self._append(SmaractRecord, "SARES23-USR:MOT_2", name="thz_mir_Rz", is_setting=True) +# self._append(SmaractRecord, "SARES23-USR:MOT_6", name="focus_z", is_setting=True) # self._append( # MotorRecord, # "SARES20-MF1:MOT_4", @@ -1964,13 +2012,13 @@ namespace.append_obj( # is_setting=True, # is_display=True, # ) -# self._append(SmaractRecord, "SARES23:ESB14", name="focus_x", is_setting=True) -# self._append(SmaractRecord, "SARES23:ESB13", name="focus_Rz", is_setting=True) -# self._append(SmaractRecord, "SARES23:ESB15", name="focus_Ry", is_setting=True) -# self._append(SmaractRecord, "SARES23:ESB11", name="focus_Rx", is_setting=True) -# self._append(SmaractRecord, "SARES23:LIC18", name="thz_wp", is_setting=True) +# self._append(SmaractRecord, "SARES23-USR:MOT_14", name="focus_x", is_setting=True) +# self._append(SmaractRecord, "SARES23-USR:MOT_13", name="focus_Rz", is_setting=True) +# self._append(SmaractRecord, "SARES23-USR:MOT_15", name="focus_Ry", is_setting=True) +# self._append(SmaractRecord, "SARES23-USR:MOT_11", name="focus_Rx", is_setting=True) +# self._append(SmaractRecord, "SARES23-LIC:MOT_18", name="thz_wp", is_setting=True) # self._append( -# SmaractRecord, "SARES23:LIC16", name="delaystage_thz", is_setting=True +# SmaractRecord, "SARES23-LIC:MOT_16", name="delaystage_thz", is_setting=True # ) # self._append(DelayTime, self.delaystage_thz, name="delay_thz", is_setting=True) # self._append( @@ -2041,7 +2089,7 @@ namespace.append_obj( namespace.append_obj( "SmaractController", - "SARES23:LIC", + "SARES23-LIC:MOT_", lazy=True, name="smaract_ust", module_name="eco.motion.smaract", @@ -2049,7 +2097,7 @@ namespace.append_obj( namespace.append_obj( "SmaractController", - "SARES23:ESB", + "SARES23-USR:MOT_", lazy=True, name="smaract_user", module_name="eco.motion.smaract", @@ -2095,7 +2143,7 @@ from ..microscopes import MicroscopeMotorRecord # ) # self._append( # SmaractRecord, -# "SARES23:ESB6", +# "SARES23-USR:MOT_6", # name="horizontal", # is_setting=True, # is_display=True, @@ -2397,7 +2445,7 @@ class Xspect_EH55(Assembly): MotorRecord, "SARES20-MF1:MOT_16", name="y_crystal", is_setting=True ) self._append( - SmaractRecord, "SARES23:ESB17", name="theta_crystal", is_setting=True + SmaractRecord, "SARES23-USR:MOT_17", name="theta_crystal", is_setting=True ) self._append( CameraBasler, @@ -2451,9 +2499,21 @@ class SampleHeaterJet(Assembly): self._append( WagoSensor, pvbase="SARES20-CWAG-GPS01:TEMP-T11", name="sensor_hexapod" ) + self._append( + MpodChannel, + pvbase="SARES21-CPCL-PS7071", + channel_number=5, + name="fan_hexapod_1", + ) + self._append( + MpodChannel, + pvbase="SARES21-CPCL-PS7071", + channel_number=6, + name="fan_hexapod_2", + ) -namespace.append_obj(SampleHeaterJet, name="heater_jet", lazy=True) +#namespace.append_obj(SampleHeaterJet, name="heater_jet", lazy=True) ## sample illumination @@ -2477,20 +2537,9 @@ class IlluminatorsLasers(Assembly): ) + namespace.append_obj(IlluminatorsLasers, name="sample_illumination", lazy=True) -## Timetool feedback -namespace.append_obj( - "Feedback_Timetool", - name="tt_kb_feedback", - pvname="SLAAR21-SPECTT:AT", - control_adj=dummy_adjustable, - lazy=True, - module_name="eco.utilities.feedback", -) - - - ## LIQUID jet setup # from eco.devices_general.wago import AnalogOutput @@ -2559,8 +2608,8 @@ namespace.append_obj( # self._append( # AdjustablePv, "KERNVARIABLES:DELAYBETWEENXFELANDLASER", name="delay" # ) -# self._append(SmaractRecord, "SARES23:ESB18", name="freespace_pitch") -# self._append(SmaractRecord, "SARES23:ESB13", name="freespace_roll") +# self._append(SmaractRecord, "SARES23-USR:MOT_18", name="freespace_pitch") +# self._append(SmaractRecord, "SARES23-USR:MOT_13", name="freespace_roll") # self._append(AnalogOutput, "SARES20-CWAG-GPS01:DAC01", name="shutter1") diff --git a/eco/devices_general/motors.py b/eco/devices_general/motors.py index 6aacd11..80fb3b4 100755 --- a/eco/devices_general/motors.py +++ b/eco/devices_general/motors.py @@ -13,6 +13,7 @@ from ..elements.adjustable import ( update_changes, value_property, ) +from ..devices_general.pv_adjustable import PvRecord from ..elements.detector import DetectorGet from ..epics import get_from_archive from ..utilities.keypress import KeyPress @@ -26,6 +27,7 @@ import numpy as np from .motor_controller import MforceChannel from .detectors import DetectorVirtual from ..epics.detector import DetectorPvData +import json if hasattr(global_config, "elog"): elog = global_config.elog @@ -909,12 +911,450 @@ class MForceSettings(Assembly): self.set_controller_command(f"IS=1,{switch1},{polarity}") self.set_controller_command(f"IS=2,{switch2},{polarity}") +class SmaractSettings(Assembly): + def __init__(self, + pvname, + name=None, + ): + super().__init__(name=name) + self.pvname = pvname + + self._append( + PvRecord, + pvsetname = self.pvname + "_PTYP", + pvreadbackname=self.pvname + "_PTYP_RB", + name="sensor_type_num", + is_setting=True, + ) + self._append( + AdjustablePv, + self.pvname + "_AUTOZERO", + name="autozero_on_homing", + is_setting=True, + ) + self._append( + AdjustablePv, + self.pvname + "_MCLF", + name="max_frequency", + is_setting=True, + ) + + self._append( + AdjustableFS, + file_path="/photonics/home/gac-bernina/eco/configuration/smaract/setting_table", + name="_setting_table", + is_setting=False, + is_display=False, + ) + + def recall(self, stage_alias_or_model=None): + setting_table = self._setting_table() + stages = np.array([(alias, settings["models"]) for alias, settings in setting_table.items()], dtype=object) + if stage_alias_or_model is not None: + if stage_alias_or_model in stages.T[0]: + alias = stage_alias_or_model + else: + idx = [stage_alias_or_model in a for a in stages.T[1]] + if np.sum(idx) == 1: + alias = stages.T[0][idx][0] + if np.sum(idx) > 1: + print("Multiple entries found for model {stage_alias_or_model}. Please check _settings_table") + return + if np.sum(idx ==0 ): + print("No entries found for model {stage_alias_or_model}. Please check _settings_table or model number / alias.") + return + else: + stages = [(alias, settings["models"]) for alias, settings in setting_table.items()] + input_message = "\nSelect the stage to load setting:\n q) quit\n" + input_message += f'{"Idx":>3} {"Alias":<30} {"Models"}\n' + for index, (alias, model) in enumerate(stages): + input_message += f'{index:>3}) {alias:<30} {model}\n' + input_message += 'Input: ' + idx = '' + while idx not in range(len(stages)): + idx = input(input_message) + if idx == 'q': + return + else: + try: + idx = int(idx) + except: + continue + print(f'Selected stage: {stages[idx]}') + alias = stages[idx][0] + stage_settings = setting_table[alias] + if np.any([mcs in self.pvname for mcs in ["SARES23-USR", "SARES23-LIC"]]): + mcs_code = stage_settings["MCS"] + else: + mcs_code = stage_settings["MCS2"] + stage_settings["settings"]["sensor_type_num"] = mcs_code + self.memory.recall(input_obj=stage_settings) + @spec_convenience @update_changes @get_from_archive @value_property class SmaractRecord(Assembly): + def __init__( + self, + pvname, + name=None, + elog=None, + # alias_fields={"readback": "RBV"}, + alias_fields={}, + backlash_definition=False, + expect_bad_limits=True, + ): + super().__init__(name=name) + # self.settings.append(self) + self.settings_collection.append(self, force=True) + + self.pvname = pvname + self._motor = _Motor(pvname) + self._elog = elog + for an, af in alias_fields.items(): + self.alias.append( + Alias(an, channel=".".join([pvname, af]), channeltype="CA") + ) + self._currentChange = None + + self._append( + SmaractSettings, self.pvname, name="motor_parameters", is_setting=False + ) + self._append( + AdjustablePv, self.pvname + ".LLM", name="limit_low", is_setting=True + ) + self._append( + AdjustablePv, self.pvname + ".HLM", name="limit_high", is_setting=True + ) + self._append( + AdjustablePvEnum, + self.pvname + ".STAT", + name="status_flag", + is_setting=False, + is_display=True, + ) + self._append( + AdjustablePv, + self.pvname + ".ACCL", + name="acceleration_time", + is_setting=True, + ) + self._append( + AdjustablePvEnum, self.pvname + ".DIR", name="direction", is_setting=True + ) + self._append(AdjustablePv, self.pvname + ".OFF", name="offset", is_setting=True) + self._append( + AdjustablePv, self.pvname + ".FOFF", name="force_offset", is_setting=True + ) + self._append(AdjustablePv, self.pvname + ".VELO", name="speed", is_setting=True) + + self._append( + AdjustablePv, + self.pvname + ".HOMR", + name="home_forward", + is_setting=False, + is_status=False, + is_display=False, + ) + self._append( + AdjustablePv, + self.pvname + ".HOMR", + name="home_reverse", + is_setting=False, + is_status=False, + is_display=False, + ) + + self._append( + DetectorPvData, + self.pvname + ".RBV", + name="readback", + is_setting=False, + is_display=True, + ) + + self._append( + AdjustablePvEnum, self.pvname + ".SPMG", name="mode", is_setting=False + ) + self._append( + DetectorPvData, self.pvname + ".MSTA", name="_flags", is_setting=False + ) + self._append( + SmaractRecordFlags, + self.pvname, + self._flags, + name="flags", + is_display="recursive", + is_status=True, + ) + + self._append( + AdjustablePvString, self.pvname + ".EGU", name="unit", is_setting=True + ) + self._append( + AdjustablePvString, + self.pvname + ".DESC", + name="description", + is_setting=True, + ) + self._append( + AdjustablePv, + self.pvname + "_CAL", + name="_calibrate_sensor", + is_setting=True, + is_status=False, + is_display=False, + ) + if backlash_definition: + self._append( + AdjustablePv, + self.pvname + ".BVEL", + name="backlash_velocity", + is_setting=True, + ) + self._append( + AdjustablePv, + self.pvname + ".BACC", + name="backlash_acceleration", + is_setting=True, + ) + self._append( + AdjustablePv, + self.pvname + ".BDST", + name="backlash_distance", + is_setting=True, + ) + self._append( + AdjustablePv, + self.pvname + ".FRAC", + name="backlash_fraction", + is_setting=True, + ) + if expect_bad_limits: + self.check_bad_limits() + + def check_bad_limits(self, abs_set_value=2**53): + ll, hl = self.get_limits() + if ll == 0 and hl == 0: + self.set_limits(-abs_set_value, abs_set_value) + + def home(self): + self.home_forward(1) + time.sleep(0.1) + while not self.flags.is_homed.get_current_value(): + time.sleep(0.1) + + def calibrate_sensor(self): + self._calibrate_sensor(1) + time.sleep(0.1) + while not self.flags.motion_complete.get_current_value(): + time.sleep(0.1) + + def set_target_value(self, value, hold=False, check=True): + """Adjustable convention""" + + def changer(value): + self._status = self._motor.move(value, ignore_limits=(not check), wait=True) + self._status_message = _status_messages[self._status] + if self._status < 0: + raise AdjustableError(self._status_message) + elif self._status > 0: + print("\n") + print(self._status_message) + + # changer = lambda value: self._motor.move(\ + # value, ignore_limits=(not check), + # wait=True) + return Changer( + target=value, + parent=self, + changer=changer, + hold=hold, + stopper=self._motor.stop, + ) + + def stop(self): + """Adjustable convention""" + try: + self._currentChange.stop() + except: + self.mode.set_target_value(0) + pass + + def get_current_value(self, posType="user", readback=True): + """Adjustable convention""" + _keywordChecker([("posType", posType, _posTypes)]) + if posType == "user": + return self._motor.get_position(readback=readback) + if posType == "dial": + return self._motor.get_position(readback=readback, dial=True) + if posType == "raw": + return self._motor.get_position(readback=readback, raw=True) + + def reset_current_value_to(self, value, posType="user"): + """Adjustable convention""" + _keywordChecker([("posType", posType, _posTypes)]) + if posType == "user": + return self._motor.set_position(value) + if posType == "dial": + return self._motor.set_position(value, dial=True) + if posType == "raw": + return self._motor.set_position(value, raw=True) + + def get_moveDone(self): + """Adjustable convention""" + """ 0: moving 1: move done""" + return PV(str(self.Id + ".DMOV")).value + + def set_limits( + self, low_limit, high_limit, posType="user", relative_to_present=False + ): + """ + set limits. usage: set_limits(low_limit, high_limit) + + """ + _keywordChecker([("posType", posType, _posTypes)]) + ll_name, hl_name = "LLM", "HLM" + if posType == "dial": + ll_name, hl_name = "DLLM", "DHLM" + if relative_to_present: + v = self.get_current_value(posType=posType) + low_limit = v + low_limit + high_limit = v + high_limit + self._motor.put(ll_name, low_limit) + self._motor.put(hl_name, high_limit) + + def add_value_callback(self, callback, index=None): + return self._motor.get_pv("RBV").add_callback(callback=callback, index=index) + + def clear_value_callback(self, index=None): + if index: + self._motor.get_pv("RBV").remove_callback(index) + else: + self._motor.get_pv("RBV").clear_callbacks() + + def get_limits(self, posType="user"): + """Adjustable convention""" + _keywordChecker([("posType", posType, _posTypes)]) + ll_name, hl_name = "LLM", "HLM" + if posType == "dial": + ll_name, hl_name = "DLLM", "DHLM" + return self._motor.get(ll_name), self._motor.get(hl_name) + + def gui(self): + pv, m = tuple(self.pvname.split(":")) + self._run_cmd(f'caqtdm -macro "P={pv},M=:{m}, T=MCS" /sf/controls/config/qt/motorx_all.ui') + + def gui_extra(self): + pv, m = tuple(self.pvname.split(":")) + self._run_cmd(f'caqtdm -macro "P={pv},M={m}" /ioc/modules/qt/MCS_extra.ui') + + # return string with motor value as variable representation + def __str__(self): + # """ return short info for the current motor""" + s = f"{self.name}" + s += f"\t@ {colorama.Style.BRIGHT}{self.get_current_value():1.6g}{colorama.Style.RESET_ALL} (dial @ {self.get_current_value(posType='dial'):1.6g}; stat: {self.status_flag().name})" + # # s += "\tuser limits (low,high) : {:1.6g},{:1.6g}\n".format(*self.get_limits()) + s += f"\n{colorama.Style.DIM}low limit {colorama.Style.RESET_ALL}" + s += ValueInRange(*self.get_limits()).get_str(self.get_current_value()) + s += f" {colorama.Style.DIM}high limit{colorama.Style.RESET_ALL}" + # # s += "\tuser limits (low,high) : {:1.6g},{1.6g}".format(self.get_limits()) + return s + + def __repr__(self): + print(str(self)) + return object.__repr__(self) + + def __call__(self, value): + self._currentChange = self.set_target_value(value) + + def _tweak_ioc(self, step_value=None): + pv = self._motor.get_pv("TWV") + pvf = self._motor.get_pv("TWF") + pvr = self._motor.get_pv("TWR") + if not step_value: + step_value = pv.get() + print(f"Tweaking {self.name} at step size {step_value}", end="\r") + + help = "q = exit; up = step*2; down = step/2, left = neg dir, right = pos dir\n" + help = help + "g = go abs, s = set" + print(f"tweaking {self.name}") + print(help) + print(f"Starting at {self.get_current_value()}") + step_value = float(step_value) + oldstep = 0 + k = KeyPress() + cll = colorama.ansi.clear_line() + + class Printer: + def print(self, **kwargs): + print( + cll + f"stepsize: {self.stepsize}; current: {kwargs['value']}", + end="\r", + ) + + p = Printer() + print(" ") + p.stepsize = step_value + p.print(value=self.get_current_value()) + ind_callback = self.add_value_callback(p.print) + pv.put(step_value) + while k.isq() is False: + if oldstep != step_value: + p.stepsize = step_value + p.print(value=self.get_current_value()) + oldstep = step_value + k.waitkey() + if k.isu(): + step_value = step_value * 2.0 + pv.put(step_value) + elif k.isd(): + step_value = step_value / 2.0 + pv.put(step_value) + elif k.isr(): + pvf.put(1) + elif k.isl(): + pvr.put(1) + elif k.iskey("g"): + print("enter absolute position (char to abort go to)") + sys.stdout.flush() + v = sys.stdin.readline() + try: + v = float(v.strip()) + self.set_target_value(v) + except: + print("value cannot be converted to float, exit go to mode ...") + sys.stdout.flush() + elif k.iskey("s"): + print("enter new set value (char to abort setting)") + sys.stdout.flush() + v = sys.stdin.readline() + try: + v = float(v[0:-1]) + self.reset_current_value_to(v) + except: + print("value cannot be converted to float, exit go to mode ...") + sys.stdout.flush() + elif k.isq(): + break + else: + print(help) + self.clear_value_callback(index=ind_callback) + print(f"final position: {self.get_current_value()}") + print(f"final tweak step: {pv.get()}") + + def tweak(self, *args, **kwargs): + return self._tweak_ioc(*args, **kwargs) + + +@spec_convenience +@update_changes +@get_from_archive +@value_property +class SmaractRecord_old(Assembly): + #Note: this is the one that works with the old SmarAct IOCs before Thierry made changes in 09/2023 def __init__( self, pvname, diff --git a/eco/endstations/bernina_diffractometers.py b/eco/endstations/bernina_diffractometers.py index aa9e30d..7c32a9d 100644 --- a/eco/endstations/bernina_diffractometers.py +++ b/eco/endstations/bernina_diffractometers.py @@ -845,10 +845,12 @@ class XRDYou(Assembly): kappa_angle=60, degrees=True, bernina_kappa=True, - invert_elbow=False, + invert_elbow=None, ): """tool to convert from you definition angles to kappa angles, in particular the bernina kappa where the""" + if invert_elbow is None: + invert_elbow = self.invert_kappa_ellbow if bernina_kappa: eta = -eta phi = -phi @@ -869,16 +871,16 @@ class XRDYou(Assembly): if bernina_kappa: eta_k = eta_k - np.pi / 2 kappa = -kappa - if False: + if True: def flip_ang(ang): - if 1 < abs(ang // np.pi): + if 2 <= abs(ang // np.pi): return ang - np.sign(ang) * np.pi * 2 else: return ang - # phi_k = flip_ang(phi_k) - phi_k = phi_k + np.pi * 2 + phi_k = flip_ang(phi_k) + # phi_k = phi_k + np.pi * 2 eta_k = flip_ang(eta_k) kappa = flip_ang(kappa) if degrees: @@ -893,8 +895,10 @@ class XRDYou(Assembly): kappa_angle=60, degrees=True, bernina_kappa=True, - invert_elbow=False, + invert_elbow=None, ): + if invert_elbow is None: + invert_elbow = self.invert_kappa_ellbow if degrees: eta_k, kappa, phi_k, kappa_angle = np.deg2rad( [eta_k, kappa, phi_k, kappa_angle] diff --git a/eco/endstations/bernina_sample_environments.py b/eco/endstations/bernina_sample_environments.py index fd6aab6..62fa09f 100644 --- a/eco/endstations/bernina_sample_environments.py +++ b/eco/endstations/bernina_sample_environments.py @@ -43,8 +43,8 @@ class High_field_thz_chamber(Assembly): self.par_out_pos = [35, -9.5] self.motor_configuration = { "rx": { - # "id": "SARES23:ESB13", - "id": "SARES23:ESB6", + # "id": "SARES23-USR:MOT_13", + "id": "SARES23-USR:MOT_6", "pv_descr": "Motor7:1 THz Chamber Rx", "type": 2, "sensor": 1, @@ -53,8 +53,8 @@ class High_field_thz_chamber(Assembly): "kwargs": {"accuracy": 0.01}, }, "x": { - # "id": "SARES23:ESB14", - "id": "SARES23:ESB15", + # "id": "SARES23-USR:MOT_14", + "id": "SARES23-USR:MOT_15", "pv_descr": "Motor7:2 THz Chamber x ", "type": 1, "sensor": 0, @@ -62,8 +62,8 @@ class High_field_thz_chamber(Assembly): "home_direction": "back", }, "z": { - # "id": "SARES23:ESB10", - "id": "SARES23:LIC16", + # "id": "SARES23-USR:MOT_10", + "id": "SARES23-LIC:MOT_16", "pv_descr": "Motor6:1 THz Chamber z ", "type": 1, "sensor": 0, @@ -71,8 +71,8 @@ class High_field_thz_chamber(Assembly): "home_direction": "back", }, "ry": { - # "id": "SARES23:ESB11", - "id": "SARES23:LIC15", + # "id": "SARES23-USR:MOT_11", + "id": "SARES23-LIC:MOT_15", "pv_descr": "Motor6:2 THz Chamber Ry", "type": 2, "sensor": 1, @@ -80,8 +80,8 @@ class High_field_thz_chamber(Assembly): "home_direction": "back", }, "rz": { - # "id": "SARES23:ESB12", - "id": "SARES23:ESB4", + # "id": "SARES23-USR:MOT_12", + "id": "SARES23-USR:MOT_4", "pv_descr": "Motor6:3 THz Chamber Rz", "type": 2, "sensor": 1, @@ -292,7 +292,7 @@ class Organic_crystal_breadboard(Assembly): self.motor_configuration = { "mir_x": { # "id": "-LIC17", - "id": ":ESB8", + "id": "-USR:MOT_8", "pv_descr": "Motor8:2 THz mirror x ", "type": 1, "sensor": 13, @@ -301,7 +301,7 @@ class Organic_crystal_breadboard(Assembly): }, "mir_rz": { # "id": "-LIC18", - "id": ":ESB9", + "id": "-USR:MOT_9", "pv_descr": "Motor8:3 THz mirror rz ", "type": 1, "sensor": 13, @@ -310,7 +310,7 @@ class Organic_crystal_breadboard(Assembly): }, "mir_ry": { # "id": "-ESB1", - "id": ":LIC18", + "id": "-LIC:MOT_18", "pv_descr": "Motor3:1 THz mirror ry ", "type": 2, "sensor": 1, @@ -319,7 +319,7 @@ class Organic_crystal_breadboard(Assembly): }, "mir_z": { # "id": "-LIC16", - "id": ":ESB7", + "id": "-USR:MOT_7", "pv_descr": "Motor8:1 THz mirror z", "type": 1, "sensor": 13, @@ -328,7 +328,7 @@ class Organic_crystal_breadboard(Assembly): }, "par_x": { # "id": "-ESB3", - "id": ":LIC17", + "id": "-LIC:MOT_17", "pv_descr": "Motor3:3 THz parabola2 x", "type": 1, "sensor": 0, @@ -337,7 +337,7 @@ class Organic_crystal_breadboard(Assembly): }, "delaystage_thz": { # "id": "-ESB18", - "id": ":ESB1", + "id": "-USR:MOT_1", "pv_descr": "Motor8:3 NIR delay stage", "type": 1, "sensor": 0, @@ -346,7 +346,7 @@ class Organic_crystal_breadboard(Assembly): }, "nir_m1_ry": { # "id": "-ESB17", - "id": ":ESB3", + "id": "-USR:MOT_3", "pv_descr": "Motor8:2 near IR mirror 1 ry", "type": 2, "sensor": 1, @@ -354,7 +354,7 @@ class Organic_crystal_breadboard(Assembly): "home_direction": "back", }, "nir_m1_rx": { - "id": ":ESB16", + "id": "-USR:MOT_16", "pv_descr": "Motor8:1 near IR mirror 1 rx", "type": 2, "sensor": 1, @@ -363,7 +363,7 @@ class Organic_crystal_breadboard(Assembly): }, "nir_m2_ry": { # "id": "-ESB9", - "id": ":ESB14", + "id": "-USR:MOT_14", "pv_descr": "Motor5:3 near IR mirror 2 ry", "type": 2, "sensor": 1, @@ -371,8 +371,8 @@ class Organic_crystal_breadboard(Assembly): "home_direction": "back", }, "nir_m2_rx": { - # "id": ":ESB4", - "id": ":ESB12", + # "id": "-USR:MOT_4", + "id": "-USR:MOT_12", "pv_descr": "Motor4:1 near IR mirror 2 rx", "type": 1, "sensor": 13, @@ -380,7 +380,7 @@ class Organic_crystal_breadboard(Assembly): "home_direction": "back", }, "crystal": { - "id": ":ESB2", + "id": "-USR:MOT_2", "pv_descr": "Motor3:2 crystal rotation", "type": 2, "sensor": 1, @@ -388,7 +388,7 @@ class Organic_crystal_breadboard(Assembly): "home_direction": "back", }, "wp": { - "id": ":ESB7", + "id": "-USR:MOT_7", "pv_descr": "Motor5:1 waveplate rotation", "type": 2, "sensor": 1, diff --git a/eco/loptics/bernina_laser.py b/eco/loptics/bernina_laser.py index ea3814d..91875e8 100644 --- a/eco/loptics/bernina_laser.py +++ b/eco/loptics/bernina_laser.py @@ -21,9 +21,9 @@ ureg = UnitRegistry() class IncouplingCleanBernina(Assembly): def __init__(self, name=None): super().__init__(name=name) - self._append(SmaractRecord, "SARES23:LIC17", name="tilt") - self._append(SmaractRecord, "SARES23:LIC18", name="rotation") - self._append(SmaractRecord, "SARES23:LIC16", name="transl_vertical") + self._append(SmaractRecord, "SARES23-LIC:MOT_17", name="tilt") + self._append(SmaractRecord, "SARES23-LIC:MOT_18", name="rotation") + self._append(SmaractRecord, "SARES23-LIC:MOT_16", name="transl_vertical") self._append(MotorRecord, "SARES20-MF2:MOT_5", name="transl_horizontal") diff --git a/eco/microscopes/microscopes.py b/eco/microscopes/microscopes.py index 1d0d331..fa72798 100644 --- a/eco/microscopes/microscopes.py +++ b/eco/microscopes/microscopes.py @@ -108,3 +108,40 @@ class OptoSigmaZoom(Assembly): def set_target_value(self, value, **kwargs): return self.zoom.set_target_value(value, **kwargs) + + +@spec_convenience +class FeturaPlusZoom(Assembly): + def __init__( + self, + pv_get_position="SARES20-FETURA:POS_RB", + pv_set_position="SARES20-FETURA:POS_SP", + + name=None, + ): + super().__init__(name=name) + self.settings_collection.append(self) + self._append( + AdjustablePv, + pv_set_position, + pv_get_position, + accuracy=1, + name="zoom_raw", + is_setting=False, + ) + + self._append( + AdjustableVirtual, + [self.zoom_raw], + lambda x: abs(round(x / 1000 * 100) - 100), + lambda x: round(abs(x - 100) / 100 * 1000), + name="zoom", + is_setting=False, + ) + + def get_current_value(self): + return self.zoom.get_current_value() + + def set_target_value(self, value, **kwargs): + return self.zoom.set_target_value(value, **kwargs) + diff --git a/eco/timing/timing_diag.py b/eco/timing/timing_diag.py index 975f949..681cb5d 100644 --- a/eco/timing/timing_diag.py +++ b/eco/timing/timing_diag.py @@ -30,7 +30,7 @@ class TimetoolBerninaUSD(Assembly): spectrometer_pvname="SARES20-CAMS142-M5", microscope_pvname="SARES20-PROF141-M1", delaystage_PV="SLAAR21-LMOT-M524:MOTOR_1", - pvname_mirror="SARES23:LIC9", + pvname_mirror="SARES23-LIC:MOT_9", pvname_zoom="SARES20-MF1:MOT_8", mirror_in=15, mirror_out=-5, diff --git a/eco/utilities/elog_scilog.py b/eco/utilities/elog_scilog.py index e45ab4b..136ece4 100755 --- a/eco/utilities/elog_scilog.py +++ b/eco/utilities/elog_scilog.py @@ -27,7 +27,7 @@ def getDefaultElogInstance( with open(os.path.join(home, ".scilog_psi"), "r") as f: _pw = f.read().strip() except: - print("Enter scilog password for user: %s" % kwargs["user"]) + print(f"Enter scilog password for user: {user}") _pw = _getpass() kwargs.update(dict(password=_pw)) log = SciLog(url, options := {"username": user, "password": kwargs["password"]}) diff --git a/eco/utilities/runtable.py b/eco/utilities/runtable.py index 80fc9de..ac2d1bd 100644 --- a/eco/utilities/runtable.py +++ b/eco/utilities/runtable.py @@ -76,7 +76,8 @@ class Gsheet_API: def _append_to_gspread_key_df(self, gspread_key_df): if os.path.exists(self._keydf_fname): self._key_df = pd.read_pickle(self._keydf_fname) - self._key_df = self._key_df.append(gspread_key_df) + #deprecated: self._key_df = self._key_df.append(gspread_key_df) + self._key_df = pd.concat([self._key_df, gspread_key_df]) self._key_df.to_pickle(self._keydf_fname) else: self._key_df.to_pickle(self._keydf_fname) @@ -100,6 +101,7 @@ class Gsheet_API: {"keys": [spreadsheet.id]}, index=[f"{exp_id}"], ) + print(gspread_key_df) spreadsheet_key = spreadsheet.id self._append_to_gspread_key_df(gspread_key_df) self._spreadsheet_key = spreadsheet_key @@ -490,13 +492,15 @@ class Run_Table_DataFrame(DataFrame): multiindex = pd.MultiIndex.from_tuples( [(dev, adj) for dev in dat.keys() for adj in dat[dev].keys()], names=names ) - values = np.array([val for adjs in dat.values() for val in adjs.values()]) + values = np.array([val for adjs in dat.values() for val in adjs.values()], dtype=object) index = np.array( [f"{dev}.{adj}" for dev, adjs in dat.items() for adj in adjs.keys()] ) # run_df = DataFrame([values], columns=multiindex, index=[runno]) run_df = DataFrame([values], columns=index, index=[runno]) - self.df = self.append(run_df) + #deprecated: self.df = self.append(run_df) + self.df = pd.concat([self.df, run_df]) + self._remove_duplicates() # self.order_df() self.save() @@ -517,14 +521,15 @@ class Run_Table_DataFrame(DataFrame): multiindex = pd.MultiIndex.from_tuples( [(dev, adj) for dev in dat.keys() for adj in dat[dev].keys()], names=names ) - values = np.array([val for adjs in dat.values() for val in adjs.values()]) + values = np.array([val for adjs in dat.values() for val in adjs.values()], dtype=object) index = np.array( [f"{dev}.{adj}" for dev, adjs in dat.items() for adj in adjs.keys()] ) # pos_df = DataFrame([values], columns=multiindex, index=[f"p{posno}"]) pos_df = DataFrame([values], columns=index, index=[f"p{posno}"]) - self.df = self.append(pos_df) + #deprecated: self.df = self.append(pos_df) + self.df = pd.concat([self.df,pos_df]) self._remove_duplicates() # self.order_df() self.save() diff --git a/eco/xdiagnostics/profile_monitors.py b/eco/xdiagnostics/profile_monitors.py index 1e559e5..873bcc8 100755 --- a/eco/xdiagnostics/profile_monitors.py +++ b/eco/xdiagnostics/profile_monitors.py @@ -108,7 +108,7 @@ class ProfKbBernina(Assembly): pvname_target_x="SARES20-MF2:MOT_1", pvname_target_y="SARES20-MF2:MOT_2", pvname_target_z="SARES20-MF2:MOT_3", - pvname_mirror="SARES23:LIC11", + pvname_mirror="SARES23-LIC:MOT_11", mirror_in=15, mirror_out=-5, pvname_zoom="SARES20-MF2:MOT_4", diff --git a/eco/xoptics/att_usd.py b/eco/xoptics/att_usd.py index ec56b0c..7b4e56d 100644 --- a/eco/xoptics/att_usd.py +++ b/eco/xoptics/att_usd.py @@ -21,8 +21,8 @@ class Att_usd(Assembly): self.E = None self.E_min = 1500 self._sleeptime = 1 - self._append(SmaractRecord, "SARES23:LIC10", name="transl_2", is_setting=True, is_display=True) - self._append(SmaractRecord, "SARES23:LIC3", name="transl_1", is_setting=True, is_display=True) + self._append(SmaractRecord, "SARES23-LIC:MOT_10", name="transl_2", is_setting=True, is_display=True) + self._append(SmaractRecord, "SARES23-LIC:MOT_3", name="transl_1", is_setting=True, is_display=True) self.motor_configuration = { "transl_2": { "id": "SARES23-LIC10", diff --git a/eco/xoptics/reflaser.py b/eco/xoptics/reflaser.py index 28464b7..726c5b5 100644 --- a/eco/xoptics/reflaser.py +++ b/eco/xoptics/reflaser.py @@ -10,7 +10,7 @@ from ..elements.assembly import Assembly class RefLaser_BerninaUSD(Assembly): def __init__( self, - pvname_mirrortranslation="SARES23:LIC12", + pvname_mirrortranslation="SARES23-LIC:MOT_12", pvname_onoff="SARES21-CPCL-PS7071:LV_OMPV_1_CH1_SWITCH_SP", elog=None, name=None,