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]


[0, 2, 4, 5, 6]
x [35 76 33 66 87]
y [65 23 78 43 23]

In [32]:
freqs[min_freq_index:max_freq_index]


Out[32]:
array([32, 76,  4, 33, 66])

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()


0.175480769231 0.622596153846
0.175480769231 0.516826923077
0.516826923077 0.658653846154
0.502403846154 0.658653846154
0.271634615385 0.502403846154
0.158653846154 0.908653846154
0.40625 0.793269230769
0.300480769231 0.353365384615
0.180288461538 0.492788461538

In [7]:
%pylab inline
fig = plt.figure()
plt.figtext?


Populating the interactive namespace from numpy and matplotlib
<matplotlib.figure.Figure at 0x102208710>

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


you opened /Users/sean/Dropbox/3 omega/Data/Liver/3mm_Liver/S_260.0K_3mmLiver_S3_091913_01

In [20]:
import tkFileDialog

In [26]:
name = tkFileDialog.askdirectory()
tkFileDialog
print "you returned the path:", name


you returned the path: /Users/sean/Dropbox/Python/3 Omega/sample_ice_data

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


a/b
c

In [12]:
a = 'hi there \nbye there\n'
b = 'ok then\n'
c = 'another sentence\n'
print ''.join([a,b,c])


hi there 
bye there
ok then
another sentence