Skip to content

Instantly share code, notes, and snippets.

@bruceravel
bruceravel / CCUheater.py
Created November 17, 2025 16:05
simple code for running Anton-Parr temperature controller
"""Modbus client for CCU100 heating stage control unit.
Protocol Modbus RTU
Baud rate 9600
Parity none
Address 1 *
"""
import serial # pip install pyserial (not serial)
import minimalmodbus
@bruceravel
bruceravel / md.txt
Created July 23, 2025 13:34
example metadata from a record at BMM
{'start': {'XDI': {'Beamline': {'collimation': 'paraboloid mirror, 5 nm Rh on '
'30 nm Pt',
'focusing': 'not in use',
'harmonic_rejection': 'flat mirror, Pt stripe, '
'pitch = 7.0 mrad '
'relative to beam',
'name': 'BMM (06BM) -- Beamline for Materials '
'Measurement (NIST)',
'software': 'Bluesky 1.13.0a4, Ophyd 1.9.0, '
'DataBroker 2.0.0b45, Python '
This file has been truncated, but you can view the full file.
BMM A.111 [6] ▶ RE(count([xs], 105))
13:54:24.010 -> (1.5 KB) POST 'https://tiled.nsls2.bnl.gov/api/v1/documents/bmm/raw' 'host:tiled.nsls2.bnl.gov' 'accept:*/*' 'connection:keep-alive' 'accept-encoding:gzip, deflate, br, blosc2, zstd' 'user-agent:python-tiled/0.1.0b6' 'cookie:tiled_csrf=szfOAbBpD8BottyDwWC82OQ4_zeOEpnxMBTCwcXJ5Aw' 'content-length:1540' 'authorization:Apikey [redacted]'
DEBUG [2025-05-20 13:54:24]: -> (1.5 KB) POST 'https://tiled.nsls2.bnl.gov/api/v1/documents/bmm/raw' 'host:tiled.nsls2.bnl.gov' 'accept:*/*' 'connection:keep-alive' 'accept-encoding:gzip, deflate, br, blosc2, zstd' 'user-agent:python-tiled/0.1.0b6' 'cookie:tiled_csrf=szfOAbBpD8BottyDwWC82OQ4_zeOEpnxMBTCwcXJ5Aw' 'content-length:1540' 'authorization:Apikey [redacted]'
Transient Scan ID: 24734 Time: 2025-05-20 13:54:24
Persistent Unique Scan ID: '7aa14d73-537a-4283-90fc-ec45684b1430'
13:54:24.061 <- (4 B) 200 date:Tue, 20 May 2025 17:54:23 GMT server:uvicorn content-length:4 content-type:application/json server-timing:acl;d
IPython profile: collection
[TerminalIPythonApp] WARNING | Unknown error in handling startup files:
---------------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last)
File /nsls2/conda/envs/2024-3.0-py311-tiled/lib/python3.11/site-packages/IPython/core/shellapp.py:403, in InteractiveShellApp._exec_file(self, fname, shell_futures)
399 self.shell.safe_execfile_ipy(full_filename,
400 shell_futures=shell_futures)
401 else:
402 # default to python, even without extension
--> 403 self.shell.safe_execfile(full_filename,
@bruceravel
bruceravel / gist:74843adeb5d0008b2935ffc0aef2f653
Created February 25, 2025 19:38
times between points in a recent XAS scan at BMM
array([ 1.37635756, 17.49025273, 3.833498 , 1.67792225, 1.54994631,
1.47975302, 3.23309135, 4.90390778, 10.4118824 , 2.1637888 ,
1.48665547, 1.41370559, 3.46452117, 3.237046 , 4.4332459 ,
1.7141912 , 2.16617203, 4.8595078 , 2.93162584, 2.85146952,
4.03303218, 2.47895312, 1.69863939, 2.38391447, 1.69642735,
1.34901834, 1.55031991, 2.64722466, 2.25259304, 1.79285002,
1.45427632, 5.26443172, 13.37482214, 11.39499688, 15.1583252 ,
18.21612263, 12.73066545, 15.25344563, 14.51086259, 15.06101155,
17.71586776, 15.1520071 , 3.55273771, 2.32369161, 1.66594267,
1.83460283, 1.42996216, 1.41853666, 1.44647622, 1.45678329,
@bruceravel
bruceravel / gist:3891b573d2981b67b71ba0601f89eef0
Created September 17, 2024 17:07
mapping of XAS data file to HDF5 files, July 2024
Eu_LiClKCl_1percentEu_CCA_1.001 -->
/nsls2/data3/bmm/proposals/2024-2/pass-314552/assets/xspress3-1/2024/07/12/319294ba-d000-4fb2-9d9e_000000.h5
Eu_LiClKCl_1percentEu_CCA_1.002 -->
/nsls2/data3/bmm/proposals/2024-2/pass-314552/assets/xspress3-1/2024/07/12/bcf34845-3c93-475b-bc56_000000.h5
Eu_LiClKCl_1percentEu_CCA_1.004 -->
/nsls2/data3/bmm/proposals/2024-2/pass-314552/assets/xspress3-1/2024/07/12/4c54894d-8df8-4682-b697_000000.h5
Eu_LiClKCl_1percentEu_CCA_1.005 -->
[TerminalIPythonApp] WARNING | Unknown error in handling startup files:
---------------------------------------------------------------------------
FileNotFoundError Traceback (most recent call last)
File /nsls2/conda/envs/2024-2.3-py310-tiled/lib/python3.10/site-packages/IPython/core/shellapp.py:359, in InteractiveShellApp._exec_file(self, fname, shell_futures)
355 self.shell.safe_execfile_ipy(full_filename,
356 shell_futures=shell_futures)
357 else:
358 # default to python, even without extension
--> 359 self.shell.safe_execfile(full_filename,
360 self.shell.user_ns,
[E 2024-06-10 20:09:47,318.318 bluesky run_engine:1686] Run aborted
Traceback (most recent call last):
File "/nsls2/conda/envs/2024-2.0-py310-tiled/lib/python3.10/site-packages/httpx/_transports/default.py", line 69, in map_httpcore_exceptions
yield
File "/nsls2/conda/envs/2024-2.0-py310-tiled/lib/python3.10/site-packages/httpx/_transports/default.py", line 233, in handle_request
resp = self._pool.handle_request(req)
File "/nsls2/conda/envs/2024-2.0-py310-tiled/lib/python3.10/site-packages/httpcore/_sync/connection_pool.py", line 216, in handle_request
raise exc from None
File "/nsls2/conda/envs/2024-2.0-py310-tiled/lib/python3.10/site-packages/httpcore/_sync/connection_pool.py", line 196, in handle_request
response = connection.handle_request(
@bruceravel
bruceravel / gist:36c442eb5b9c438f7e13fffaf19bb132
Created February 5, 2024 16:03
second core dump capture
BMM XRD.111 [5] ▶ Fatal Python error: Segmentation fault
Thread 0x00007ff64a67d700 (most recent call first):
<no Python frame>
Thread 0x00007ff1edfdc700 (most recent call first):
File "/nsls2/conda/envs/2023-2.1-py310-tiled/lib/python3.10/selectors.py", line 469 in select
File "/nsls2/conda/envs/2023-2.1-py310-tiled/lib/python3.10/site-packages/prompt_toolkit/eventloop/inputhook.py", line 115 in run_selector
File "/nsls2/conda/envs/2023-2.1-py310-tiled/lib/python3.10/threading.py", line 953 in run
File "/nsls2/conda/envs/2023-2.1-py310-tiled/lib/python3.10/threading.py", line 1016 in _bootstrap_inner
File "/nsls2/conda/envs/2023-2.1-py310-tiled/lib/python3.10/site-packages/dask/local.py", line 224 in execute_task
File "/nsls2/conda/envs/2023-2.1-py310-tiled/lib/python3.10/site-packages/dask/local.py", line 238 in <listcomp>
File "/nsls2/conda/envs/2023-2.1-py310-tiled/lib/python3.10/site-packages/dask/local.py", line 238 in batch_execute_tasks
File "/nsls2/conda/envs/2023-2.1-py310-tiled/lib/python3.10/concurrent/futures/thread.py", line 58 in run
File "/nsls2/conda/envs/2023-2.1-py310-tiled/lib/python3.10/concurrent/futures/thread.py", line 83 in _worker
File "/nsls2/conda/envs/2023-2.1-py310-tiled/lib/python3.10/threading.py", line 953 in run
File "/nsls2/conda/envs/2023-2.1-py310-tiled/lib/python3.10/threading.py", line 1016 in _bootstrap_inner
File "/nsls2/conda/envs/2023-2.1-py310-tiled/lib/python3.10/threading.py", line 973 in _bootstrap
Thread 0x00007fef8bfff700 (most recent call first):