Skip to content

Instantly share code, notes, and snippets.

@stuartcampbell
stuartcampbell / get_scanid_filenames.py
Created October 19, 2022 20:01
Get filenames for a given bluesky scan
def get_scanid_filenames(run):
"""
Get a bluesky scan_id, unique_id, filename by giveing uid
Parameters
----------
run: a BlueskyRun
Returns
-------
@stuartcampbell
stuartcampbell / spe2nxspe.py
Last active March 8, 2024 08:57
Convert SPE files into NXSPE files
#!/usr/bin/env python
'''
Created on Nov 24, 2009
@author: Stuart Campbell - SNS, Oak Ridge National Laboratory
'''
import nxs
import optparse
@stuartcampbell
stuartcampbell / README.md
Created December 16, 2019 21:59 — forked from danielballan/README.md
data-transfer

Running a Local DataBroker

Place downloaded files

The shared Globus endpoint includes one messagepack (*.msgpack) file per Bluesky Run. DataBroker can run on top of these filesdirectly, and that's how we'll start. Alternatively, we can read the contents of these files into MongoDB to gain better performance and support for more advanced search queries. We'll address that process at the end. It may or may not be necessary depending on your needs.

Keybase proof

I hereby claim:

  • I am stuartcampbell on github.
  • I am stuartcampbell (https://keybase.io/stuartcampbell) on keybase.
  • I have a public key ASDheIEWYXjQVdkWVu9Pjro5XKmXCLwdRrX41GLF77fSogo

To claim this, I am signing this object:

@stuartcampbell
stuartcampbell / iss_correct_missing_devnames.ipynb
Last active December 1, 2018 18:12
ISS correct missing devnames
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@stuartcampbell
stuartcampbell / ingest_iss_data.py
Created August 30, 2018 16:22
Ingest Eli's Test data from ISS into databroker (athena files)
import pandas as pd
import uuid
import time
def _parse_athena_header(inp_lines):
out = {}
for ln in inp_lines:
key, sep, val = ln[2:].partition(':')
if not sep:
continue
@stuartcampbell
stuartcampbell / iss-ascii-data-printer.cpp
Created April 5, 2018 01:03
Little test program to write out timestamps in ASCII as fast as possible (for testing ISS writing data issues)
//
// ascii-data-printer
//
// Created by Stuart Campbell on 3/9/18.
// Copyright © 2018 Stuart Campbell. All rights reserved.
//
#include <iostream>
#include <stdio.h>
#include <time.h>
@stuartcampbell
stuartcampbell / xspress2_stu
Created November 15, 2017 22:29
XSPRESS2 setup/collection script from a facility far far away...
xspress2 set-up "xsp1" $14 $14 $5 $5 0 $ffff $100 $8401
#xspress2 dump-regs "xsp1" -1
tfg generate 1 1 0.01 300 0
clear 0
enable 0
tfg start
echo "Starting run ..."
tfg wait
echo "Stopping run ..."
disable 0
@stuartcampbell
stuartcampbell / toggle-jupyter-code.py
Created July 22, 2017 01:44
Toggle raw code blocks on/off in Jupyter Notebooks
from IPython.display import HTML
HTML('''<script>
code_show=true;
function code_toggle() {
if (code_show){
$('div.input').hide();
} else {
@stuartcampbell
stuartcampbell / bsui
Last active May 8, 2017 00:30
Bluesky Startup Script
#! /bin/bash
if [ -z "$BS_ENV" ]; then
BS_ENV=collection-17Q2.0
fi
source /opt/conda/bin/activate $BS_ENV && ipython --profile=collection