Skip to content

Instantly share code, notes, and snippets.

View andrewfowlie's full-sized avatar

Andrew Fowlie andrewfowlie

View GitHub Profile
@andrewfowlie
andrewfowlie / libload.py
Created July 4, 2017 23:45
Load functions into Python from a C++ library automagically
"""
Load functions from a dynmaic library via the header file
=========================================================
"""
import ctypes
import numpy as np
import json
import sys
from collections import OrderedDict as odict
@andrewfowlie
andrewfowlie / merge.py
Created December 2, 2016 07:40
Overlay two pickled figure objects
"""
Merge two pickled plots
=======================
This is rather crude. The pickled plots should have identical sizes, axes etc.
"""
from pickle import load
from matplotlib.pyplot import figure
@andrewfowlie
andrewfowlie / h5_txt.py
Last active November 16, 2022 16:24
Convert h5 -> txt format
"""
Make a numpy array
>>> np_array = np.random.random((30, 30))
Write it in h5 format
>>> h5_name = 'np_array.h5'
>>> write_dh5_np(h5_name, np_array)
@andrewfowlie
andrewfowlie / bw.py
Last active July 27, 2016 05:15
Starting point for relativistic Breit-Wigner in scipy.stats
"""
Relativistic Breit-Wigner.
"""
import numpy as np
from numpy import pi
from scipy.stats import rv_continuous
class breit_wigner_gen(rv_continuous):
"""