Skip to content

Instantly share code, notes, and snippets.

@sixtenbe
sixtenbe / analytic_wfm.py
Last active May 27, 2024 01:24 — forked from endolith/peakdet.m
Peak detection in Python
#!/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
@sixtenbe
sixtenbe / wx_except.py
Created September 1, 2011 08:43
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
sixtenbe / analytic_wfm.py
Created September 1, 2011 11:26
analytic wafeforms
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 / wxPlot.py
Created September 4, 2011 20:14
plotting in wxPython
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