-
Notifications
You must be signed in to change notification settings - Fork 0
/
workup1125.py
454 lines (306 loc) · 13.5 KB
/
workup1125.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
# -*- coding: utf-8 -*-
"""
Created on Tue Nov 25 15:13:48 2014
@author: chris
"""
import os
from ramanTools.RamanSpectrum import *
from scipy import optimize
import pdb
from numpy import fft
import pandas
def takeout(a,centers = (452,479),demo = False):
def function(x,A1,w1,G1,b): return b - A1*exp(-(x-w1)**2/G1)
for center in centers:
x = array(a.index[center-7:center+7])
y = a.values[center-7:center+7]
guess= [a.iloc[center]-a.iloc[center+7],float(a.index[center]),20,float(a.iloc[center+7])]
try:
result = optimize.curve_fit(function,x,y,guess)
except RuntimeError:
tkMessageBox.showerror('Fit Failed')
return 0
z = list(result[0])
if demo:
print z
plot(x,function(x,*z))
if abs(z[2]<100):
a.iloc[center-7:center+7]-=function(x,*z)-z[-1]
return 0
def Fig1(): ##### View,filter, and average spectra of PbS dots with Methoxythiophenol in the 800-1600 cm-1 range
a = RamanTools.RamanSpectrum('/home/chris/Documents/DataWeiss/141125/5_.txt')
takeout(a)
b = RamanTools.RamanSpectrum('/home/chris/Documents/DataWeiss/141125/6_.txt')
takeout(b)
c = RamanTools.RamanSpectrum('/home/chris/Documents/DataWeiss/141125/8_.txt')
takeout(c)
d = RamanTools.RamanSpectrum('/home/chris/Documents/DataWeiss/141126/6_.txt')
takeout(d)
e = RamanTools.RamanSpectrum('/home/chris/Documents/DataWeiss/141126/3_.txt')
for l in [a,b,c,d,e]:
noise = l.calc_noise((1100,1200))
signal = l.values[argmin(abs(array(l.index)-1596))] - l.values[argmin(abs(array(l.index)-1650))]
print 'S/N:', signal/noise
l = RamanTools.add_RamanSpectra(a,b)
m = RamanTools.add_RamanSpectra(l,c)
o = RamanTools.add_RamanSpectra(m,d)
#o = RamanTools.add_RamanSpectra(o,e)
noise = l.calc_noise((1100,1200))
signal = l.iloc[argmin(abs(array(l.index)-1596))] - l.iloc[argmin(abs(array(l.index)-1650))]
print 'S/N:', signal/noise
noise = m.calc_noise((1100,1200))
signal = m.iloc[argmin(abs(array(m.index)-1596))] - m.iloc[argmin(abs(array(m.index)-1650))]
print 'S/N:', signal/noise
noise = o.calc_noise((1100,1200))
signal = o.iloc[argmin(abs(array(m.index)-1596))] - o.iloc[argmin(abs(array(o.index)-1650))]
print 'S/N:', signal/noise
figure()
subplot(311)
a.plot(color='r')
b.plot(color='k')
c.plot(color='b')
d.plot(color='g')
legend(['a','b','c','d'])
#n = FourierFilter(n, width = 400)
subplot(312)
o.plot()
subplot(313)
n=RamanTools.FourierFilter(o,width = 170)
n.autobaseline((700,1700))
n.plot(color = 'k')
#### Reference Spectrum of MTP on Cd
MTP = RamanTools.RamanSpectrum('/home/chris/Documents/DataWeiss/141014/4_methoxythiophenol_1.csv')
MTP-=min(MTP[0:1000])
MTP/=(max(MTP[0:1000]))
MTP*=1000
MTP.plot(color = 'b',linewidth = 3)
a = RamanTools.RamanSpectrum('/home/chris/Documents/DataWeiss/141126/10_control pbs.txt')
b = RamanTools.RamanSpectrum('/home/chris/Documents/DataWeiss/141126/11_control.txt')
c = RamanTools.add_RamanSpectra(a,b)
control = RamanTools.FourierFilter(c,width = 170)
control.autobaseline((700,1700))
control.plot(color = 'r')
xlim(700,1700)
ylim(-500,1500)
return 0
def Fig2(): ##### View,filter, and average spectra of PbS dots with Methoxythiophenol in the 2300-3400 cm-1 range
subplot(121)
a = RamanTools.RamanSpectrum('/home/chris/Documents/DataWeiss/141125/7_.txt')
takeout(a)
a.plot()
b = RamanTools.RamanSpectrum('/home/chris/Documents/DataWeiss/141126/7_.txt')
b = RamanTools.FourierFilter(b,width = 380)
takeout(b,centers = (456,483),demo = True)
b.plot()
c = RamanTools.RamanSpectrum('/home/chris/Documents/DataWeiss/141126/8_.txt')
takeout(c)
c.plot()
m = RamanTools.add_RamanSpectra(a,b)
n = RamanTools.add_RamanSpectra(m,c)
legend(['1','2','3'])
subplot(122)
MTP = RamanTools.RamanSpectrum('/home/chris/Documents/DataWeiss/141014/4_methoxythiophenol_1.csv')
MTP-=min(MTP[0:1000])
MTP/=(max(MTP[0:1000]))
MTP*=1000
MTP.plot(color = 'b',linewidth = 3)
n.autobaseline((2300,3400))
n/=10
n.plot()
xlim(2300,3400)
ylim(-500,1500)
return 0
def Fig3(): ### Combine final spectra from fig1 and fig2. Display side by side. Showing no SH stretch but some modes for phenyl ring in MTP.
subplot(121)
a = RamanTools.RamanSpectrum('/home/chris/Documents/DataWeiss/141125/5_.txt')
takeout(a)
b = RamanTools.RamanSpectrum('/home/chris/Documents/DataWeiss/141125/6_.txt')
takeout(b)
c = RamanTools.RamanSpectrum('/home/chris/Documents/DataWeiss/141125/8_.txt')
takeout(c)
d = RamanTools.RamanSpectrum('/home/chris/Documents/DataWeiss/141126/6_.txt')
takeout(d)
e = RamanTools.RamanSpectrum('/home/chris/Documents/DataWeiss/141126/3_.txt')
##### total of 4500 s measurement for a-e, for a-d total is 2500 s
l = RamanTools.add_RamanSpectra(a,b)
m = RamanTools.add_RamanSpectra(l,c)
o = RamanTools.add_RamanSpectra(m,d)
n=RamanTools.FourierFilter(o,width = 170)
n.autobaseline((700,1700))
n/=2500
MTP = RamanTools.RamanSpectrum('/home/chris/Documents/DataWeiss/141014/4_methoxythiophenol_1.csv')
MTP-=min(MTP[0:1000])
MTP/=(max(MTP[0:1000]))
MTP+=1
a = RamanTools.RamanSpectrum('/home/chris/Documents/DataWeiss/141126/10_control pbs.txt')
b = RamanTools.RamanSpectrum('/home/chris/Documents/DataWeiss/141126/11_control.txt')
c = RamanTools.add_RamanSpectra(a,b)
####total colection time for a and b is 1700
control = RamanTools.FourierFilter(c,width = 170)
control.autobaseline((700,1700))
control[:]/=1700
control +=0.5
MTP.plot(color = 'b',linewidth = 3,label ='MTP reference')
control.plot(color = 'r',label = 'PbS-oleate only')
n.plot(color = 'k',label = 'PbS-oleate + MTP')
annotate('C-S-H bend',(910,1.25),xytext = (910,2.0),arrowprops = {'width':1,'headwidth':3,'frac':0.05,'color':'k'} )
annotate('Ring expansion',(804,2.1),xytext = (804,2.6),arrowprops = {'width':1,'headwidth':3,'frac':0.05,'color':'k'} )
annotate('Ring expansion',(1095,1.85),xytext = (1140,1.9),arrowprops = {'width':1,'headwidth':3,'frac':0.05,'color':'k'} )
annotate('Ring asymmetric rocking',(1600,1.7),xytext = (1300,1.8),arrowprops = {'width':1,'headwidth':3,'frac':0.05,'color':'k'} )
legend()
xlim(700,1700)
ylim(-0.5,3)
ylabel('Intensity (a.u.)')
xlabel('Raman Shift (cm$^{-1}$)')
subplot(122)
a = RamanTools.RamanSpectrum('/home/chris/Documents/DataWeiss/141125/7_.txt')
takeout(a)
b = RamanTools.RamanSpectrum('/home/chris/Documents/DataWeiss/141126/7_.txt')
b = RamanTools.FourierFilter(b,width = 380)
takeout(b,centers = (456,483))
c = RamanTools.RamanSpectrum('/home/chris/Documents/DataWeiss/141126/8_.txt')
takeout(c)
#### Total collection time is 2500 s
m = RamanTools.add_RamanSpectra(a,b)
g = RamanTools.add_RamanSpectra(m,c)
g.autobaseline((2300,3400))
g[:]/=2500
MTP.plot(color = 'b', label = 'MTP reference',linewidth = 3)
g.plot(color = 'k', label='PbS-oleate + MTP')
annotate('S-H stretch',(2556,1.4),xytext = (2556,1.6),arrowprops = {'width':1,'headwidth':3,'frac':0.05,'color':'k'} )
legend()
xlim(2300,3400)
ylim(-0.5,3.0)
xlabel('Raman Shift (cm$^{-1}$)')
return 0
def Fig4(): ### Combine final spectra from fig1 and fig2. Display side by side. Showing no SH stretch but some modes for phenyl ring in MTP.
import os
os.chdir('/home/chris/Documents/DataWeiss/141113')
for i in os.listdir('.'):
if '.txt' in i:
print i
try:
a = RamanTools.RamanSpectrum(i)
a.autobaseline((800,1680),order = 4)
except:
continue
figure()
title(i[-8:])
a.plot()
xlim(800,1700)
gca().autoscale(axis = 'y')
return 0
def Fig5(): ### showing SERS on gold.
green = RamanTools.RamanSpectrum('/home/chris/Documents/DataWeiss/141202/15_.txt')
red = RamanTools.RamanSpectrum('/home/chris/Documents/DataWeiss/141202/14.txt')
green*=100
green[:]-=167000
red[:]-=red.iloc[0]
green.plot(color = 'g',label = '514.5 nm x 100')
red.plot(color = 'r',label = '647.1 nm (SERS enhanced)')
legend()
title('Raman of gold nanoparticles ($\lambda_{max}$ = 535 nm)')
ylabel('Intensity (a.u.)')
xlabel('Raman Shift (cm$^{-1}$)')
return 0
def Fig6():
from RamanTools2 import autobaseline
r = loadtxt('/home/chris/Documents/DataWeiss/141203/Nanoparticles after dispersion in methanol Dec3.csv',
unpack = True,
delimiter = ',',
usecols= (2,3,4,5),
skiprows = 2)
largeAu = pandas.Series(r[1],r[0])
largeAu[:]*=2
smallAu = pandas.Series(r[3],r[2])
subplot(121)
smallAu.plot(color = 'green',label = '525 nm sample')
largeAu.plot(color= 'r',label = '535 nm sample')
legend()
r = loadtxt('/home/chris/Documents/DataWeiss/141203/Nanoparticles after deposition onto glass Dec3.csv',
unpack = True,
delimiter = ',',
usecols= (2,3,4,5,6,7,8,9,10,11),
skiprows = 2)
smallAu1 = pandas.Series(r[1],r[0])
smallAu2 = pandas.Series(r[3],r[2])
glass = pandas.Series(r[5],r[4])
largeAu1 = pandas.Series(r[7],r[6])
largeAu2 = pandas.Series(r[9],r[8])
subplot(122)
rnge = (600,492)
autobaseline(smallAu1,rnge,order = 0)
smallAu1.plot(color = 'k',label = '525 sample1')
autobaseline(smallAu2,rnge,order = 0)
smallAu2.plot(color = 'k',label = '525 sample2')
autobaseline(glass,rnge,order = 2)
glass.plot(label = 'glass')
autobaseline(largeAu1,rnge,order = 0)
largeAu1.plot(color = 'r',label = '535 sample1')
autobaseline(largeAu2,rnge,order = 0)
largeAu2.plot(color = 'r',label = '535 sample2')
xlim(rnge[1],rnge[0])
ylim(-0.001,0.005)
legend()
#### took a wider view of exactly those particles used for SERS experiment.\ in Fig7
figure()
r = loadtxt('/home/chris/Documents/DataWeiss/141203/Gold nanoparticles wider view.csv',
unpack = True,
delimiter = ',',
skiprows = 2)
largeAu = pandas.Series(r[5],r[4])
largeAu[:]*=2
smallAu = pandas.Series(r[7],r[6])
correctionpoint1 = argmin(abs(array(smallAu.index)-800))
correctionpoint2 = argmin(abs(array(smallAu.index)-350))
smallAu.iloc[correctionpoint2:]-= diff(smallAu)[correctionpoint2]
smallAu.iloc[:correctionpoint1]+= diff(smallAu)[correctionpoint1]
largeAu.iloc[:correctionpoint1]+= diff(largeAu)[correctionpoint1]
largeAu.iloc[correctionpoint2:]-= diff(largeAu)[correctionpoint2]
smallAu[:]-=smallAu.iloc[0]
largeAu[:]-=largeAu.iloc[0]
peaklarge = argmin(abs(array(largeAu.index)-535))
peaksmall = argmin(abs(array(smallAu.index)-525))
smallAu[:]/=smallAu.iloc[peaksmall]
largeAu[:]/=largeAu.iloc[peaklarge]
#smallAu.plot(color = 'green',label = '525 nm sample')
largeAu.plot(color= 'r',label = '535 nm sample')
legend()
ylabel('Absorbance (a.u.)')
xlabel('Frequency (nm)')
return 0
def Fig7(): ### show raman enhancmenet of MTP coated gold NPs
green = RamanTools.RamanSpectrum('/home/chris/Documents/DataWeiss/141203/4_.txt')
red = RamanTools.RamanSpectrum('/home/chris/Documents/DataWeiss/141203/7_.txt')
MTP = RamanTools.RamanSpectrum('/home/chris/Documents/DataWeiss/141014/4_methoxythiophenol_1.csv')
MTP-=min(MTP[0:1000])
MTP/=(max(MTP[0:1000]))/10000
MTP+=3000
green[:]*=10
green._smooth()
green[:]-=14100
red[:]-=red.iloc[0]-1000
MTP.plot(color = 'b',label = 'MTP reference')
green.plot(color = 'g',label = '514.5 nm x 10')
red.plot(color = 'r',label = '647.1 nm (SERS enhanced)')
legend()
annotate('C-S-H bend',(910,5000),xytext = (950,12000),arrowprops = {'width':1,'headwidth':10,'frac':0.05,'color':'k'} )
title('Raman of MTP-functionalized gold nanoparticles ($\lambda_{max}$ = 535 nm)')
ylabel('Intensity (a.u.)')
xlabel('Raman Shift (cm$^{-1}$)')
return 0
def Fig8(): ### show raman enhancmenet of CdSe phonon mode
ongold = RamanTools.RamanSpectrum('/home/chris/Documents/DataWeiss/141203/15_.txt')
offgold = RamanTools.RamanSpectrum('/home/chris/Documents/DataWeiss/141203/16.txt')
#title('SERS of CdSe (ODPA-capped) on Gold NPs ($\lambda_{max}$ = 576 nm)')
ongold.plot(color = 'r',label = 'CdSe QDs on gold NPs (SERS enhanced)')
offgold.plot(color = 'k',label = 'CdSe QDs')
legend()
annotate('2nd-LO CdSe', (393,5340))
annotate('3rd-LO CdSe', (610,5500))
ylabel('Intensity (a.u.)')
xlabel('Raman Shift (cm$^{-1}$)')
xlim(300,700)
ylim(3200,6500)
#annotate('C-S-H bend',(910,5000),xytext = (950,12000),arrowprops = {'width':1,'headwidth':10,'frac':0.05,'color':'k'} )
return 0