Skip to content

Instantly share code, notes, and snippets.

sixtenbe /
Created Sep 4, 2011
plotting in wxPython
import wx
import matplotlib
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas
from matplotlib.backends.backend_wx import NavigationToolbar2Wx
from matplotlib.figure import Figure
from matplotlib.ticker import ScalarFormatter, LogFormatter
from os import path, remove
from numpy import linspace
from math import pi, sqrt, sin
#Heavyside step function
H = lambda t: 1 if t > 0 else 0
# pure sine
ACV_A1 = lambda T, Hz = 50: 1000 * sqrt(2) * np.sin(2*pi*Hz * T)
ACV_A2 = lambda T, Hz = 50: 1000 * sqrt(2) * np.sin(2*pi*Hz * T) + 500
sixtenbe /
Created Sep 1, 2011
WXpython excepthook
import wx
import sys
import traceback
class Mainframe(wx.Frame):
def __init__(self, parent, id = wx.ID_DEFAULT, title = "The title", **kwargs):
sys.excepthook = self.excepthook
super(Mainframe, self).__init__(parent, id, title, *args, **kwargs)
#wx graphics code here
sixtenbe /
Last active Jul 19, 2022 — forked from endolith/peakdet.m
Peak detection in Python
# Copyright (C) 2016 Sixten Bergman
# License WTFPL
# This program is free software. It comes without any warranty, to the extent
# permitted by applicable law.
# You can redistribute it and/or modify it under the terms of the Do What The
# Fuck You Want To Public License, Version 2, as published by Sam Hocevar. See