From ba6129ede7cc63a796308278bfb75843f4a6b8fc Mon Sep 17 00:00:00 2001 From: Alexander Steppke Date: Tue, 25 Nov 2025 15:32:52 +0100 Subject: [PATCH] cleanup --- cristallina.py | 77 ++++---------------------------------------------- 1 file changed, 6 insertions(+), 71 deletions(-) diff --git a/cristallina.py b/cristallina.py index 87d09e0..7b97be2 100755 --- a/cristallina.py +++ b/cristallina.py @@ -38,7 +38,6 @@ def setup_general_logging(): def setup_logging_pgroup(pgroup, level="INFO"): try: logger.add( -# f"/sf/cristallina/data/{pgroup}/scratch/slic.log", f"/sf/cristallina/data/{pgroup}/res/slic.log", format="{time:YYYY-MM-DD at HH:mm:ss} | {level} | {message}", level=level, @@ -179,9 +178,6 @@ except Exception as e: dilution = None -# MX adjustables -# import mx.mx_adjustables - # Temporary quick hack thermometer addition for stand #TODO: make in a thermometer class ... T_reg = PVAdjustable('SARES31-DIL-LS1:A_KELVIN') @@ -189,20 +185,21 @@ T_plato = PVAdjustable('SARES31-DIL-LS1:7_KELVIN') T_chip = PVAdjustable('SARES31-DIL-LS1:8_KELVIN') - # TODO: better attenuators upstream_transmission = PVAdjustable("SAROP31-OATA150:UsrRec.TC1") downstream_transmission = PVAdjustable("SARFE10-OATT053:UsrRec.TC1") - # from crq_exp.puma import Puma # puma = Puma() +# temporary mono +# from exp_temp.mono import Mono_rotation + + ################# Stand setup ################## -# TODO: requires the stand client, need small howto how to start and configure or let it run all the time from slic.core.acquisition.detcfg import DetectorConfig from slic.core.acquisition.spreadsheet import Spreadsheet from stand.time import Time @@ -248,8 +245,6 @@ if dilution is not None: adjs_for_spreadsheet.update(adjs_dilsc) -# temporary mono -from exp_temp.mono import Mono_rotation # setup spreadsheet for transmission to stand @@ -266,13 +261,12 @@ try: stand_host = "saresc-vcons-02.psi.ch" stand_client = Client(host=stand_host, port=9090) response = stand_client.get() - logger.info("Connected to stand server") + logger.info("Connected to stand server.") except Exception as error: # catching excpetions with a broad net because different connection errors can occur. logger.warning(f"Cannot connect to stand server on {stand_host}. Disabling spreadsheet.") spreadsheet = None -# spreadsheet = Spreadsheet(adjs, placeholders=PLACEHOLDERS, host="127.0.0.1", port=8080)) ################# DAQ Setup ################# instrument = "cristallina" @@ -363,7 +357,7 @@ from crq_exp import synchronization temperature_setpoint=PVAdjustable('SARES31-DIL-LS1:H0_SETP_SET') # d fixed to 3.0 mm, x_0 = 4.574 mm and theta_0 = -67.853 deg -import numpy as np + # d = 3 # theta_0 = -67.853 @@ -416,62 +410,3 @@ daq_1p5M_I0 = SFAcquisition( rate_multiplicator=1, spreadsheet=spreadsheet) - - - -def scan_with_sync(adjustable, start_pos, end_pos, step_size, n_pulses, filename, acquisitions = [daq], return_to_initial_values=False, condition=check_intensity_gas_monitor, spreadsheet=spreadsheet): - """ - Convenience function to make scans when pulse tube synchronisation is used. - """ - positions = nice_arange(start_pos, end_pos, step_size) - scaninfo = ScanInfo(filename, "scan_info", [adjustable], positions) - assert len(acquisitions) == 1, f"Only one acquisition can be given for one run. Now {acquisitions} were given." - - for i, position in enumerate(tqdm(positions)): - # Go to the position and save readback - adjustable.set_target_value(position).wait() - readback = adjustable.get_current_value() - scaninfo.append([position], [readback], None, None) - - - if condition is not None: - successful_acquisition = False - - while not successful_acquisition: - condition.clear_and_start_counting() - - try: - # Measure the step and save the pids - # It's done with try because every now and then the pids are not retrieved and the step should be repeated. - pids = synchronization.start_sequence(n_pulses) - scan_info_d = scaninfo.to_sfdaq_dict() - successful_acquisition = check_intensity_gas_monitor.stop_counting_and_analyze() - except KeyboardInterrupt: - print('Aborting.') - break - except: - successful_acquisition = False - - else: - # Measure the step and save the pids - pids = synchronization.start_sequence(n_pulses) - scan_info_d = scaninfo.to_sfdaq_dict() - - - # Retrieve data - # First step needs to be made separately, because a run number can't be given to sfdaq until the folder is created. - if i == 0: - for acquisition in acquisitions: - first_step = acquisition.retrieve(filename, pulseids=pids, scan_info=scan_info_d) - run_number= first_step['run_number'] - else: - for acquisition in acquisitions: - acquisition.retrieve(filename, pulseids=pids, run_number=run_number, scan_info=scan_info_d) - - if return_to_initial_values: - adjustable.set_target_value(start_pos).wait() - - # Write to stand table - stand_client.add_row(run=str(run_number), filename=filename, n_pulses=str(n_pulses), sync="True", **spreadsheet.get_adjs_values()) - - print(f"Scan {run_number} finished")