Skip to content

Instantly share code, notes, and snippets.

View CJ-Wright's full-sized avatar

Christopher J. 'CJ' Wright CJ-Wright

View GitHub Profile
from numba import cuda
import numpy as np
@cuda.jit
def foo(arr):
for i in range(arr.size):
arr[i] += i
A = np.arange(10000)
B = np.arange(10000)
Traceback (most recent call last):
File "/home/christopher/mc/envs/dp/bin/pyFAI-calib", line 47, in <module>
import pyFAI
ImportError: No module named pyFAI
---------------------------------------------------------------------------
DatumNotFound Traceback (most recent call last)
<ipython-input-26-0b516695237d> in <module>()
----> 1 ev0 = next(events)
/mnt/work-data/other_src/databroker/databroker/databroker.pyc in get_events(headers, fields, fill, handler_registry, handler_overrides)
402 # (else omit it from the events of this descriptor)
403 if fill:
--> 404 fill_event(event, handler_registry, handler_overrides)
405 yield event
@CJ-Wright
CJ-Wright / stack_installer.sh
Last active September 22, 2016 15:10
Install the APS/NSLS-II hybrid stack
#!/usr/bin/env bash
# Start in the home dir
cd
# Need to install/start mongo
# install miniconda
wget https://repo.continuum.io/miniconda/Miniconda2-latest-Linux-x86_64.sh -O ~/miniconda.sh
chmod +x miniconda.sh
./miniconda.sh -b -p ~/mc
@CJ-Wright
CJ-Wright / gpu_error.txt
Created June 15, 2016 19:54
conda env assocaited with numba issue #1940
# packages in environment at /mnt/work-data/other_src/mc/envs/master_dev2:
#
accelerate 2.2.0 np110py27_0 defaults
accelerate_cudalib 2.0 0 defaults
ase 3.12.0b1 <pip>
atk 2.8.0 0 mw
backports 1.0 py27_0 defaults
backports-abc 0.4 <pip>
backports.shutil-get-terminal-size 1.0.0 <pip>
backports.shutil_get_terminal_size 1.0.0 py27_0 conda-forge
In [81]: retrieve(e['data']['pe1_image'])
Out[81]:
array([[ 0. , 0. , 0. , ...,
0. , 0. , 0. ],
[ 4844.60009766, 4847.5 , 4862.58349609, ...,
4563.81689453, 4625.20019531, 4574.41650391],
[ 4883.38330078, 4861.45019531, 4895.26660156, ...,
4736.98339844, 4641.60009766, 4626.58349609],
...,
[ 4739.86669922, 4723.53320312, 4718.79980469, ...,
from magic import integrate
functions_dict = {integrate:[(args),{kwargs}} # ask people about more elegant way to do this
def __init__(self, functions_dict):
self.functions_dict = functions_dict
def run_analysis(self):
for data in self.data:
for func, v in self.functions_dict.items():
ret = func(img, *v[0], *v[1])
@CJ-Wright
CJ-Wright / 90-plans.py
Created July 29, 2016 22:56
XPD plans
import time
import os
import numpy as np
from bluesky.plans import (scan, subs_wrapper, abs_set, pchain,
reset_positions_wrapper, count, list_scan,
open_run, close_run, stage, unstage,
trigger_and_read, checkpoint, sleep, wait)
from bluesky.callbacks.broker import post_run, LiveTiffExporter
from bluesky.callbacks import LiveTable, LivePlot
from bluesky.plan_tools import print_summary
from pyFAI.geometry import Geometry
from skbeam.core.utils import radius_to_twotheta
from skbeam.core.utils import twotheta_to_q
from numpy.testing import assert_array_almost_equal
import matplotlib.pyplot as plt
geo = Geometry(
detector='Perkin', pixel1=.0002, pixel2=.0002,
dist=.23,
@CJ-Wright
CJ-Wright / export_daemon.py
Created March 21, 2017 21:24
Daemon to export data from the databroker continuously
import databroker.databroker as db
def export_daemon():
last_updated = now
while True:
last_updated_2 = now
hdrs = db(start_time=last_updated))
last_updated = last_updated_2.copy()
if hdrs:
for hdr in hdrs: