Skip to content

Instantly share code, notes, and snippets.

View rawlik's full-sized avatar

Michał rawlik

  • Zürich, Switzerland
View GitHub Profile
@rawlik
rawlik / Cramer-Rao.ipynb
Created February 21, 2014 18:26
Numerical Cramer-Rao bound in Python
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@rawlik
rawlik / cramer_rao.py
Last active March 5, 2022 15:04
Python module to numerically calculate Cramer-Rao bounds.
import pylab as pl
from scipy.misc import derivative
import inspect
def cramer_rao(model, p0, X, noise, show_plot=False):
"""Calulate inverse of the Fisher information matrix for model
sampled on grid X with parameters p0. Assumes samples are not
correlated and have equal variance noise^2.
Parameters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@rawlik
rawlik / Makefile
Created December 13, 2014 09:38
a simple ROOT Makefile
CC=clang++
FLAGS= `root-config --cflags` -std=c++11
LINK_FLAGS= `root-config --glibs`
DEPS = breedSFC.h
PROGRAMS = playground tests
PROGRAMS_OBJS = $(foreach X,$(PROGRAMS),$(X).o)
OBJS = breedSFC.o
@rawlik
rawlik / careful_autoscale.py
Last active November 27, 2015 09:28
A context manager for matplotlib that will autoscale only to objects plotted within its context. Ref. http://stackoverflow.com/questions/7386872/make-matplotlib-autoscaling-ignore-some-of-the-plots
class careful_autoscale:
def __init__(self, ax=None):
self.ax = ax if ax else gca()
def __enter__(self):
self.xl = self.ax.get_xlim()
self.yl = self.ax.get_ylim()
self.lines = self.ax.get_lines()
self.lines_visibility = [ l.get_visible() for l in self.lines ]
[ l.set_visible(False) for l in self.lines ]
@rawlik
rawlik / brighten.py
Created June 10, 2017 12:50
Brighten any color in matplotlib
def brighten(color, v):
return np.array(matplotlib.colors.to_rgb(color)) ** (1 - v)
@rawlik
rawlik / welcome.py
Created April 4, 2019 08:12
Colouring ASCII art in python
# use color ANSI escape sequences on windows
if os.name == "nt":
import colorama
colorama.init()
def welcome():
BLACK = "\033[0;30m"
RED = "\033[0;31m"
GREEN = "\033[0;32m"
YELLOW = "\033[0;33m"
@rawlik
rawlik / logging.py
Created April 4, 2019 08:16
Python logging in multiple modules
import coloredlogs
import logging
if __name__=="__main__":
# only configure logging in the main program, everywhere else just import and use it
# set up logging
logfile_folder = "N:/data/log/"
logfile_date = datetime.datetime.now().strftime("%Y%m%d_%H%M%S")
logfile_filename = f"bunker5_{logfile_date}.log"
@rawlik
rawlik / forward model.ipynb
Created March 6, 2020 08:33
A simple forward-model of grating interferometry computed tomography.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.