Skip to content

Instantly share code, notes, and snippets.

@sixtenbe
sixtenbe / wxPlot.py
Created Sep 4, 2011
plotting in wxPython
View wxPlot.py
import wx
import matplotlib
matplotlib.use('WXAgg')
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
View analytic_wfm.py
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
sixtenbe / wx_except.py
Created Sep 1, 2011
WXpython excepthook
View wx_except.py
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
sixtenbe / analytic_wfm.py
Last active Oct 1, 2021 — forked from endolith/peakdet.m
Peak detection in Python
View analytic_wfm.py
#!/usr/bin/python2
# 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