Skip to content

Instantly share code, notes, and snippets.

View tacaswell's full-sized avatar

Thomas A Caswell tacaswell

View GitHub Profile
class FileStoreSquashing(FileStorePluginBase):
'''Write out 'squashed' files
.. note::
See :class:`FileStoreBase` for the rest of the required parametrs
This mixin will also configure the ``cam`` and ``proc`` plugins
on the parent.
@tacaswell
tacaswell / wo
Last active September 21, 2018 11:17
patch over conda vs venvs idea of activate
#! /bin/bash
if [ -a $1/bin/conda ]; then
# we are in a conda env
# save old QT_PLUGIN_PATH
OLD_QT=$QT_PLUGIN_PATH
@tacaswell
tacaswell / requirements.txt
Created November 18, 2018 06:38
Files from Melbourne 2018 EPICS python-in-controls workshop
git+https://github.com/pcdshub/QDarkStyleSheet.git
git+https://github.com/pcdshub/happi.git
git+https://github.com/pcdshub/typhon.git
git+https://github.com/slaclab/pydm.git
git+https://github.com/tacaswell/caproto.git@fix_alarm_subscriptions
git+https://github.com/tacaswell/timechart.git@fix_future_pydm
jinja2
numpy
ophyd
prettytable
from epics import caput, caget
from itertools import count
for j in count():
try:
ret = caget('XF:31IDA-BI{Cam:Tbl}cam1:PortName_RBV')
if ret is None:
raise TimeoutError('failed on XF:31IDA-BI{Cam:Tbl}cam1:PortName_RBV')
ret = caget('XF:31IDA-BI{Cam:Tbl}image1:EnableCallbacks_RBV')
if ret is None:
raise TimeoutError('failed on XF:31IDA-BI{Cam:Tbl}image1:EnableCallbacks_RBV')
@tacaswell
tacaswell / make_bleeding
Created February 5, 2019 18:36
make bleeding
#! /usr/bin/bash
set -e
TARGET_ENV=bleeding
OSPATH=~/source/other_source/
PSPATH=~/source/p
DSPATH=~/source/bnl
pull_build () {
git pull || echo failed
@tacaswell
tacaswell / .gitignore
Last active September 18, 2019 14:26
Slides for h5py update
*.h5
.ipynb_checkpoints/
@tacaswell
tacaswell / README.md
Last active April 2, 2020 19:37
ingest xpd chi files

This is code to consume processed data from XPD back into document model

@tacaswell
tacaswell / ironmanpython.txt
Created April 8, 2020 17:42
trace back -> IPython exit
Python 3.9.0a5+ (heads/master:799d7d61a9, Apr 6 2020, 17:38:49)
Type 'copyright', 'credits' or 'license' for more information
IPython 8.0.0.dev -- An enhanced Interactive Python. Type '?' for help.
In [1]: 1 /0
Traceback (most recent call last):
File "/home/tcaswell/.virtualenvs/bleeding/lib/python3.9/site-packages/IPython/core/interactiveshell.py", line 3331, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "<ipython-input-1-a37332903225>", line 1, in <module>
1 /0
@tacaswell
tacaswell / ingest_sensord.py
Created May 16, 2020 20:47
Example of how to ingest sensord logs (from journalctl) to EventModel
from event_model import compose_run
import datetime
import dateutil.parser
import itertools
from io import StringIO
import subprocess
import numpy as np
import functools
def extract_event(ts, batch):
@tacaswell
tacaswell / pi_format.py
Created January 17, 2013 02:54
Format nicely printed labels based on pi for matplotlib x-axis
def format_frac(fr):
'''Convert a/b to latex'''
sp = str(fr).split('/')
if len(sp) == 1:
return sp[0]
else:
return r'$\frac{%s}{%s}$' % tuple(sp)
frac_size = 4