Leverage the SciPy Ecosystem

Bluesky enables scientists to leverage the scientific Python ecosystem at every stage of the experiment from data acquisition through data analysis.

Credit: Jake vanderPlas, "The Unexpected Effectiveness of Python in Science", PyCon 2017

Individually Useful Components

The scientific Python ecosystem is built on protocols, such as Numpy's array protocol, that enable software to be combined and repurposed in ways not foreseen by the original authors.

Drawing inspiration from this, the software libraries in the Bluesky Project interoperate through carefully-defined software interfaces. Any given piece may be separately used, extended, or replaced.


Bluesky — Experiment Specification & Orchestration

Bluesky, a library that shares the name of the overall project, is an experiment specification and orchestration engine.

  • Specify the logic of an experiment in a high-level, hardware-abstracted way.
  • First-class support for adaptive feedback between analysis and acquisition.
  • Data is emitted in a streaming fashion in standard Python data structures.
  • Pause/resume, robust error handling, and rich metadata capture are built in.
Learn about Bluesky »

Ophyd — Hardware Abstraction Layer

Ophyd puts the control layer (e.g. EPICS, HTTP, some serial protocol) behind a high-level interface. It keeps device-specific details contained.

  • Put the control layer behind a high-level interface.
  • Group individual signals into logical "Devices" to be configured and used as one unit.
  • Assign signals and devices human-friendly names that propagate into metadata.
  • Categorize signals by "kind" (primary reading, configuration, engineering/debugging).
Learn about Ophyd »
from ophyd import Device, Component, EpicsSignal

# Here we group signals into a Device

class XYStage(Device):
    x = Component(EpicsSignal, 'Mtr-X')
    y = Component(EpicsSignal, 'Mtr-Y')

# and connect to multiple instances
# of that device.

left_stage  = XYStage('Left-', name='left_stage')
right_stage = XYStage('Right-', name='right_stage')

Ophyd Async — Asynchronous Hardware Abstraction Layer

Ophyd Async is an alternative option to Ophyd that uses asynchronous logic to access the control layer, as well as implementing new features such as EPICS pva access via the p4p python package.

Ophyd Async is included on a provisional basis until the v1.0 release. Learn about Ophyd Async »
from ophyd_async.core import Device, DeviceCollector
from ophyd_async.epics.demo import Mover
from bluesky import RunEngine

# Here we group signals into a device

class SampleStage(Device):
    """A demo sample stage with X and Y movables"""

    def __init__(self, prefix: str, name="") -> None:
        # each 'mover' contains epics signals like its velocity, units and precision.
        self.x = Mover(prefix + "X:")
        self.y = Mover(prefix + "Y:")

# make and connect devices. Requires the run engine.
RE= RunEngine()
with DeviceCollector():
    left_stage = SampleStage("Left-")
    right_stage = SampleStage("Right-")

Bluesky Queue Server — Remote Control of Experiments

Bluesky Queue Server allows users to create and remotely manage the queue of Bluesky plans and the environment for plan execution.

  • Extensive set of API for full remote access to server functionality.
  • Autonomous execution of sequenced Bluesky plans.
  • Remote monitoring of the server.
  • Bluesky Queue Server API package for easy development of client applications in Python.
Learn about Bluesky Queue Server »

Suitcase — Export / Serialization

Bluesky is file format-agnostic. Individual "suitcase" packages encode data and metadata from bluesky's in-memory data model to existing file formats.

  • Export can be performed during acquisition or later.
  • It is easy to write new "suitcases" for desired formats.
  • The destination does not have to be a file on disk: it could be an in-memory buffer or a web client.
Learn about Suitcase »
Supported formats so far include:
  • CSV
  • TIFF
  • SPEC file
  • msgpack
  • JSONL
  • and other, technique- and instrument-specific formats

Data Broker — Rich Search and Access to Saved Data

Keeping scientific logic and I/O code separate makes important scientific code easier to maintain and reuse. Data Broker supports this by providing a programmatic interface to data, giving the user standard Python data structures directly.

  • The system is unopinionated about data formats.
  • Any file I/O happens transparently: the user never sees files, just gets data in memory (e.g. a numpy array).
  • Your detector writes in a special format? Register a custom reader at runtime.
Learn about Data Broker »

"Event Model" — Bluesky's Data Model

Bluesky organizes data and metadata into documents that adhere to a schema. This schema is formalized but minimal and may be composed with existing standards.

Learn about Bluesky's Data Model »

Citation

Daniel Allan, Thomas Caswell, Stuart Campbell & Maksim Rakitin (2019) Bluesky's Ahead: A Multi-Facility Collaboration for an a la Carte Software Project for Data Acquisition and Management, Synchrotron Radiation News, 32:3, 19-22, DOI: 10.1080/08940886.2019.1608121

@Article{doi:10.1080/08940886.2019.1608121,
  author    = {Allan, Daniel and Caswell, Thomas and Campbell, Stuart and Rakitin, Maksim},
  journal   = {Synchrotron Radiation News},
  title     = {{Bluesky's Ahead: A Multi-Facility Collaboration for an a la Carte Software Project for Data Acquisition and Management}},
  year      = {2019},
  number    = {3},
  pages     = {19--22},
  volume    = {32},
  doi       = {10.1080/08940886.2019.1608121},
  publisher = {Taylor \& Francis},
  url       = {https://doi.org/10.1080/08940886.2019.1608121},
}