mx/experiment_jfj.py: slic GUI recording the Cristallina-Q 1.5M with JungfrauJoch

JFJAcquisition + JFJ tab from swissmx_tools/jfj; sf-daq records BS/PV only.
Runs in the crmx-tools env; pgroup p23610 for the JFJ tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
John Henry BealeandClaude Opus 5.5 committed 2026-11-18 11:24:44 +01:00
1 parent 012ce4f2ca
commit e685edfa28
1 file changed
+135
+135
View File
@@ -0,0 +1,135 @@
#!/usr/bin/env python
"""
slic GUI that records a JUNGFRAU with JungfrauJoch (JFJ) and BS channels / PVs with sf-daq.
Based on mx_experiment.py (devices and shortcuts dropped); the JFJ side lives in
/sf/cristallina/applications/mx/swissmx_tools/jfj (jfj_acquisition.py, jfj_panel.py).
Detector: JF16T03V02, the Cristallina-Q 1.5M (3 modules). JFJ broker: http://sf-daq-2:8080, config /opt/jfjoch/etc/broker.json.
Run with the crmx-tools env:
/sf/cristallina/config/python/.pixi/envs/crmx-tools/bin/python -i experiment_jfj.py
>>> jfjgui() # opens the window (JFJ tab first)
In the JFJ tab:
1. "Take control" selects JF16T03V02 in JFJ and initialises it (interrupts JFJ for anybody else,
e.g. SwissMX on the 8M: select CrMX again in JFJ when done)
2. "JFJ Pedestal!" with the beam off
3. fill energy / distance / beam centre (transmission is read from PVs if left empty), Start
Start from the Static/SFX/scan tabs uses the same JFJ settings.
"""
import sys
import os
from loguru import logger
# cristallina slic modules (channels, ...) and the JFJ acquisition/panel
sys.path.insert(0, "/sf/cristallina/applications/slic/cristallina")
sys.path.insert(0, "/sf/cristallina/applications/mx/swissmx_tools/jfj")
def setup_general_logging():
logger.remove()
logger.add(sys.stderr, format="{time:YYYY-MM-DD at HH:mm:ss} | {level} | {message}", level="INFO")
logger.info("Loading started.")
try:
logger.add(
"/sf/cristallina/applications/beamline/snapshots/slic_logs/cristallina_jfj.log",
format="{time:YYYY-MM-DD at HH:mm:ss} | {level} | {message}",
level="DEBUG",
rotation="1 week",
)
logger.info("Logging to snapshots.")
except PermissionError as e:
logger.warning("Cannot write log file to snapshots.")
logger.warning(e)
def setup_logging_pgroup(pgroup, level="INFO"):
try:
logger.add(
f"/sf/cristallina/data/{pgroup}/scratch/slic.log",
format="{time:YYYY-MM-DD at HH:mm:ss} | {level} | {message}",
level=level,
rotation="1 week",
)
logger.info(f"Logging to pgroup {pgroup}.")
except PermissionError:
logger.warning(f"Cannot write log file to pgroup {pgroup}.")
setup_general_logging()
from slic.gui import GUI
# the slic installed in crmx-tools lacks gui/icon.png: use the one from the slic-package checkout
import wx
import slic.gui.daqframe
SLIC_ICON = "/sf/cristallina/applications/slic/slic-package/slic/gui/icon.png"
slic.gui.daqframe.get_wx_icon = lambda: wx.Icon(SLIC_ICON) if os.path.exists(SLIC_ICON) else wx.NullIcon
from slic.core.condition import PVCondition
from slic.core.scanner import Scanner
from slic.core.acquisition.detcfg import DetectorConfig
from channels.bs_channels import bs_channels
from channels.pv_channels import pv_channels
from jfj_acquisition import JFJAcquisition
from jfj_panel import JFJPanel
################# DAQ Setup #################
instrument = "cristallina"
pgroup = "p23610"
JFJ_URL = "http://sf-daq-2:8080"
JFJ_DETECTOR = "JF16T03V02" # Cristallina-Q 1.5M (2 modules in JFJ for now)
DRY_RUN = False # True: nothing is sent to JFJ or sf-daq (status reads still work)
setup_logging_pgroup(pgroup)
# sf-daq records no JUNGFRAU here: the 1.5M goes to JFJ, and the 8M must not be
# recorded by sf-daq while its network settings belong to JFJ
sfdaq_detectors = DetectorConfig()
# used when the field in the JFJ tab is left empty (same PVs as SwissMX uses)
metadata_pvs = {
"transmission": ["SARFE10-OATT053:UsrRec.TD", "SAROP31-OATA150:UsrRec.TD"], # product is used
}
jfjdaq = JFJAcquisition(
instrument,
pgroup,
jfj_url=JFJ_URL,
jfj_detector=JFJ_DETECTOR,
metadata_pvs=metadata_pvs,
dry_run=DRY_RUN,
default_channels=bs_channels,
default_pvs=pv_channels,
default_detectors=sfdaq_detectors,
rate_multiplicator=1,
append_user_tag_to_data_dir=True,
)
# new EPICS buffer: make sure PVs are taken from the right place
try:
jfjdaq.update_config_pvs()
except Exception as e:
logger.warning(f"error updating config pvs for jfjdaq: {e}")
check_intensity_gas_monitor = PVCondition(
"SARFE10-PBPG050:PHOTON-ENERGY-PER-PULSE-US",
vmin=4,
vmax=2000,
wait_time=0.5,
required_fraction=0.8,
)
jfjscan = Scanner(default_acquisitions=[jfjdaq], condition=check_intensity_gas_monitor)
jfjgui = GUI(
jfjscan,
title="Cristallina JFJ (JF16T03V02)",
show_goto=False, show_spec=False, show_scan=True, show_scan2D=False, show_run=False, show_static=True, show_sfx=False,
extras={"JFJ": JFJPanel},
start_tab="JFJ",
)