Skip to content

Instantly share code, notes, and snippets.


Dan Allan danielballan

View GitHub Profile
danielballan /
Created Aug 6, 2021
Bluesky Widgets Demo Quickstart

Bluesky Widgets Demo Quickstart

danielballan /
Created Jul 17, 2021
MVP for Qt RemoteDispatcher

Terminal 1:

bluesky-0MQ-proxy 5567 5568

Terminal 2:

danielballan /
Last active Feb 24, 2021
IOC connection time analysis

IOC connection time analysis

We will use caproto-shark to analyze CA network traffic. Note that the actual servers and clients involve may or may not be using caproto themselves; it does not matter.

  1. Install caproto and pandas if they are not already installed.

    pip install caproto[standard] pandas
danielballan /
Created Jan 28, 2021
Logging optimizations galaxy brain

Logging optimizations

We will examine the byte code to get a sense of how much work the interpreter is doing.


>>> import logging
>>> logger = logging.getLogger()
>>> from dis import dis
danielballan /
Last active Jan 11, 2021 — forked from AbbyGi/
APS 4-ID POLAR bluesky-widgets example
from bluesky_widgets.models.auto_plot_builders import AutoPlotter
from bluesky_widgets.models.plot_builders import Lines
from bluesky_widgets.models.plot_specs import AxesSpec, FigureSpec
from bluesky_widgets.qt.figures import QtFigures
import databroker
import numpy as np
def xanes(monitor, detector):
absorption = np.log(np.array(monitor) / np.array(detector)).reshape(-1, 4)
from ophyd.epics_motor import EpicsMotor, required_for_connection, motor_done_move, AlarmSeverity
def _move_changed(self, timestamp=None, value=None, sub_type=None,
'''Callback from EPICS, indicating that movement status has changed'''
was_moving = self._moving
danielballan /
Created Dec 17, 2020
Data processing inside a plan, involving externally-stored data (e.g. images)
from ophyd.sim import img as detector
from bluesky.plan_stubs import open_run, stage, unstage, close_run, trigger_and_read, subscribe, unsubscribe
from bluesky_live.bluesky_run import BlueskyRun, DocumentCache
def plan():
Take 10 shots with a detector and do some data processing on the result.
Key points
danielballan /
Last active Nov 11, 2020
Area Detector + ophyd test harness

Run Area Detector

Start the container interactively.

sudo podman run -it --rm --name=area-detector -e AD_PREFIX=13SIM1: -p 5064:5064 -v /tmp:/tmp prjemian/synapps-6.1-ad-3.7:latest

In the container's shell:

danielballan /
Last active Oct 29, 2020
Patch databroker to enable reading PDF TIFFs lazily
from databroker import Broker
db = Broker.named('pdf')
# Ooverride the dask-coersion code with an improved version
# that deals with the incomplete or wrong shape metadata from ophyd.
# This is proposed to be added to databroker in
import dask
import dask.array
danielballan / example.ipynb
Last active Oct 19, 2020
New BlueskyRun work
View example.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.