Skip to content

Instantly share code, notes, and snippets.

@pierre-haessig
pierre-haessig / interactive_AR2.py
Created June 25, 2012 12:41
Interactive study of an AR(2) filter/process
#!/usr/bin/python
# -*- coding: UTF-8 -*-
""" Interactive study of an AR(2) auto-regressive filter/process.
AR(2) process definition : X_k = a_1 X_{k-1} + a_2 X_{k-2} + Z_k
Interactive choice :
choose graphically the two coefficients (a1, a2) of the filter
by clicking and dragging the red disc on the (a1, a2) plane.
@pierre-haessig
pierre-haessig / Terminal Here.py
Created June 29, 2012 09:08
Python script which opens a gnome-terminal in the current Nautilus directory
#!/usr/bin/python
# -*- coding: UTF-8 -*-
""" Terminal Here.py
Python script which opens a gnome-terminal in the current Nautilus directory.
This 'Terminal Here' script should work with spaces and with Unicode characters
in the path (at least, it is meant to work).
Script tested with Python 2.7 (2.5 - 2.6 should be fine as well)
This file should be dropped in the "~/.gnome2/nautilus-scripts" directory,
@pierre-haessig
pierre-haessig / zoom_adaptive_line.py
Created September 3, 2012 08:59
Change the appearance of the plotted line depending on the amount of zoom.
"""
Change the appearance of the plotted line depending on the amount of zoom.
Line properties changed include: line width, line color and marker type
Code derived from the clippedline example
http://matplotlib.sourceforge.net/examples/pylab_examples/clippedline.html
"""
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.lines import Line2D
@pierre-haessig
pierre-haessig / mpl_big_line.py
Created September 5, 2012 15:30
matplotlib slowdown with big invisible lines
import numpy as np
import matplotlib as mpl
import matplotlib.pyplot as plt
# Creates big x and y data:
N = 10**7
t = np.linspace(0,1,N)
x = np.random.normal(size=N)
# Create a plot:
@pierre-haessig
pierre-haessig / image_shake.py
Created October 4, 2012 15:51
Shake an image to get kind of XKCD-style lines
#!/usr/bin/python
# -*- coding: UTF-8 -*-
""" Shake an image
in relation to the discussion about xkcd-style graphs on matplotlib-users ML
ref: http://mathematica.stackexchange.com/questions/11350/xkcd-style-graphs
Pierre Haessig — October 2012
"""
from os.path import splitext
import numpy as n
import random as r
import pylab as p
DIRS = ['up', 'right', 'down', 'left']
def new_guy(seed=0):
r.seed(seed)
dna = [[r.choice(DIRS),
r.randint(1, 40),
@pierre-haessig
pierre-haessig / daily_power.tsv
Created January 30, 2013 14:33
a first D3js exercise to plot hourly electric power data over one day
hour power
00 5.88
01 5.51
02 5.94
03 6.84
04 6.10
05 5.80
06 6.26
07 4.64
08 3.71
@pierre-haessig
pierre-haessig / traits_saving.py
Last active December 22, 2015 22:58
Saving and loading Traits in a text file formatusing a minimal amount of formatting and parsing code.
'''Saving and loading Traits in a text file format
using a minimal amount of formatting and parsing code.
Pierre Haessig -- September 2013
'''
from traits.api import HasTraits, Float
class Person(HasTraits):
weight = Float(75.0)
@pierre-haessig
pierre-haessig / sympy transfer function solving.ipynb
Created September 26, 2013 16:20
An experiment to see how `SymPy` could be used to analyze block diagrams in order to compute transfer functions (Laplace or frequency domain analysis).
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pierre-haessig
pierre-haessig / ipythonhere.desktop
Created October 3, 2013 17:30
a .desktop file to create an entry in KDE Dolphin's Actions menu to lauch IPython in the current directory. File to be placed in ~/.kde/share/kde4/services/ServiceMenus/
[Desktop Entry]
Type=Service
X-KDE-ServiceTypes=KonqPopupMenu/Plugin
MimeType=inode/directory;
Actions=openIPythonHere;
X-KDE-AuthorizeAction=shell_access
[Desktop Action openIPythonHere]
# TryExec=ipython
Exec=cd %f; ipython qtconsole --pylab