This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from matplotlib import * | |
use('Qt4Agg') | |
from matplotlib.pyplot import * | |
from numpy import * | |
def PlotRFFT(x, y): | |
### PlotRFFT(x, y): plots the FFT of y assuming y is real. Generates one plot with two subfigures: abscissa = frequency and abscissa = period. | |
f = fft.rfft(y)/len(y)*2 | |
nu = fft.rfftfreq(len(y), x[1]-x[0]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Script to sync Pythonista files to Dropbox | |
# Author: David Hutchison | |
# www: http://www.devwithimagination.com/ | |
import webbrowser, os, pprint | |
import dropbox | |
import hashlib | |
import json | |
import difflib | |
import sys |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Without having to worry about all the hassle of starting a wx app or remembering flags, just | |
# show a dialog box to get a directory, file or messagebox and be done with it. | |
# Zack Gainsforth 2014 | |
import wx | |
if 'app' not in locals(): | |
app = wx.App(None) | |
def DirDialog(DefaultDir='', Title='Select Directory:'): | |
dlg = wx.DirDialog (None, Title, DefaultDir, wx.DD_DEFAULT_STYLE | wx.DD_DIR_MUST_EXIST) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import threading | |
import os | |
# Normally this would be some busier function... Here it is a stub. | |
def PlotAlphaMELTS(PathName): | |
print PathName | |
# How many threads we want. | |
NumThreads = 10 | |
# Counter for the thread in the loop. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
# Go to the directory where the alphaMELTS input files are. | |
os.chdir('/Users/Zack/Desktop/Testcmd') | |
# Run the shell script. | |
process = subprocess.Popen('./runit', shell=True) | |
process.wait() | |
print 'done' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Script to sync Pythonista files to Dropbox | |
# Author: David Hutchison | |
# www: http://www.devwithimagination.com/ | |
import webbrowser, os, pprint | |
import dropbox | |
import hashlib | |
import json | |
import difflib | |
import sys |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def Marry2ColumnDomains(x1, y1, x2, y2): | |
#Based on: http://stackoverflow.com/questions/24317761/numpy-function-to-find-indices-for-overlapping-vectors?noredirect=1#comment37587212_24317761 | |
mask1 = np.in1d(x1, x2) | |
mask2 = np.in1d(x2, x1) | |
xx1 = x1[mask1] | |
yy1 = y1[mask1] | |
xx2 = x2[mask2] | |
yy2 = y2[mask2] | |
return xx1, yy1, xx2, yy2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# implicit from numpy import * | |
def fullprint(*args, **kwargs): | |
from pprint import pprint | |
opt = get_printoptions() | |
set_printoptions(threshold='nan') | |
pprint(*args, **kwargs) | |
set_printoptions(**opt) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def cyfib(int n): | |
cdef int a, b, i | |
a,b = 1,1 | |
for i in range(n): | |
a,b = a+b, a | |
return a |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def myfunc(x): | |
x = x*3 | |
return x | |
import timeit | |
n = 100000 | |
print timeit.timeit(stmt='myfunc(5)', setup='from __main__ import myfunc', number=n)/n |
OlderNewer