Skip to content

Instantly share code, notes, and snippets.

View andrewfowlie's full-sized avatar

Andrew Fowlie andrewfowlie

View GitHub Profile
@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):
"""
@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 / 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 / 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 / hugo_academic_from_arxiv.py
Created August 29, 2017 04:55
Convert arXiv webpage into markdown entry for webpage in Hugo academic theme
"""
Convert arXiv code into markdown entry for webpage in Hugo academic theme
=========================================================================
Main usuage e.g.,
>>> markdown('1607.06608')
to scrape https://arxiv.org/abs/1607.06608 into a publication for Hugo
academic theme.
@andrewfowlie
andrewfowlie / evidence.py
Created September 12, 2017 01:39
Illustration of Bayesian evidence and Occam's razor
"""
Plot evidences for simple and complicated models
================================================
by Andrew Fowlie.
"""
import matplotlib
import numpy as np
import matplotlib.pyplot as plt
@andrewfowlie
andrewfowlie / highlight.sty
Last active May 3, 2020 07:33
LaTeX package for highlighting text that looks like a hand-drawn highlighter pen
\NeedsTeXFormat{LaTeX2e}[1994/06/01]
\ProvidesPackage{highlight}[2017/09/13 Highlight]
% All credit to https://tex.stackexchange.com/a/6029/35729
\usepackage{soul}
\usepackage{tikz}
\usetikzlibrary{calc}
\usetikzlibrary{decorations.pathmorphing}
@andrewfowlie
andrewfowlie / shadow.sty
Created September 13, 2017 01:11
LaTeX package for using tikz to put a shadow around an image
\NeedsTeXFormat{LaTeX2e}[1994/06/01]
\ProvidesPackage{shadow}[2017/09/13 shadow]
% code adapted from http://tex.stackexchange.com/a/11483/3954
\usepackage{tikz}
\usetikzlibrary{shadows,calc}
@andrewfowlie
andrewfowlie / freeze_out.py
Created November 6, 2017 00:57
Figure for WIMP freeze out
"""
WIMP miracle
============
"""
import matplotlib
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.ticker import MaxNLocator
@andrewfowlie
andrewfowlie / pie.py
Created November 6, 2017 00:58
Pie chart showing fraction of DM in universe
"""
Pie chart of Bayes factor
=========================
"""
import matplotlib
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.ticker import MaxNLocator