Skip to content

Instantly share code, notes, and snippets.

@dmcdougall
dmcdougall / test.cpp
Created September 29, 2013 20:45 — forked from simleb/test.cpp
#include <iostream>
#include <hdf5.h>
// Constants
const char saveFilePath[] = "test.h5";
const hsize_t ndims = 2;
const hsize_t ncols = 3;
int main()
@dmcdougall
dmcdougall / autocorrelate.py
Created April 11, 2013 17:20
Computing autocorrelations via Fourier transform
def compute_corr(f, pad=2, normalise=True):
n = pad * len(f)
fk = np.fft.rfft(f, n=n)
acf = np.fft.irfft(fk * np.conj(fk), n=n)
acf = acf[:len(f)]
if normalise:
acf /= acf[0]
acf = np.append(acf[::-1][:len(acf) - 1], acf)
return acf
/usr/bin/clang -fno-strict-aliasing -fno-common -dynamic -pipe -O2 -fwrapv -DNDEBUG -g -fwrapv -O3 -Wall -DPY_ARRAY_UNIQUE_SYMBOL=MPL_ARRAY_API -DPYCXX_ISO_CPP_LIB=1 -D_REENTRANT -I/opt/local/include -I/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/include -I/opt/local/include -I. -I/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/include -Isrc -Iagg24/include -I. -I/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/include -I/opt/local/include/freetype2 -I/opt/local/include -I. -I/opt/local/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/backend_agg.cpp -o build/temp.macosx-10.8-x86_64-2.7/src/backend_agg.o
In file included from src/backend_agg.cpp:49:
In file included from src/file_compat.h:4:
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/include/numpy/npy_3kcompat.h:258:40: warning
/usr/bin/clang -fno-strict-aliasing -fno-common -dynamic -pipe -O2 -fwrapv -DNDEBUG -g -fwrapv -O3 -Wall -DPY_ARRAY_UNIQUE_SYMBOL=MPL_ARRAY_API -DPYCXX_ISO_CPP_LIB=1 -D_REENTRANT -I/opt/local/include -I/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/include -I/opt/local/include -I. -I/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/include -Isrc -Iagg24/include -I. -I/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/include -I/opt/local/include/freetype2 -I/opt/local/include -I. -I/opt/local/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 -c src/backend_agg.cpp -o build/temp.macosx-10.8-x86_64-2.7/src/backend_agg.o
In file included from src/backend_agg.cpp:42:
In file included from src/file_compat.h:4:
/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/include/numpy/npy_3kcompat.h:258:40: warning
@dmcdougall
dmcdougall / xkcd.py
Created October 4, 2012 09:42
XKCD-style graphs in matplotlib
import numpy as np
from matplotlib import rcParams
rcParams['text.usetex'] = False
from matplotlib.backends.backend_agg import FigureCanvasAgg as fc
from matplotlib.figure import Figure
import matplotlib.font_manager as fm
# Function to draw a random function. Yo dawg...
def rand_func():
# Some random Fourier coefficients
@dmcdougall
dmcdougall / email.txt
Created September 17, 2012 11:05
Nabble boxplot email
Dear matplotlib developers,
I am attaching an updated boxplot method for axes.py that I would like
to suggest as a replacement for the present one in 0.90. My code does
not change any of the existing functionality, and simply adds a few
options to the existing code:
* I wanted to be able to draw boxplots entirely in black.
* When plotting several boxes on the same axes, where some boxes are
@dmcdougall
dmcdougall / new_boxplot_method.py
Created September 17, 2012 11:02
New boxplot method
def boxplot(self, x, notch=0, sym='+', vert=1, whis=1.5,
positions=None, widths=None, means=0, fill=0,
linestyle='-', monochrome=0, limits=None,
notchsize=None):
"""
boxplot(x, notch=0, sym='+', vert=1, whis=1.5,
positions=None, widths=None, means=0, fill=0,
linestyle='-', monochrome=0, limits=None,
notchsize=None)
@dmcdougall
dmcdougall / axes (boxplot method).py
Created September 17, 2012 11:01
Axes boxplot method
def boxplot(self, x, notch=0, sym='b+', vert=1, whis=1.5,
positions=None, widths=None, means=0, dofill=1,
linestyle='-', monochrome=0, limits=None):
"""
boxplot(x, notch=0, sym='+', vert=1, whis=1.5,
positions=None, widths=None, means=0, dofill=1,
linestyle='-', monochrome=0, limits=None)
Make a box and whisker plot for each column of x.
The box extends from the lower to upper quartile values
@dmcdougall
dmcdougall / diff_output.txt
Created September 17, 2012 11:00
Diff output from v0.90
1,2c1,4
< def boxplot(self, x, notch=0, sym='b+', vert=1, whis=1.5,
< positions=None, widths=None):
---
> def boxplot(self, x, notch=0, sym='+', vert=1, whis=1.5,
> positions=None, widths=None, means=0, fill=0,
> linestyle='-', monochrome=0, limits=None,
> notchsize=None):
5c7,9
< positions=None, widths=None)
@dmcdougall
dmcdougall / new_boxplot_method.py
Created September 3, 2012 12:10
New boxplot features
def boxplot(self, x, notch=0, sym='+', vert=1, whis=1.5,
positions=None, widths=None, means=0, fill=0,
linestyle='-', monochrome=0, limits=None,
notchsize=None):
"""
boxplot(x, notch=0, sym='+', vert=1, whis=1.5,
positions=None, widths=None, means=0, fill=0,
linestyle='-', monochrome=0, limits=None,
notchsize=None)