Skip to content

Instantly share code, notes, and snippets.

Avatar

Dan Allan danielballan

View GitHub Profile
@danielballan
danielballan / README.md
Created Aug 6, 2021
Bluesky Widgets Demo Quickstart
View README.md

Bluesky Widgets Demo Quickstart

@danielballan
danielballan / README.md
Created Jul 17, 2021
MVP for Qt RemoteDispatcher
View README.md

Terminal 1:

bluesky-0MQ-proxy 5567 5568

Terminal 2:

python publisher.py
@danielballan
danielballan / README.md
Last active Feb 24, 2021
IOC connection time analysis
View README.md

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
danielballan / logging-optimizations.md
Created Jan 28, 2021
Logging optimizations galaxy brain
View logging-optimizations.md

Logging optimizations

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

Setup

>>> import logging
>>> logger = logging.getLogger()
>>> from dis import dis
@danielballan
danielballan / aps_polar_example.py
Last active Jan 11, 2021 — forked from AbbyGi/README.md
APS 4-ID POLAR bluesky-widgets example
View aps_polar_example.py
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)
View patched_epics_motor.py
from ophyd.epics_motor import EpicsMotor, required_for_connection, motor_done_move, AlarmSeverity
PatchedEpicsMotor(EpicsMotor):
@required_for_connection
@motor_done_move.sub_value
def _move_changed(self, timestamp=None, value=None, sub_type=None,
**kwargs):
'''Callback from EPICS, indicating that movement status has changed'''
was_moving = self._moving
@danielballan
danielballan / example.py
Created Dec 17, 2020
Data processing inside a plan, involving externally-stored data (e.g. images)
View example.py
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
danielballan / README.md
Last active Nov 11, 2020
Area Detector + ophyd test harness
View README.md

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
danielballan / patch_databroker_for_lazy_filling.py
Last active Oct 29, 2020
Patch databroker to enable reading PDF TIFFs lazily
View patch_databroker_for_lazy_filling.py
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
# https://github.com/bluesky/databroker/pull/596/.
import dask
import dask.array
@danielballan
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.