Skip to content

Instantly share code, notes, and snippets.

View neggert's full-sized avatar

Nic Eggert neggert

View GitHub Profile
@neggert
neggert / ABCD.py
Created April 18, 2012 15:04
Background estimates using ABCD method
import math
class ABCDCalculator(object):
"""Class to calculate background using the ABCD method"""
def __init__(self, x, y):
self.x = x
self.y = y
def set_x_data(self, data):
"""Give the calculator the x data"""
self.x = data
@neggert
neggert / matplotlibrc
Created April 17, 2012 14:08
matplotlibrc that produces plots similar to the official CMS style
### MATPLOTLIBRC FORMAT
# This is a sample matplotlib configuration file - you can find a copy
# of it on your system in
# site-packages/matplotlib/mpl-data/matplotlibrc. If you edit it
# there, please note that it will be overridden in your next install.
# If you want to keep a permanent local copy that will not be
# over-written, place it in HOME/.matplotlib/matplotlibrc (unix/linux
# like systems) and C:\Documents and Settings\yourname\.matplotlib
# (win32 systems).
@neggert
neggert / hist_errorbars.py
Created April 16, 2012 14:49
Function for plotting histogram with error bars
import matplotlib.pyplot as plt
import numpy as np
import inspect
def hist_errorbars( data, xerrs=True, *args, **kwargs) :
"""Plot a histogram with error bars. Accepts any kwarg accepted by either numpy.histogram or pyplot.errorbar"""
# pop off normed kwarg, since we want to handle it specially
norm = False
if 'normed' in kwargs.keys() :
norm = kwargs.pop('normed')