-
Notifications
You must be signed in to change notification settings - Fork 0
/
ageCalculation.py
1865 lines (1411 loc) · 87.5 KB
/
ageCalculation.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
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Apr 25 09:29:17 2017
@author: Julia Nissen, Zongyi Wang
"""
import sys
import Tkinter as tk
import tkFileDialog as filedialog
import tkMessageBox as messagebox
import numpy as np
from openpyxl import load_workbook
from scipy.optimize import fsolve
class Application(tk.Frame):
'''
GUI for age caculation for Larry Edwards trace metal lab
created by Julia and Nick
May 2017
'''
def __init__(self, master):
tk.Frame.__init__(self,master)
self.dialog_frame = tk.Frame(self)
self.dialog_frame.pack(padx = 20, pady = 15, anchor = 'w')
tk.Label(self.dialog_frame, text = "Welcome to age calculation!" ).grid(row = 0, column = 0, sticky = 'e')
self.master.title("Age Calculation")
self.create_widgets()
self.pack()
def create_widgets(self):
# some entry widgets
tk.Label(self.dialog_frame, text = "Enter spike information(choose from: DIII-B, DIII-A, 1I, 1H) ").grid(row = 1, column = 0, sticky = 'w')
self.spikeinput = tk.Entry(self.dialog_frame, background = 'white', width = 24)
self.spikeinput.grid(row = 1, column = 1, sticky = 'w')
self.spikeinput.focus_set()
tk.Label(self.dialog_frame, text = "Enter abundant sensitivity for 237U-238U ").grid(row = 2, column = 0, sticky = 'w')
self.AS1_input = tk.Entry(self.dialog_frame, background = 'white', width = 24)
self.AS1_input.grid(row =2, column = 1, sticky = 'w')
self.AS1_input.focus_set()
tk.Label(self.dialog_frame, text = "Enter sample weight(g) ").grid(row = 3, column = 0, sticky = 'w')
self.samplewt = tk.Entry(self.dialog_frame, background = 'white', width = 24)
self.samplewt.grid(row =3, column = 1, sticky = 'w')
self.samplewt.focus_set()
tk.Label(self.dialog_frame, text = "Enter spike weight(g) ").grid(row = 4, column = 0, sticky = 'w')
self.spikewt = tk.Entry(self.dialog_frame, background = 'white', width = 24)
self.spikewt.grid(row =4, column = 1, sticky = 'w')
self.spikewt.focus_set()
tk.Label(self.dialog_frame, text = "Enter chem spike weight(g) ").grid(row = 5, column = 0, sticky = 'w')
self.chemspikewt = tk.Entry(self.dialog_frame, background = 'white', width = 24)
self.chemspikewt.grid(row =5, column = 1, sticky = 'w')
self.chemspikewt.focus_set()
tk.Label(self.dialog_frame, text = "Enter sample ID: ").grid(row = 6, column = 0, sticky = 'w')
self.samplename = tk.Entry(self.dialog_frame, background = 'white', width = 24)
self.samplename.grid(row =6, column = 1, sticky = 'w')
self.samplename.focus_set()
tk.Label(self.dialog_frame, text = "Enter measurement year ").grid(row = 7, column = 0, sticky = 'w')
self.year_input = tk.Entry(self.dialog_frame, background = 'white', width = 24)
self.year_input.grid(row =7, column = 1, sticky = 'w')
self.year_input.focus_set()
tk.Label(self.dialog_frame, text = "Enter the row number for the calculation results to written into(starting from 6) ").grid(row = 8, column = 0, sticky = 'w')
self.row_input = tk.Entry(self.dialog_frame, background = 'white', width = 24)
self.row_input.grid(row =8, column = 1, sticky = 'w')
self.row_input.focus_set()
#Define submit and cancel buttons
button_frame = tk.Frame(self)
button_frame.pack(padx=15, pady=(0, 15), anchor='e')
self.submit_button = tk.Button(button_frame, text='Submit', default='active', command=self.click_submit)
self.submit_button.pack(side='right')
self.cancel_button = tk.Button(button_frame, text='Cancel', command=self.click_cancel)
self.cancel_button.pack(side='right')
#upload buttons
self.u_meas_upload = tk.Button(self)
self.u_meas_upload["text"] = "Upload U measurement file"
self.u_meas_upload["command"] = self.file_upload_u_meas
#self.u_meas_upload.grid(row = 10, column = 1)
self.u_meas_upload.pack()
self.th_meas_upload = tk.Button(self)
self.th_meas_upload["text"] = "Upload Th measurement file"
self.th_meas_upload["command"] = self.file_upload_th_meas
#self.th_meas_upload.grid(row = 10, column = 2)
self.th_meas_upload.pack()
self.u_wash_upload = tk.Button(self)
self.u_wash_upload["text"] = "Upload U wash file"
self.u_wash_upload["command"] = self.file_upload_u_wash
#self.u_wash_upload.grid(row = 11, column = 1)
self.u_wash_upload.pack()
self.th_wash_upload = tk.Button(self)
self.th_wash_upload["text"] = "Upload Th wash file"
self.th_wash_upload["command"] = self.file_upload_th_wash
#self.th_wash_upload.grid(row = 11, column =4 )
self.th_wash_upload.pack()
self.u_chemblank_upload = tk.Button(self)
self.u_chemblank_upload["text"] = "Upload U chem blank file"
self.u_chemblank_upload["command"] = self.file_upload_u_chemblank
#self.u_chemblank_upload.grid(row = 12, column =1 )
self.u_chemblank_upload.pack()
self.th_chemblank_upload = tk.Button(self)
self.th_chemblank_upload["text"] = "Upload Th chem blank file"
self.th_chemblank_upload["command"] = self.file_upload_th_chemblank
#self.th_chemblank_upload.grid(row = 12, column =2)
self.th_chemblank_upload.pack()
self.u_chemblankwash_upload = tk.Button(self)
self.u_chemblankwash_upload["text"] = "Upload U chem blank wash file"
self.u_chemblankwash_upload["command"] = self.file_upload_u_chemblankwash
#self.u_chemblankwash_upload.grid(row = 13, column =0 )
self.u_chemblankwash_upload.pack()
self.th_chemblankwash_upload = tk.Button(self)
self.th_chemblankwash_upload["text"] = "Upload Th chem blank wash file"
self.th_chemblankwash_upload["command"] = self.file_upload_th_chemblankwash
#self.u_chemblankwash_upload.grid(row = 13, column =2 )
self.th_chemblankwash_upload.pack()
self.file_export_upload = tk.Button(self)
self.file_export_upload ["text"] = "Upload age export file"
self.file_export_upload["command"] = self.file_upload_export
#self.file_export_upload.grid(row= 14, column = 1)
self.file_export_upload.pack( )
#age claculation button
self.agecalc = tk.Button(self)
self.agecalc["text"] = "Calculate age and export data"
self.agecalc["command"] = self.Age_Calculation
#self.agecalc.grid(row = 14, column = 2)
self.agecalc.pack()
# quit button
self.quit = tk.Button(self, text="QUIT", fg="red",command=root.destroy)
self.quit.pack()
def file_upload_u_meas(self):
filename_raw = filedialog.askopenfilename(parent=self)
self.filename_u_meas = filename_raw
try:
self.file_u_meas = load_workbook(str(filename_raw))
messagebox.showinfo("Success!", "You have uploaded your U measurement file! " )
except OSError as err:
messagebox.showwarning("Error", str(err))
except:
messagebox.showerror("Unexpected error:", str(sys.exc_info()[:]))
def file_upload_th_meas(self):
filename_raw = filedialog.askopenfilename(parent=self)
self.filename_th_meas = filename_raw
try:
self.file_u_meas = load_workbook(filename_raw)
messagebox.showinfo("Success!", "You have uploaded your Th measurement file! " )
except OSError as err:
messagebox.showwarning("Error", str(err))
except:
messagebox.showerror("Unexpected error:", str(sys.exc_info()[:]))
def file_upload_u_wash(self):
filename_raw = filedialog.askopenfilename(parent=self)
self.filename_u_wash = filename_raw
try:
self.file_u_meas = load_workbook(filename_raw)
messagebox.showinfo("Success!", "You have uploaded your U wash file! " )
except OSError as err:
messagebox.showwarning("Error", str(err))
except:
messagebox.showerror("Unexpected error:", str(sys.exc_info()[:]))
def file_upload_th_wash(self):
filename_raw = filedialog.askopenfilename(parent=self)
self.filename_th_wash = filename_raw
try:
self.file_th_wash = load_workbook(filename_raw)
messagebox.showinfo("Success!", "You have uploaded your Th wash file! " )
except OSError as err:
messagebox.showwarning("Error", str(err))
except:
messagebox.showerror("Unexpected error:", str(sys.exc_info()[:]))
def file_upload_u_chemblank(self):
filename_raw = filedialog.askopenfilename(parent=self)
self.filename_u_chemblank = filename_raw
try:
self.file_u_chemblank = load_workbook(filename_raw)
messagebox.showinfo("Success!", "You have uploaded your U chem blank file! " )
except OSError as err:
messagebox.showwarning("Error", str(err))
except:
messagebox.showerror("Unexpected error:", str(sys.exc_info()[:]))
def file_upload_th_chemblank(self):
filename_raw = filedialog.askopenfilename(parent=self)
self.filename_th_chemblank = filename_raw
try:
self.file_th_chemblank = load_workbook(filename_raw)
messagebox.showinfo("Success!", "You have uploaded your Th chem blank file! " )
except OSError as err:
messagebox.showwarning("Error", str(err))
except:
messagebox.showerror("Unexpected error:", str(sys.exc_info()[:]))
def file_upload_u_chemblankwash(self):
filename_raw = filedialog.askopenfilename(parent=self)
self.filename_u_chemblankwash = filename_raw
try:
self.file_u_chemblankwash = load_workbook(filename_raw)
messagebox.showinfo("Success!", "You have uploaded your U chem blank wash file! " )
except OSError as err:
messagebox.showwarning("Error", str(err))
except:
messagebox.showerror("Unexpected error:", str(sys.exc_info()[:]))
def file_upload_th_chemblankwash(self):
filename_raw = filedialog.askopenfilename(parent=self)
self.filename_th_chemblankwash = filename_raw
try:
self.file_th_chemblankwash = load_workbook(filename_raw)
messagebox.showinfo("Success!", "You have uploaded your Th chem blank wash file! " )
except OSError as err:
messagebox.showwarning("Error", str(err))
except:
messagebox.showerror("Unexpected error:", str(sys.exc_info()[:]))
def file_upload_export(self):
filename_raw = filedialog.askopenfilename(parent=self)
self.filename_export = filename_raw
try:
self.file_export = load_workbook(filename_raw)
messagebox.showinfo("Success!", "You have uploaded your export file! " )
except OSError as err:
messagebox.showwarning("Error", str(err))
except:
messagebox.showerror("Unexpected error:", str(sys.exc_info()[:]))
def click_submit(self, event=None):
self.spike_input = self.spikeinput.get()
spike = self.spike_input
#derives spike value based off dictionary entries
spike_six_three_dictionary = {"DIII-B":1.008398,"DIII-A": 1.008398,"1I":1.010128,"1H":1.010128}
spike_six_three_err_dictionary = {"DIII-B": 0.00015, "DIII-A": 0.00015, "1I": 0.00015, "1H": 0.00015}
spike_three_dictionary = {"DIII-B": 0.78938, "DIII-A": 0.78933, "1I": 0.61351, "1H": 0.78997}
spike_three_err_dictionary = {"DIII-B": 0.00002, "DIII-A": 0.00002, "1I": 0.00002, "1H": 0.00002}
spike_nine_dictionary = {"DIII-B": 0.21734, "DIII-A": 0.21705, "1I": 0.177187, "1H": 0.22815}
spike_nine_err_dictionary = {"DIII-B": 0.00001, "DIII-A": 0.00002, "1I": 0.00001, "1H": 0.00001}
spike_zero_nine_dictionary = {"DIII-B": 0.0000625, "DIII-A": 0.0000625, "1I": 0.0000402, "1H": 0.0000402}
spike_zero_nine_err_dictionary = {"DIII-B": 0.000003, "DIII-A": 0.000003, "1I": 0.0000011, "1H": 0.0000011}
spike_nine_two_dictionary = {"DIII-B": 0.00, "DIII-A": 0.00, "1I": 0.00, "1H": 0.00}
spike_nine_two_err_dictionary = {"DIII-B": 0.00, "DIII-A": 0.00, "1I": 0.00, "1H": 0.00}
spike_four_three_dictionary = {"DIII-B": 0.003195, "DIII-A": 0.003195, "1I":0.003180, "1H": 0.003180}
spike_four_three_err_dictionary= {"DIII-B": 0.000003, "DIII-A": 0.000003, "1I": 0.000003, "1H": 0.000003}
spike_five_three_dictionary = {"DIII-B": 0.10532, "DIII-A": 0.10532, "1I": 0.10521, "1H":0.10521}
spike_five_three_err_dictionary = {"DIII-B": 0.00003, "DIII-A": 0.00003, "1I": 0.00003, "1H": 0.00003}
spike_eight_three_dictionary = {"DIII-B": 0.01680, "DIII-A": 0.01680, "1I": 0.01700, "1H":0.01700 }
spike_eight_three_err_dictionary = {"DIII-B": 0.00001, "DIII-A": 0.00001,"1I": 0.00001, "1H": 0.00001}
if spike in spike_six_three_dictionary:
self.spike_six_three = float(spike_six_three_dictionary[spike]) #spike ratio
else:
messagebox.showwarning("Error!", "No valid spike info entered! ")
if spike in spike_six_three_err_dictionary:
self.spike_six_three_err = float(spike_six_three_err_dictionary[spike]) #error of spike ratio
if spike in spike_three_dictionary:
self.spike_three = float(spike_three_dictionary[spike]) #in pmol/g
else:pass
if spike in spike_three_err_dictionary:
self.spike_three_err = float(spike_three_err_dictionary[spike]) #in pmol/g
else:pass
if spike in spike_nine_dictionary:
self.spike_nine = float(spike_nine_dictionary[spike]) #in pmol/g
else: pass
if spike in spike_nine_err_dictionary:
self.spike_nine_err = float(spike_nine_err_dictionary[spike]) #in pmol/g
else: pass
if spike in spike_zero_nine_dictionary:
self.spike_zero_nine = float(spike_zero_nine_dictionary[spike]) #spike ratio
else: pass
if spike in spike_zero_nine_err_dictionary:
self.spike_zero_nine_err = float(spike_zero_nine_err_dictionary[spike]) #error of spike ratio
else: pass
if spike in spike_nine_two_dictionary:
self.spike_nine_two = float(spike_nine_two_dictionary[spike]) #spike ratio
else: pass
if spike in spike_nine_two_err_dictionary:
self.spike_nine_two_err = float(spike_nine_two_err_dictionary[spike]) #error of spike ratio
else: pass
if spike in spike_four_three_dictionary:
self.spike_four_three = float(spike_four_three_dictionary[spike]) #spike ratio
else: pass
if spike in spike_four_three_err_dictionary:
self.spike_four_three_err = float(spike_four_three_err_dictionary[spike]) #error of spike ratio
else: pass
if spike in spike_five_three_dictionary:
self.spike_five_three = float(spike_five_three_dictionary[spike]) #spike ratio
else: pass
if spike in spike_five_three_err_dictionary:
self.spike_five_three_err = float(spike_five_three_err_dictionary[spike]) #error of spike ratio
else: pass
if spike in spike_eight_three_dictionary:
self.spike_eight_three = float(spike_eight_three_dictionary[spike]) #spike ratio
else: pass
if spike in spike_eight_three_err_dictionary:
self.spike_eight_three_err = float(spike_eight_three_err_dictionary[spike]) #error of spike ratio
else: pass
#sample information
self.AS = self.AS1_input.get()
self.sample_wt = float(self.samplewt.get())
#self.filename_export_chem = self.chemFile.get()
self.chemspike_wt = float(self.chemspikewt.get())
self.chem_spike_wt = float(self.chemspikewt.get())
#year run
self.spike_wt = float(self.spikewt.get())
self.sample_name = self.samplename.get()
self.year = float(self.year_input.get())
#self.chemblank_date = self.chemBlankDate.get()
self.row = self.row_input.get()
messagebox.showinfo("Success! " , "You have submitted successfully! ")
def click_cancel(self, event=None):
messagebox.showwarning("You have clicked cancel", " bye bye! ")
self.master.destroy()
def Age_Calculation(self):
"""
Input variables for Age Calculation
"""
#constants needed in calculations
wt_229 = 229.031756
wt_230 = 230.033128
wt_232 = 232.038051
wt_233 = 233.039629
wt_234 = 234.040947
wt_235 = 235.043924
wt_236 = 236.045563
wt_238 = 238.050785
five_counttime = 0.131
four_counttime = 1.049
three_counttime = 0.393
two_nine_counttime = 1.049
eight_five_rat = 137.82 #why not 137.83?
eight_filament_blank = 0.0001
eight_filament_blank_err = 0.1
sample_wt_err = 0.000005
spike_wt_err = 0.000005
two_nine_spike = 0.00065
two_nine_spike_err = 0.00005
AS_1amu = 1.00E-10
AS_1amu_err = 0.25 * AS_1amu
AS_2amu = AS_1amu/2.5
AS_2amu_err = 0.25 * AS_2amu
lambda_238 = 0.000000000155125
lambda_234 = 0.0000028263*0.9985
lambda_230 = 0.0000091577*1.0014
threefive_four = 1E-11
fourfour_four = 1E-11
"""
Input functions for U, Th, wash, and chem blank values for use in Age Calculation
"""
self.wb_U = Ucalculation(self.spike_input, self.AS, self.filename_u_meas)
self.lstU_Th = self.wb_U.U_normalization_forTh() #provides a list for use in Th normalization
self.lstU_Age = self.wb_U.U_normalization_forAge() #provides a list for use in Age Calculation
"""
lstU_Age output is a list of the following values:
[0]: 235/233 normalized ratio
[1]: 235/233 normalized ratio error
[2]: 235/234 normalized and corrected ratio
[3]: 235/234 normalized and corrected ratio error
[4]: Unfiltered 233 counts
[5]: Filtered 234/235 counts
[6]: Unfiltered 233 mean
"""
self.wb_Th = Thcalculation(self.spike_input, self.AS, self.filename_th_meas, self.lstU_Th)
self.lstTh_Age = self.wb_Th.Th_normalization_forAge() #provides a list to use for Age Calculation
"""
lstTh_Age provides a list of the following outputs for the Age Calculation:
[0]: 230/229 corrected and normalized ratio
[1]: 230/229 corrected and normalized ratio error
[2]: 232/229 corrected and normalized ratio
[3]: 232/229 corrected and normalized ratio error
[4]: Unfiltered 229 mean
[5]: Unfiltered 229 counts
"""
self.wb_wash = background_values(self.filename_u_wash, self.filename_th_wash)
self.lstU_wash = self.wb_wash.U_wash() #provides a list of 233, 234, 235 wash values for use in Age Calculation
"""
lstU_wash provides a list of the following outputs for the Age Calculation:
[0]: 233 unfiltered wash in cps
[1]: 234 unfiltered wash in cps
[2]: 235 unfiltered wash in cps
"""
self.Th_wash = self.wb_wash.Th_wash() #provides the 230 darknoise cpm for use in Age Calculation
self.wb_chemblank = chemblank_values("1H", self.chem_spike_wt,
self.filename_u_chemblankwash, self.filename_th_chemblankwash,
self.filename_u_chemblank, self.filename_th_chemblank)
self.lst_chemblank = self.wb_chemblank.blank_calculate() #calculates chem blanks for use in Age Calculation
"""
lst_chemblank provides a list of the following outputs for the Age Calculation:
[0]: 238 chemblank value in pmol
[1]: 238 chemblank error in pmol
[2]: 232 chemblank value in pmol
[3]: 232 chemblank error in pmol
[4]: 230 chemblank value in fmol
[5]: 230 chemblank error in fmol
"""
"""
Age Calculation equations
"""
#238 ppb
five_three_max_err = ( (self.lstU_Age[6] * self.lstU_Age[0]) - self.lstU_wash[2] ) / (self.lstU_Age[6] - self.lstU_wash[0])
eight_nmol = (((five_three_max_err - self.spike_five_three) * self.spike_wt * self.spike_three * eight_five_rat)/1000) /self.sample_wt
chemblank_corr_238 = ((eight_nmol * self.sample_wt) - (self.lst_chemblank[0]/1000)) / self.sample_wt
filament_blank_corr_238 = chemblank_corr_238 * (1 - (eight_filament_blank/ (self.lstU_Age[6] * five_three_max_err
* eight_five_rat)))
eight_ppb = filament_blank_corr_238 * wt_238
#238 ppb error
rel_err_1 = (self.lstU_Age[1]/self.lstU_Age[0])
three_counting_err = 2 / (self.lstU_Age[6] * self.lstU_Age[4] * three_counttime)**0.5
five_counting_err = 2 / (self.lstU_Age[6] * self.lstU_Age[0] * five_counttime * self.lstU_Age[4])**0.5
rel_err_2 = np.sqrt( (five_counting_err**2) + (three_counting_err**2) + (three_counting_err**2)*(8.0/9.0) )
rel_err_five_three = max(rel_err_1, rel_err_2)
abs_err_five_three = rel_err_five_three * five_three_max_err
eight_nmol_err = eight_nmol * np.sqrt( ((np.sqrt((abs_err_five_three**2) + (0.0000527**2)))/(five_three_max_err - self.spike_five_three))**2 +
(spike_wt_err/self.spike_wt)**2 +
(self.spike_three_err/self.spike_three)**2 +
(sample_wt_err/self.sample_wt)**2 )
eight_nmol_err_rel = eight_nmol_err/eight_nmol
chemblank_corr_238_err = np.sqrt( (eight_nmol_err**2) + ((self.lst_chemblank[1]/1000)**2) )
chemblank_corr_238_err_rel = chemblank_corr_238_err / chemblank_corr_238
filament_blank_corr_238_err_rel = np.sqrt( (chemblank_corr_238_err_rel**2) +
( ((eight_filament_blank/(self.lstU_Age[6]*self.lstU_Age[0]*eight_five_rat)) *
np.sqrt((eight_filament_blank_err/eight_filament_blank)**2 +
((self.lstU_Age[6]*0.05)/self.lstU_Age[6])**2 +
((self.lstU_Age[1]/self.lstU_Age[0])**2)))
/ (1 - (eight_filament_blank/(self.lstU_Age[6]*self.lstU_Age[0]*eight_five_rat))))**2)
filament_blank_corr_238_err = filament_blank_corr_238_err_rel * filament_blank_corr_238
eight_ppb_err = filament_blank_corr_238_err * wt_238
#232 ppt
two_nine_max_err = self.lstTh_Age[2]
two_nine_spike_corr = two_nine_max_err - two_nine_spike
two_nine_chemblank_corr = two_nine_spike_corr - ( self.lst_chemblank[2]/(self.spike_wt * self.spike_nine) )
two_pmol = two_nine_chemblank_corr * self.spike_wt * self.spike_nine/self.sample_wt
two_ppt = two_pmol * wt_232
#232 ppt error
abs_err_two_nine = self.lstTh_Age[3]
two_nine_spike_corr_err = np.sqrt( (abs_err_two_nine**2) + (two_nine_spike_err **2) )
two_nine_chemblank_corr_err = np.sqrt( (self.lst_chemblank[2]/self.spike_wt*self.spike_nine) *
np.sqrt( (self.lst_chemblank[3]/self.lst_chemblank[2])**2 +
(spike_wt_err/self.spike_wt)**2 +
(self.spike_nine_err/self.spike_nine)**2)**2 +
two_nine_spike_corr_err**2)
two_pmol_err = two_pmol * np.sqrt( (two_nine_chemblank_corr_err/two_nine_chemblank_corr)**2 +
(spike_wt_err/self.spike_wt)**2 +
(self.spike_nine_err/self.spike_nine)**2 +
(sample_wt_err/self.sample_wt)**2 )
two_pmol_err_rel = two_pmol_err / two_pmol
two_ppt_err = two_ppt * two_pmol_err_rel
#230 pmol/g
zero_nine_max_err = self.lstTh_Age[0]
zero_nine_spike_corr = zero_nine_max_err - self.spike_zero_nine
zero_nine_AS_corr = zero_nine_spike_corr - AS_1amu - (AS_2amu * self.lstTh_Age[2])
zero_nine_darknoise_corr = zero_nine_AS_corr * (1 - ((self.Th_wash/60)/(self.lstTh_Age[4]*zero_nine_AS_corr)) )
zero_nine_chemblank_corr = zero_nine_darknoise_corr - ( self.lst_chemblank[4]/(self.spike_wt * self.spike_nine * 1000) )
zero_pmol = (zero_nine_chemblank_corr * self.spike_wt * self.spike_nine) / self.sample_wt
#230 pmol/g error
zero_nine_counting_err = self.lstTh_Age[0] * 2 * np.sqrt( (1 / ((self.lstTh_Age[4]/self.lstTh_Age[0])*self.lstTh_Age[5]*two_nine_counttime)) +
(1 / (self.lstTh_Age[4]*self.lstTh_Age[5]*two_nine_counttime) ) )
abs_err_zero_nine = max((zero_nine_max_err*0.00001), zero_nine_counting_err, self.lstTh_Age[1] )
zero_nine_spike_corr_err = np.sqrt( (abs_err_zero_nine**2) + (0.000003**2) )
zero_nine_AS_corr_err = np.sqrt( (zero_nine_spike_corr_err**2) + (AS_1amu_err**2) +
( AS_2amu * self.lstTh_Age[2] * np.sqrt( (AS_2amu_err/AS_2amu)**2 +
(self.lstTh_Age[3]/self.lstTh_Age[2])**2 ) )**2 )
zero_nine_darknoise_corr_err = zero_nine_darknoise_corr * np.sqrt( (zero_nine_AS_corr_err/zero_nine_AS_corr)**2 +
(((self.Th_wash/60)/(self.lstTh_Age[4]*zero_nine_AS_corr)) *
np.sqrt((0.2**2) + (10/self.lstTh_Age[4])**2 + (zero_nine_AS_corr_err/zero_nine_AS_corr)**2
/ (1 - ((self.Th_wash/60)/self.lstTh_Age[4]*zero_nine_AS_corr) ))
)**2)
zero_nine_chemblank_corr_err = np.sqrt( zero_nine_darknoise_corr_err**2 +
( (self.lst_chemblank[4]/(self.spike_wt * self.spike_nine * 1000)) *
np.sqrt( (self.lst_chemblank[5]/self.lst_chemblank[4])**2 +
(spike_wt_err/ self.spike_wt)**2 +
(self.spike_nine_err/self.spike_nine)**2 ))**2)
zero_pmol_err = zero_pmol * np.sqrt((zero_nine_chemblank_corr_err/zero_nine_chemblank_corr)**2 +
(spike_wt_err/self.spike_wt)**2 +
(self.spike_nine_err/self.spike_nine)**2 +
(sample_wt_err/self.sample_wt)**2)
zero_pmol_err_rel = zero_pmol_err / zero_pmol
#230/232 atomic ratio
zero_two_atomic = zero_pmol / two_pmol
zero_two_atomic_final = zero_two_atomic * 10**6
#230/232 atomic ratio error
zero_two_atomic_err_rel = np.sqrt( two_pmol_err_rel**2 + zero_pmol_err_rel**2 )
zero_two_atomic_err = zero_two_atomic_err_rel * zero_two_atomic
zero_two_atomic_err_final = zero_two_atomic_err * 10**6
#d234U measured
zero_nine_measuredU = self.lstU_Age[2] * (1 - self.lstU_wash[1]/(self.lstU_Age[6] * self.lstU_Age[2] * self.lstU_Age[0]))
four_five_wt_avg = zero_nine_measuredU
four_three_max_err = four_five_wt_avg * self.lstU_Age[0]
four_five_tail_corr = four_five_wt_avg * (1 - ((4.0/9.0 * threefive_four) + (5.0/9.0 * fourfour_four)))
four_five_spike_corr_234 = four_five_tail_corr * (1 - (self.spike_four_three/four_three_max_err))
four_five_spike_corr_235 = four_five_spike_corr_234 * (1 / (1- (self.spike_five_three/five_three_max_err)))
four_eight_ppm = (four_five_spike_corr_235 * 10**6) / eight_five_rat
d234U_m = (( four_eight_ppm / ((lambda_238/lambda_234) * 10**6)) - 1) * 1000
#d234U measured error
zero_nine_measuredU_err_rel = self.lstU_Age[3] / zero_nine_measuredU
rel_err_1 = np.sqrt(zero_nine_measuredU_err_rel**2 + (self.lstU_Age[1]/self.lstU_Age[0])**2)
four_counting_err = 2 / (self.lstU_Age[6] * four_three_max_err * four_counttime * self.lstU_Age[4])**0.5
rel_err_2 = np.sqrt(four_counting_err**2 + 2*three_counting_err**2 + (2.0/9.0)*three_counting_err**2)
rel_err_four_three = max(rel_err_1, rel_err_2)
four_five_wt_avg_err_rel = max(zero_nine_measuredU_err_rel**2,
np.sqrt(four_counting_err**2 + five_counting_err**2 + (2.0/9.0 * three_counting_err**2) ))
four_five_tail_corr_err_rel = np.sqrt((four_five_wt_avg_err_rel**2) +
(np.sqrt((4.0/9.0 * threefive_four)**2 + (5.0/9.0 * fourfour_four)**2)/
(1 - (4.0/9.0 * threefive_four + 5/9 * fourfour_four)) )**2)
four_five_spike_corr_234_err_rel = np.sqrt((four_five_tail_corr_err_rel**2) +
((self.spike_four_three/four_three_max_err) * np.sqrt(0.002**2 + rel_err_four_three**2) /
(1 - self.spike_four_three/four_three_max_err))**2)
four_five_spike_corr_235_err_rel = np.sqrt((four_five_spike_corr_234_err_rel**2) +
((self.spike_five_three/five_three_max_err) * np.sqrt(0.0005**2 + (rel_err_five_three/1000)**2) /
(1 - self.spike_five_three/five_three_max_err))**2)
four_five_spike_corr_235_err = four_five_spike_corr_235_err_rel * four_five_spike_corr_235
four_eight_ppm_err = (four_five_spike_corr_235_err * 10**6)/ eight_five_rat
d234U_m_err = (four_eight_ppm_err / ((lambda_238/lambda_234) * 10**6)) * 1000
#230Th/238U activity ratio
zero_eight_atomic = (zero_pmol/(eight_ppb/wt_238))/1000
zero_eight_activity = zero_eight_atomic * (lambda_230/lambda_238)
#230Th/238U activity ratio error
zero_eight_atomic_err_rel = np.sqrt(zero_pmol_err_rel**2 + eight_nmol_err_rel **2 )
zero_eight_activity_err = zero_eight_atomic_err_rel * zero_eight_activity
#Uncorrected age calculation and error
age_func = lambda t : zero_eight_activity - (1 - np.exp(-lambda_230*t) + (d234U_m/1000) *
(lambda_230/(lambda_230-lambda_234)) *
(1 - np.exp((lambda_234 - lambda_230)*t)))
t_initial_guess = 0
uncorrected_t = fsolve(age_func, t_initial_guess) #returns the value for t at which the solution is 0. This is true of all fsolve functions following this.
age_func_ThUmax = lambda t : (zero_eight_activity+zero_eight_activity_err) - (1 - np.exp(-lambda_230*t) + (d234U_m/1000) *
(lambda_230/(lambda_230-lambda_234)) *
(1 - np.exp((lambda_234 - lambda_230)*t)))
uncorrected_ThUmax = fsolve(age_func_ThUmax, t_initial_guess)
age_func_ThUmin = lambda t : (zero_eight_activity-zero_eight_activity_err) - (1 - np.exp(-lambda_230*t) + (d234U_m/1000) *
(lambda_230/(lambda_230-lambda_234)) *
(1 - np.exp((lambda_234 - lambda_230)*t)))
uncorrected_ThUmin = fsolve(age_func_ThUmin, t_initial_guess)
age_func_d234Umax = lambda t : zero_eight_activity - (1 - np.exp(-lambda_230*t) + ((d234U_m + d234U_m_err)/1000) *
(lambda_230/(lambda_230-lambda_234)) *
(1 - np.exp((lambda_234 - lambda_230)*t)))
uncorrected_d234Umax = fsolve(age_func_d234Umax, t_initial_guess)
age_func_d234Umin = lambda t : zero_eight_activity - (1 - np.exp(-lambda_230*t) + ((d234U_m - d234U_m_err)/1000) *
(lambda_230/(lambda_230-lambda_234)) *
(1 - np.exp((lambda_234 - lambda_230)*t)))
uncorrected_d234Umin = fsolve(age_func_d234Umin, t_initial_guess)
uncorrected_t_maxerr = np.sqrt((uncorrected_ThUmax - uncorrected_t)**2 + (uncorrected_d234Umax - uncorrected_t)**2)
uncorrected_t_minerr = np.sqrt((uncorrected_ThUmin - uncorrected_t)**2 + (uncorrected_d234Umin - uncorrected_t)**2)
uncorrected_t_err = (uncorrected_t_maxerr + uncorrected_t_minerr)/2
#Corrected age calculation and error
zero_two_initial = 0.0000044
zero_two_initial_err = zero_two_initial/2
age_func_corrected_t = lambda t : (((zero_pmol - zero_two_initial*np.exp(-lambda_230*t)*two_pmol) * lambda_230/(filament_blank_corr_238 * 1000 * lambda_238)) -
(1 - np.exp(-lambda_230 * t) + (d234U_m/1000 * (lambda_230/(lambda_230-lambda_234)) *
(1 - np.exp((lambda_234-lambda_230)*t)))))
t_initial_guess = 0
corrected_t = fsolve(age_func_corrected_t, t_initial_guess)
zero_two_initial_now = zero_two_initial * np.exp(-lambda_230 * corrected_t)
zero_two_initial_now_err = zero_two_initial_now * (zero_two_initial_err / zero_two_initial)
corrected_zero_eight_activity = (zero_pmol - zero_two_initial_now*two_pmol) * lambda_230/(filament_blank_corr_238 * 1000 * lambda_238)
corrected_zero_eight_activity_err = corrected_zero_eight_activity * np.sqrt(
(np.sqrt(((zero_two_initial_now * two_pmol) * np.sqrt((zero_two_initial_now_err/zero_two_initial_now)**2
+ (two_pmol_err/two_pmol))**2)**2 + zero_pmol_err **2) /
(zero_pmol - zero_two_initial_now*two_pmol))**2 +
(filament_blank_corr_238_err/filament_blank_corr_238)**2)
age_func_ThUmax = lambda t : (corrected_zero_eight_activity+corrected_zero_eight_activity_err) - (1 - np.exp(-lambda_230*t) + (d234U_m/1000) *
(lambda_230/(lambda_230-lambda_234)) *
(1 - np.exp((lambda_234 - lambda_230)*t)))
corrected_ThUmax = fsolve(age_func_ThUmax, t_initial_guess)
age_func_ThUmin = lambda t : (corrected_zero_eight_activity-corrected_zero_eight_activity_err) - (1 - np.exp(-lambda_230*t) + (d234U_m/1000) *
(lambda_230/(lambda_230-lambda_234)) *
(1 - np.exp((lambda_234 - lambda_230)*t)))
corrected_ThUmin = fsolve(age_func_ThUmin, t_initial_guess)
age_func_d234Umax = lambda t : corrected_zero_eight_activity - (1 - np.exp(-lambda_230*t) + ((d234U_m + d234U_m_err)/1000) *
(lambda_230/(lambda_230-lambda_234)) *
(1 - np.exp((lambda_234 - lambda_230)*t)))
corrected_d234Umax = fsolve(age_func_d234Umax, t_initial_guess)
age_func_d234Umin = lambda t : corrected_zero_eight_activity - (1 - np.exp(-lambda_230*t) + ((d234U_m - d234U_m_err)/1000) *
(lambda_230/(lambda_230-lambda_234)) *
(1 - np.exp((lambda_234 - lambda_230)*t)))
corrected_d234Umin = fsolve(age_func_d234Umin, t_initial_guess)
age_func_low = lambda t: ((zero_pmol - ((zero_two_initial_now + zero_two_initial_now_err) * np.exp(-lambda_230 * t)) *two_pmol)
* lambda_230/(filament_blank_corr_238 * 1000 * lambda_238)) - (1 - np.exp(-lambda_230*t) + ((d234U_m)/1000) *
(lambda_230/(lambda_230-lambda_234)) *
(1 - np.exp((lambda_234 - lambda_230)*t)))
age_func_high = lambda t: ((zero_pmol - ((zero_two_initial_now - zero_two_initial_now_err) * np.exp(-lambda_230 * t)) *two_pmol)
* lambda_230/(filament_blank_corr_238 * 1000 * lambda_238)) - (1 - np.exp(-lambda_230*t) + ((d234U_m)/1000) *
(lambda_230/(lambda_230-lambda_234)) *
(1 - np.exp((lambda_234 - lambda_230)*t)))
corrected_age_low = fsolve(age_func_low, t_initial_guess)
corrected_age_high = fsolve(age_func_high, t_initial_guess)
corrected_t_maxerr = np.sqrt((corrected_ThUmax - corrected_t)**2 + (corrected_d234Umax - corrected_t)**2 + (corrected_age_high - corrected_t)**2 )
corrected_t_minerr = np.sqrt((corrected_ThUmin - corrected_t)**2 + (corrected_d234Umin - corrected_t)**2 + (corrected_age_low - corrected_t)**2 )
corrected_t_err = (corrected_t_maxerr + corrected_t_minerr)/2
#Corrected initial d234U and error
d234U_i = d234U_m * np.exp(lambda_234 * corrected_t)
d234U_i_maxerr = np.sqrt( (d234U_m_err * np.exp(lambda_234 * corrected_t))**2 +
(d234U_m * np.exp((lambda_234 * (corrected_t + corrected_t_maxerr)) - d234U_i))**2)
d234U_i_minerr = np.sqrt( (d234U_m_err * np.exp(lambda_234 * corrected_t))**2 +
(d234U_m * np.exp((lambda_234 * (corrected_t - corrected_t_minerr)) - d234U_i))**2)
d234U_i_err = (d234U_i_maxerr + d234U_i_minerr)/2
#Corrected age BP
corrected_t_BP = corrected_t - self.year
corrected_t_BP_err = corrected_t_err
age_file = load_workbook(self.filename_export)
sheet = age_file.get_sheet_by_name('Sheet1')
row = str(self.row)
sheet['B' + row] = self.sample_name
sheet['C' + row] = "{0:.1f}".format(eight_ppb)
sheet['D' + row] = "± " + "{0:.1f}".format(eight_ppb_err)
sheet['E' + row] = "{0:.0f}".format(two_ppt)
sheet['F' + row] = "± " + "{0:.0f}".format(two_ppt_err)
sheet['G' + row] = "{0:.1f}".format(zero_two_atomic_final)
sheet['H' + row] = "± " + "{0:.1f}".format(zero_two_atomic_final)
sheet['I' + row] = "{0:.1f}".format(d234U_m)
sheet['J' + row] = "± " + "{0:.1f}".format(d234U_m_err)
sheet['K' + row] = "{0:.5f}".format(zero_eight_activity)
sheet['L' + row] = "± " + "{0:.5f}".format(zero_eight_activity_err)
sheet['M' + row] = "%.0f" % uncorrected_t
sheet['N' + row] = "± %.0f" % uncorrected_t_err
sheet['O' + row] = "%.0f" % corrected_t
sheet['P' + row] = "± %.0f" % corrected_t_err
sheet['Q' + row] = "%.1f" % d234U_i
sheet['R' + row] = "± %.1f" % d234U_i_err
sheet['S' + row] = "%.0f" % corrected_t_BP
sheet['T' + row] = "± %.0f" % corrected_t_BP_err
age_file.save(self.filename_export)
messagebox.showinfo( "AGE CALCULATION VALUES ",\
"238 ppb: " + str(eight_ppb) + " ± " + str(eight_ppb_err)+\
"\n232 ppt: " + str(two_ppt) + " ± " + str(two_ppt_err)+\
"\n230/232 atomic (10*6) ratio: " + str(zero_two_atomic_final) + " ± " + str(zero_two_atomic_err_final)+\
"\nd234U measured: " + str(d234U_m) + " ± " + str(d234U_m_err)+\
"\n230/238 activity ratio: " + str(zero_eight_activity) + " ± " + str(zero_eight_activity_err)+\
"\n230Th Age uncorrected: %f" % uncorrected_t + " ± %f" % uncorrected_t_err + " yrs"+\
"\n230Th Age corrected: %f" % corrected_t + " ± %f" % corrected_t_err + " yrs"+\
"\nd234U initial corrected: %f" % d234U_i + " ± %f" % d234U_i_err+\
"\n230Th Age corrected: %f" % corrected_t_BP + " ± %f" %corrected_t_BP_err + " yrs BP"+\
"\nAge Calculation has finished")
messagebox.showinfo("Success! ", "Age calculation finished! ")
class isofilter():
def __init__(self, filename,columnletter,filternumber): # input filename and columnletter as strings
self.column = str(columnletter)+'{}:'+str(columnletter)+'{}'
self.filename = str(filename)
self.filternumber = int(filternumber)
self.workbook = load_workbook(self.filename)
self.ws = self.workbook.active
self.totalCounts = 0
self.mean = 0
self.filteredMean = 0
self.err = 0
self.criteria = 0
self.totalCounts_filt = 0
self.standdev = 0
def getMean(self):
"""
Code works row by row through specified Excel column, and calculates total mean
"""
outlist = []
for row in self.ws.iter_rows(self.column.format(2, self.ws.max_row - 8)):
for cell in row:
value = cell.value or cell.value == 0
if value:
outlist.append(cell.value)
else:
outlist.append(np.nan)
outarray = np.array(outlist, dtype = np.float)
self.mean = np.nanmean(a = outarray)
return self.mean
def getStanddev(self):
"""
Code works row by row through specified Excel column, and calculates standard deviation
"""
outlist = []
for row in self.ws.iter_rows(self.column.format(2, self.ws.max_row - 8)):
for cell in row:
value = cell.value or cell.value == 0
if value:
outlist.append(value)
else:
outlist.append(np.nan)
outarray = np.array(outlist, dtype = np.float)
self.standdev = np.nanstd(a = outarray, ddof = 1)
return self.standdev
def getCounts(self):
"""
Code works row by row through specified Excel Column, and determines total number of values present (i.e. cycles)
"""
total_counts = 0
for row in self.ws.iter_rows(self.column.format(2, self.ws.max_row - 8)):
for cell in row:
value = cell.value or cell.value == 0
if value:
total_counts +=1
self.totalCounts = total_counts
return self.totalCounts
def Filtered_mean(self, mean, standdev, counts):
"""
Code works row by row through specified Excel column, deletes entries that are outside of specified range,
and calculates resulting mean
"""
self.mean = mean
self.standdev = standdev
self.totalCounts = counts
self.standerr = (self.standdev / (self.totalCounts**0.5))
self.criteria = self.filternumber * self.standerr
outlist = []
outcounts = 0
for row in self.ws.iter_rows(self.column.format(2, self.ws.max_row - 8)):
for cell in row:
value = cell.value or cell.value == 0
if value:
if abs(value - self.mean) > self.criteria:
outlist.append(np.nan)
else:
outlist.append(value)
outcounts += 1
else:
outlist.append(np.nan)
outarray = np.array(outlist, dtype = np.float)
self.filteredMean = np.nanmean(a = outarray)
return self.filteredMean
def Filtered_err(self, mean, standdev, counts):
"""
Code works row by row through specified Excel column, deletes entries that are outside of specified range,
and calculates resulting 2s counting stantistics error
"""
self.mean = mean
self.standdev = standdev
self.totalCounts = counts
self.standerr = (self.standdev / (self.totalCounts**0.5))
self.criteria = self.filternumber * self.standerr
outlist = []
outcounts = 0
for row in self.ws.iter_rows(self.column.format(2, self.ws.max_row - 8)):
for cell in row:
value = cell.value or cell.value == 0
if value:
if abs(value - self.mean) > self.criteria:
outlist.append(np.nan)
else:
outlist.append(value)
outcounts += 1
else:
outlist.append(np.nan)
outarray = np.array(outlist, dtype = np.float)
outstanddev = np.nanstd(a=outarray, ddof = 1)
self.err = 2 * (outstanddev / (outcounts ** 0.5))
return self.err
def Filtered_counts(self, mean, standdev, counts):
"""
Code works row by row through specified Excel column, deletes entries that are outside of specified range,
and determines total number of values remaining (i.e. filtered cycles)
"""
self.mean = mean
self.standdev = standdev
self.totalCounts = counts
self.standerr = (self.standdev / (self.totalCounts**0.5))
self.criteria = self.filternumber * self.standerr
outlist = []
outcounts = 0
for row in self.ws.iter_rows(self.column.format(2, self.ws.max_row - 8)):
for cell in row:
value = cell.value or cell.value == 0
if value:
if abs(value - self.mean) > self.criteria:
outlist.append(np.nan)
else:
outlist.append(value)
outcounts += 1
else:
outlist.append(np.nan)
self.totalCounts_filt = outcounts
return self.totalCounts_filt
class chem_blank():
def __init__(self,filename, columnletter, int_time):
self.column = str(columnletter)+'{}:'+str(columnletter)+'{}'
self.filename = str(filename)
self.workbook = load_workbook(self.filename)
self.ws = self.workbook.active
int_time = str(int_time)
int_dictionary = {"229":0.131, "230":1.049, "232":0.262, "233":0.131, "234":1.049,
"235": 0.262, "236":0.131, "238": 0.262}
if int_time in int_dictionary:
self.inttime = int_dictionary[int_time]
else: print "Int_time not available"