In [39]:
import numpy as np
freqs = np.array([35,32,76,4,33,66,87])
vals = np.array([65,45,23,65,78,43,23])
picks = [35, 87]
unpicks = [4, 32]
min_freq_index = list(freqs).index(picks[0])
max_freq_index = list(freqs).index(picks[1])+1
#np.where(a==b[1])
fit_indices = [i+min_freq_index for i, num in enumerate(freqs[min_freq_index:max_freq_index]) if num not in unpicks]
#for i, num in enumerate(a):
# if num in b:
# locations.append(i)
print fit_indices
print "x", freqs[fit_indices]
print "y", vals[fit_indices]
In [32]:
freqs[min_freq_index:max_freq_index]
Out[32]:
In [5]:
from pylab import *
from matplotlib.widgets import Slider, Button, RadioButtons, SpanSelector
ax = subplot(111)
subplots_adjust(left=0.25, bottom=0.25)
t = arange(0.0, 1.0, 0.001)
a0 = 5
f0 = 3
s = a0*sin(2*pi*f0*t)
l, = plot(t,s, lw=2, color='red')
axis([0, 1, -10, 10])
axcolor = 'lightgoldenrodyellow'
axfreq = axes([0.25, 0.1, 0.65, 0.03], axisbg=axcolor)
axamp = axes([0.25, 0.15, 0.65, 0.03], axisbg=axcolor)
sfreq = Slider(axfreq, 'Freq', 0.1, 30.0, valinit=f0)
samp = Slider(axamp, 'Amp', 0.1, 10.0, valinit=a0)
def update(val):
amp = samp.val
freq = sfreq.val
l.set_ydata(amp*sin(2*pi*freq*t))
draw()
sfreq.on_changed(update)
samp.on_changed(update)
resetax = axes([0.8, 0.025, 0.1, 0.04])
button = Button(resetax, 'Reset', color=axcolor, hovercolor='0.975')
def reset(event):
sfreq.reset()
samp.reset()
button.on_clicked(reset)
def onselect(vmin, vmax):
print vmin, vmax
span = SpanSelector(ax, onselect, 'horizontal')
rax = axes([0.025, 0.5, 0.15, 0.15], axisbg=axcolor)
radio = RadioButtons(rax, ('red', 'blue', 'green'), active=0)
def colorfunc(label):
l.set_color(label)
draw()
radio.on_clicked(colorfunc)
show()
In [7]:
%pylab inline
fig = plt.figure()
plt.figtext?
In [7]:
from Tkinter import *
from tkFileDialog import askopenfilename
browser = Tk()
browser.withdraw() # we don't want a full GUI, so keep the root window from appearing
fileName = askopenfilename() # show an "Open" dialog box and return the path to the selected file
#browser.destroy() # get rid of the widget window
print "you opened", fileName
In [20]:
import tkFileDialog
In [26]:
name = tkFileDialog.askdirectory()
tkFileDialog
print "you returned the path:", name
In [35]:
class toy(object):
def __init__(self):
self.a,b = 5, 6
self.c,self.d = (7, 8)
In [7]:
rootn, filen = os.path.split('a/b/c')
print rootn
print filen
In [12]:
a = 'hi there \nbye there\n'
b = 'ok then\n'
c = 'another sentence\n'
print ''.join([a,b,c])