Other features#
Electronic logbook#
IcatClient can be used to send messages and images to beamline and experiment session logbooks.
Getting an IcatClient instance
From the current BLISS session:
from bliss import current_session
icat_client = current_session.scan_saving.icat_client
or create an IcatClient:
from pyicat_plus.client.main import IcatClient
API_KEY = "" # Replace with your API key
ENDPOINT_URL = "https://icatplus.esrf.fr"
client = IcatClient(elogbook_url=ENDPOINT_URL, elogbook_token=API_KEY)
Send a message to the beamline logbook
BEAMLINE = "ID00"
TAGS = ["test"]
# Send a text message
client.send_message(
msg="This is a message to the beamline logbook",
beamline=BEAMLINE,
beamline_only=True,
tags=TAGS,
)
# Send an image or a file
client.send_binary_file(
filename="/path/to/file.png", # Replace with your file
beamline=BEAMLINE,
beamline_only=True,
tags=TAGS,
)
Send a message to the experiment session logbook
PROPOSAL = "id002510"
# Send a text message
client.send_message(
msg="This is a message to the experiment session logbook",
beamline=BEAMLINE,
proposal=PROPOSAL,
tags=TAGS,
)
# Send an image or a file
client.send_binary_file(
filename="/path/to/file.png", # Replace with your file
beamline=BEAMLINE,
proposal=PROPOSAL,
tags=TAGS,
)
To log to the electronic logbook from BLISS, see the BLISS documentation.
Authenticated access#
Using SSO:
from pyicat_plus.client.main import IcatClient
URL = "https://icatplus.esrf.fr/"
sso_token = "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9..."
icatClient = IcatClient(icatplus_restricted_url=URL)
icatClient.do_log_in(sso_token)
Using another authentication plugin:
from pyicat_plus.client.main import IcatClient
URL = "https://icatplus.esrf.fr/"
icatClient = IcatClient(icatplus_restricted_url=URL)
icatClient.do_log_in(password="****", username="daiquiri", plugin="db")
Example: retrieve sample metadata
from datetime import date
metadata = icatClient.get_sample_metadata_by(
proposal="hg237", beamline="id13", session_start_date=date(2025, 7, 24)
)
print(metadata)