Skip to content

Instantly share code, notes, and snippets.

Avatar

Dan Allan danielballan

View GitHub Profile
@danielballan
danielballan / download_ftp_tree.py
Last active Sep 12, 2021 — forked from Jwely/download_ftp_tree.py
recursive ftp directory downloader with python
View download_ftp_tree.py
import argparse
import ftplib
import os
import tqdm
import time
"""
Example usage as a CLI:
```
@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 / camera_device.py
Last active Jul 4, 2021
BMM camera ophyd integration
View camera_device.py
import os
import uuid
import threading
import itertools
import requests
from ophyd import Device, Component, Signal, DeviceStatus
from ophyd.areadetector.filestore_mixins import resource_factory
# See for resource_factory docstring
View _README.md

Replay

Replay documents from a bluesky run with realistic time spacing.

Example

This example acquires data with bluesky, saves the documents to disk, accesses the data using databroker, and finally uses replay to push the documents into a LiveTable callback.

@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