-
Notifications
You must be signed in to change notification settings - Fork 42
/
thellier_gui_dialogs.py
executable file
·2056 lines (1658 loc) · 96.7 KB
/
thellier_gui_dialogs.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 python
#============================================================================================
# LOG HEADER:
#
# Dialogs boxes for thellier_gui.py
#
#============================================================================================
#
# 11/16/2014 add some units to criteria dialogs
#
# 11/08/2014 Version add k_prime description
#
# 08/08/2014 Version add k_prime description
#
# 3/22/2014 Version 1.0 by Ron Shaar
#
#
#============================================================================================
#--------------------------------------------------------------
# Thellier GUI dialog
#--------------------------------------------------------------
import matplotlib
#matplotlib.use('WXAgg')
import pmag
import wx
import copy
import os
import scipy
from scipy import arange
# only this one is nessesary.
import wx
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigCanvas \
#--------------------------------------------------------------
# paleointensity statistics list (SPD.v.1.0)
#--------------------------------------------------------------
class PI_Statistics_Dialog(wx.Dialog):
def __init__(self, parent, show_statistics_on_gui,title):
style = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER
super(PI_Statistics_Dialog, self).__init__(parent, title=title,style=style)
self.show_statistics_on_gui=copy.copy(show_statistics_on_gui)
self.stat_by_category={}
self.stat_by_category['Arai plot']=['specimen_int_n',
'specimen_frac','specimen_f','specimen_fvds',
'specimen_b_sigma','specimen_b_beta','specimen_scat',
'specimen_g','specimen_gmax',
'specimen_k','specimen_k_sse',
'specimen_k_prime','specimen_k_prime_sse',
'specimen_z','specimen_z_md',
'specimen_q',
'specimen_r_sq','specimen_coeff_det_sq',
]
self.stat_by_category['Direction']=['specimen_int_mad','specimen_int_mad_anc','specimen_int_dang','specimen_int_alpha','specimen_alpha_prime','specimen_theta','specimen_int_crm','specimen_gamma']
self.stat_by_category['pTRM Checks']=['specimen_int_ptrm_n','specimen_ptrm','specimen_drat','specimen_drats','specimen_cdrat','specimen_mdrat',
'specimen_dck','specimen_maxdev','specimen_mdev','specimen_dpal']
self.stat_by_category['Tail Checks']=['specimen_int_ptrm_tail_n','specimen_md','specimen_tail_drat','specimen_dtr','specimen_dt']
self.stat_by_category['Additivity Checks']=['specimen_ac_n','specimen_dac']
self.DESC={}
self.DESC['specimen_frac']='The angle between the applied field direction and the ChRM direction of the NRM as determined from the free-floating PCA fit to the selected demagnetization steps of the paleointensity experiment'
self.DESC['specimen_int_n']='Number of measurements included in field strength calculations'
self.DESC['specimen_alpha_prime']='Angular difference between the anchored best-fit direction from the paleointensity experiment and an independent measure of the paleomagnetic direction'
self.DESC['specimen_alpha']='Angular difference between the anchored and free-floating best-fit directions on a vector component diagram'
self.DESC['specimen_int_alpha']='Angular difference between the anchored and free-floating best-fit directions on a vector component diagram from a paleointensity experiment'
self.DESC['specimen_mad']='Maximum Angular Deviation (MAD) of the free-floating directional PCA fits to the paleomagnetic vector'
self.DESC['specimen_mad_anc']='Maximum Angular Deviation (MAD) of the anchored directional PCA fits to the paleomagnetic vector'
self.DESC['specimen_int_mad']='Maximum Angular Deviation (MAD) of the free-floating directional PCA fits to the paleomagnetic vector from a paleointensity experiment'
self.DESC['specimen_int_mad_anc']='Maximum Angular Deviation (MAD) of the anchored directional PCA fits to the paleomagnetic vector from a paleointensity experiment'
self.DESC['specimen_w']='Weighting factor'
self.DESC['specimen_q']='A measure of the overall quality of the paleointensity estimate and combines the relative scatter of the best-fit line, the NRM fraction and the gap factor'
self.DESC['specimen_f']='NRM fraction used for the best-fit on an Arai plot '
self.DESC['specimen_fvds']='NRM fraction used for the best-fit on an Arai plot calculated as a vector difference sum'
self.DESC['specimen_b']='The slope of the best-fit line of the selected TRM and NRM points on an Arai plot'
self.DESC['specimen_b_sigma']='The standard error on the slope on an Arai plot'
self.DESC['specimen_b_beta']='The ratio of the standard error of the slope to the absolute value of the slope on an Arai plot'
self.DESC['specimen_g']='The gap reflects the average spacing of the selected Arai plot points along the best-fit line'
self.DESC['specimen_gmax']='The maximum gap between two points in Arai plot determined by vector arithmetic'
self.DESC['specimen_r_sq']='The squared correlation coefficient to estimate the strength of the linear relationship between the NRM and TRM over the best-fit Arai plot segment'
self.DESC['specimen_coeff_det_sq']='The squared coefficient of determination to estimate variance accounted for by the linear model fit on an Arai plot'
self.DESC['specimen_dang']='Deviation angle of direction of component with respect to origin'
self.DESC['specimen_int_dang']='The angle between the free-floating best-fit direction and the vector connecting the center of mass and the origin of the vector component diagram'
self.DESC['specimen_int_crm']='The cumulative deflection between the NRM vectors and the ChRM direction'
self.DESC['specimen_int_ptrm_tail_n']='Number of pTRM tail checks used in paleointensity experiment'
self.DESC['specimen_md']='Maximum absolute difference produced by a pTRM tail check, normalized by the vector difference sum of the NRM'
self.DESC['specimen_tail_drat']='Maximum absolute difference produced by a pTRM tail check, normalized by the length of the best-fit line'
self.DESC['specimen_dtr']='Maximum absolute difference produced by a pTRM tail check, normalized by the NRM (obtained from the intersection of the best-fit line and the y-axis on an Arai plot)'
self.DESC['specimen_int_ptrm_n']='Number of pTRM checks used in paleointensity experiment'
self.DESC['specimen_ptrm']='Maximum absolute difference produced by a pTRM check, normalized by the TRM acquired at that heating step'
self.DESC['specimen_dck']='Maximum absolute difference produced by a pTRM check, normalized by the total TRM (obtained from the intersection of the best-fit line and the x-axis on an Arai plot)'
self.DESC['specimen_maxdev']='Maximum absolute difference produced by a pTRM check, normalized by the length of the TRM segment of the best-fit line on an Arai plot'
self.DESC['specimen_drat']='Maximum absolute difference produced by a pTRM check, normalized by the length of the best-fit line'
self.DESC['specimen_mdrat']='The average difference produced by a pTRM check, normalized by the length of the best-fit line'
self.DESC['specimen_cdrat']='Cumulative difference ratio difference produced by a pTRM check'
self.DESC['specimen_drats']='Cumulative pTRM check difference normalized by the pTRM gained at the maximum temperature used for the best-fit on the Arai plot'
self.DESC['specimen_mdev']='Mean deviation of a pTRM check'
self.DESC['specimen_dpal']='A measure of cumulative alteration determined by the difference of the alteration corrected intensity estimate (Valet et al., 1996) and the uncorrected estimate, normalized by the uncorrected estimate (Leonhardt et al., 2004a)'
self.DESC['specimen_dt']='The extent of a pTRM tail after correction for angular dependence'
self.DESC['specimen_dac']='The maximum absolute additivity check difference normalized by the total TRM (obtained from the intersection of the best-fit line and the x-axis on an Arai plot'
self.DESC['specimen_ac_n']='The number of additivity checks used to analyze the best-fit segment on an Arai plot'
self.DESC['specimen_k']='The curvature of the Arai plot as determined by the best-fit circle to all of the data '
self.DESC['specimen_k_sse']='The quality of the best-fit circle used to determine k'
self.DESC['specimen_k_prime']='The curvature of the Arai plot as determined by the best-fit circle to the selected data points'
self.DESC['specimen_k_prime_sse']='The quality of the best-fit circle used to determine k_prime'
self.DESC['specimen_z']='Arai plot zigzag parameter calculated using the scatter around the best-fit slope on an Arai plot'
self.DESC['specimen_z_md']='Arai plot zigzag parameter calculated by the area bounded by the curve that the ZI points make and the curve that the IZ points make'
self.DESC['specimen_scat']='All pTRM checks, MD checks, IZ ZI data, etc. are in the box (g = good or b=bad)'
self.DESC['specimen_viscosity_index']='Viscosity index'
self.DESC['specimen_lab_field_dc']='Applied DC field in laboratory'
self.DESC['specimen_lab_field_ac']='Applied maximum or peak AC field in laboratory'
self.DESC['specimen_magn_moment']='Measured magnetic moment'
self.DESC['specimen_magn_volume']='Measured intensity of magnetization, Volume normalized'
self.DESC['specimen_magn_mass']='Measured intensity of magnetization, Mass normalized'
self.DESC['specimen_int_corr_cooling_rate']='Cooling rate correction factor for intensity'
self.DESC['specimen_int_corr_anisotropy']='Anisotropy correction factor for intensity'
self.DESC['specimen_int_corr_nlt']='Non-linear TRM correction factor for intensity'
self.DESC['specimen_delta']='Maximum angle of deviation between assumed NRM and measured NRM in perpendicular paleointensity method'
self.DESC['specimen_theta']='The angle between the applied field direction and the ChRM direction of the NRM as determined from the free-floating PCA fit to the selected demagnetization steps of the paleointensity experiment'
self.DESC['specimen_gamma']='Maximum angle of deviation between acquired pTRM direction and assumed applied field direction'
self.InitUI()
self.initialize_stat()
def InitUI(self):
pnl1 = wx.Panel(self)
vbox = wx.BoxSizer(wx.VERTICAL)
#============================
# design the panel
#============================
#---------------------------
# sizer 1
# Specimen criteria
#---------------------------
categories=['Arai plot','Direction','pTRM Checks','Tail Checks','Additivity Checks']
for k in range(len(categories)):
command = "bSizer%i = wx.StaticBoxSizer( wx.StaticBox( pnl1, wx.ID_ANY, '%s' ), wx.VERTICAL )"%(k,categories[k])
exec command
for stat in self.stat_by_category[categories[k]]:
short_name=stat.replace("specimen_","")
command="self.set_specimen_%s=wx.CheckBox(pnl1,-1,label='%s',name='%s')"%(short_name,short_name,short_name)
exec command
command = "self.Bind(wx.EVT_CHECKBOX, self.OnCheckBox, self.set_specimen_%s)"%(short_name)
exec command
command="self.specimen_%s_button = wx.Button(pnl1, -1, label='description',name='%s')" %(short_name,stat)
exec command
command = "self.Bind(wx.EVT_BUTTON,self.PI_stat_description, self.specimen_%s_button)"%(short_name)
exec command
for i in range(len(self.stat_by_category[categories[k]])):
command="hbox_%i= wx.BoxSizer(wx.HORIZONTAL)"%i
exec command
stat=self.stat_by_category[categories[k]][i]
short_name=stat.replace("specimen_","")
command="hbox_%i.Add(self.specimen_%s_button)"%(i,short_name)
exec command
command="hbox_%i.AddSpacer(10)"%(i)
exec command
command="hbox_%i.Add(self.set_specimen_%s)"%(i,short_name)
exec command
command="bSizer%i.Add(hbox_%i)"%(k,i)
exec command
command="bSizer%i.AddSpacer(10)"%k
exec command
#self.specimen_int_n_button.Bind(wx.EVT_BUTTON, lambda evt, name=specimen_int_n_button.GetLabel(): self.onButton(evt, name)
#self.Bind(wx.EVT_BUTTON,self.PI_stat_description, self.specimen_int_n_button)
#---------------------------
# OK / CANCEL
#---------------------------
hbox_OK_CANCEL = wx.BoxSizer(wx.HORIZONTAL)
self.okButton = wx.Button(pnl1, wx.ID_OK, "&OK")
self.cancelButton = wx.Button(pnl1, wx.ID_CANCEL, '&Cancel')
hbox_OK_CANCEL.Add(self.okButton)
hbox_OK_CANCEL.AddSpacer(10)
hbox_OK_CANCEL.Add(self.cancelButton )
#============================
# arrange sizers
#============================
hbox= wx.BoxSizer(wx.HORIZONTAL)
hbox.AddSpacer(10)
hbox.Add(bSizer0, flag=wx.ALIGN_CENTER_HORIZONTAL)
hbox.AddSpacer(10)
hbox.Add(bSizer1, flag=wx.ALIGN_CENTER_HORIZONTAL)
hbox.AddSpacer(10)
hbox.Add(bSizer2, flag=wx.ALIGN_CENTER_HORIZONTAL)
hbox.AddSpacer(10)
hbox.Add(bSizer3, flag=wx.ALIGN_CENTER_HORIZONTAL)
hbox.AddSpacer(10)
hbox.Add(bSizer4, flag=wx.ALIGN_CENTER_HORIZONTAL)
hbox.AddSpacer(10)
vbox.AddSpacer(10)
vbox.Add(hbox, flag=wx.ALIGN_CENTER_HORIZONTAL)
vbox.AddSpacer(10)
vbox.Add(hbox_OK_CANCEL, flag=wx.ALIGN_CENTER_HORIZONTAL)
vbox.AddSpacer(10)
pnl1.SetSizer(vbox)
vbox.Fit(self)
def initialize_stat(self):
categories=['Arai plot','Direction','pTRM Checks','Tail Checks','Additivity Checks']
for short_name in self.show_statistics_on_gui:
for category in categories:
if "specimen_" + short_name in self.stat_by_category[category]:
command="self.set_specimen_%s.SetValue(True)"%short_name
exec command
def PI_stat_description(self,event):
button = event.GetEventObject()
crit=button.GetName()
TEXT=self.DESC[crit]
TEXT=TEXT+"\n\n"
TEXT=TEXT+"For more details see:\n http://www.paleomag.net/SPD"
dlg1 = wx.MessageDialog(None,caption=crit, message=TEXT ,style=wx.OK|wx.ICON_INFORMATION)
dlg1.ShowModal()
dlg1.Destroy()
def OnCheckBox(self,event):
checkbox= event.GetEventObject()
if checkbox.GetValue()==True:
crit=str(checkbox.GetName())
if crit not in self.show_statistics_on_gui:
self.show_statistics_on_gui.append(crit)
if checkbox.GetValue()==False:
crit=str(checkbox.GetName())
if crit in self.show_statistics_on_gui:
self.show_statistics_on_gui.remove(crit)
# arrange_all_statistics in order:
tmp_list=copy.copy(self.show_statistics_on_gui)
self.show_statistics_on_gui=[]
categories=['Arai plot','Direction','pTRM Checks','Tail Checks','Additivity Checks']
for category in categories:
for stat in self.stat_by_category[category]:
short_name=str(stat.replace("specimen_",""))
if short_name in tmp_list:
self.show_statistics_on_gui.append(short_name)
#--------------------------------------------------------------
# Change Acceptance criteria dialog
#--------------------------------------------------------------
class Criteria_Dialog(wx.Dialog):
def __init__(self, parent, acceptance_criteria,preferences,title):
style = wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER
super(Criteria_Dialog, self).__init__(parent, title=title,style=style)
self.acceptance_criteria=acceptance_criteria
self.preferences=preferences
self.InitUI()
def InitUI(self):
pnl1 = wx.Panel(self)
vbox = wx.BoxSizer(wx.VERTICAL)
#============================
# design the panel
#============================
#---------------------------
# sizer 1
# Specimen criteria
#---------------------------
bSizer1 = wx.StaticBoxSizer( wx.StaticBox( pnl1, wx.ID_ANY, "specimen acceptance criteria" ), wx.HORIZONTAL )
hbox_criteria = wx.BoxSizer(wx.HORIZONTAL)
window_list_specimens=self.preferences['show_statistics_on_gui']
for stat in window_list_specimens:
if stat=='scat':
self.set_specimen_scat=wx.CheckBox(pnl1, -1, '')
else:
command="self.set_specimen_%s=wx.TextCtrl(pnl1,style=wx.TE_CENTER,size=(50,20))"%stat
exec command
command="self.%s_label=wx.StaticText(pnl1,label='%s',style=wx.ALIGN_CENTRE)"%(stat,stat.replace("specimen_",""))
exec command
command="gs_%s = wx.GridSizer(2, 1,5,5)"%stat
exec command
command="gs_%s.AddMany( [(self.%s_label,wx.EXPAND),(self.set_specimen_%s,wx.EXPAND)])"%(stat,stat,stat)
exec command
command="bSizer1.Add(gs_%s,flag=wx.ALIGN_LEFT)"%stat
exec command
bSizer1.AddSpacer(12)
#criteria_specimen_window = wx.GridSizer(2, 14, 6, 6)
#criteria_specimen_window.AddMany( [(wx.StaticText(pnl1,label="int_n",style=wx.TE_CENTER), wx.EXPAND),
# (wx.StaticText(pnl1,label="int_ptrm_n",style=wx.TE_CENTER), wx.EXPAND),
# (wx.StaticText(pnl1,label="FRAC",style=wx.TE_CENTER), wx.EXPAND),
# (wx.StaticText(pnl1,label="SCAT",style=wx.TE_CENTER), wx.EXPAND),
# (wx.StaticText(pnl1,label="gap_max",style=wx.TE_CENTER), wx.EXPAND),
# (wx.StaticText(pnl1,label="f",style=wx.TE_CENTER), wx.EXPAND),
# (wx.StaticText(pnl1,label="fvds",style=wx.TE_CENTER), wx.EXPAND),
# (wx.StaticText(pnl1,label="beta",style=wx.TE_CENTER), wx.EXPAND),
# (wx.StaticText(pnl1,label="g",style=wx.TE_CENTER), wx.EXPAND),
# (wx.StaticText(pnl1,label="q",style=wx.TE_CENTER), wx.EXPAND),
# (wx.StaticText(pnl1,label="MAD",style=wx.TE_CENTER), wx.EXPAND),
# (wx.StaticText(pnl1,label="DANG",style=wx.TE_CENTER), wx.EXPAND),
# (wx.StaticText(pnl1,label="DRATS",style=wx.TE_CENTER), wx.EXPAND),
# (wx.StaticText(pnl1,label="MD tail",style=wx.TE_CENTER), wx.EXPAND),
# (self.set_specimen_int_n),
# (self.set_specimen_int_ptrm_n),
# (self.set_specimen_frac),
# (self.set_specimen_scat),
# (self.set_specimen_gmax),
# (self.set_specimen_f),
# (self.set_specimen_fvds),
# (self.set_specimen_b_beta),
# (self.set_specimen_g),
# (self.set_specimen_q),
# (self.set_specimen_int_mad),
# (self.set_specimen_int_dang),
# (self.set_specimen_drats),
# (self.set_specimen_md)])
# bSizer1.Add( criteria_specimen_window, 0, wx.ALIGN_LEFT|wx.ALL, 5 )
#---------------------------
# anistropy criteria
#---------------------------
bSizer1a = wx.StaticBoxSizer( wx.StaticBox( pnl1, wx.ID_ANY, "anisotropy criteria" ), wx.HORIZONTAL )
self.set_anisotropy_alt=wx.TextCtrl(pnl1,style=wx.TE_CENTER,size=(50,20))
#self.set_anisotropy_ftest=wx.ComboBox(self.panel, -1, value='None', choices=["None","pass 95%"],style=wx.CB_DROPDOWN,name="aniso-ftest")
self.set_anisotropy_ftest_flag= wx.CheckBox(pnl1, -1, '', (10, 10))
criteria_aniso_window = wx.GridSizer(2, 2, 6, 6)
criteria_aniso_window.AddMany( [(wx.StaticText(pnl1,label="use F test as acceptance criteria",style=wx.TE_CENTER), wx.EXPAND),
(wx.StaticText(pnl1,label="alteration check (%)",style=wx.TE_CENTER), wx.EXPAND),
(self.set_anisotropy_ftest_flag),
(self.set_anisotropy_alt)])
bSizer1a.Add( criteria_aniso_window, 0, wx.ALIGN_LEFT|wx.ALL, 5 )
#---------------------------
# sample/site criteria
#---------------------------
bSizer2 = wx.StaticBoxSizer( wx.StaticBox( pnl1, wx.ID_ANY, "sample/Site acceptance criteria" ), wx.HORIZONTAL )
self.set_average_by_sample_or_site=wx.ComboBox(pnl1, -1,size=(150, -1), value = 'sample', choices=['sample','site'], style=wx.CB_READONLY)
# Sample criteria
window_list_samples=['int_n','int_n_outlier_check']
for key in window_list_samples:
command="self.set_sample_%s=wx.TextCtrl(pnl1,style=wx.TE_CENTER,size=(50,20))"%key
exec command
criteria_sample_window = wx.GridSizer(2, 3, 6, 6)
criteria_sample_window.AddMany( [(wx.StaticText(pnl1,label="averge by sample/site",style=wx.TE_CENTER), wx.EXPAND),
(wx.StaticText(pnl1,label="int_n",style=wx.TE_CENTER), wx.EXPAND),
(wx.StaticText(pnl1,label="int_n_outlier_check",style=wx.TE_CENTER), wx.EXPAND),
(self.set_average_by_sample_or_site),
(self.set_sample_int_n),
(self.set_sample_int_n_outlier_check)])
bSizer2.Add( criteria_sample_window, 0, wx.ALIGN_LEFT|wx.ALL, 5 )
#---------------------------
# thellier interpreter calculation type
#---------------------------
bSizer2a = wx.StaticBoxSizer( wx.StaticBox( pnl1, wx.ID_ANY, "mean calculation algorithm" ), wx.HORIZONTAL )
self.set_stdev_opt=wx.RadioButton(pnl1, -1, '', (10, 10), style=wx.RB_GROUP)
self.set_bs=wx.RadioButton(pnl1, -1, ' ', (10, 30))
self.set_bs_par=wx.RadioButton(pnl1, -1, '', (50, 50))
self.set_include_nrm= wx.CheckBox(pnl1, -1, '', (10, 10))
criteria_sample_window = wx.GridSizer(2, 4, 6, 6)
criteria_sample_window.AddMany( [(wx.StaticText(pnl1,label="Enable STDEV-OPT",style=wx.TE_CENTER), wx.EXPAND),
(wx.StaticText(pnl1,label="Enable BS",style=wx.TE_CENTER), wx.EXPAND),
(wx.StaticText(pnl1,label="Enable BS_PAR",style=wx.TE_CENTER), wx.EXPAND),
(wx.StaticText(pnl1,label="include NRM",style=wx.TE_CENTER), wx.EXPAND),
(self.set_stdev_opt),
(self.set_bs),
(self.set_bs_par),
(self.set_include_nrm)])
bSizer2a.Add( criteria_sample_window, 0, wx.ALIGN_LEFT|wx.ALL, 5 )
#---------------------------
# sample/site criteria
#---------------------------
bSizer3 = wx.StaticBoxSizer( wx.StaticBox( pnl1, wx.ID_ANY, "sample/site acceptance criteria: STDEV-OPT" ), wx.HORIZONTAL )
# Sample STEV-OPT
window_list_samples=['int_sigma_uT','int_sigma_perc','int_interval_uT','int_interval_perc','aniso_mean']
for key in window_list_samples:
command="self.set_sample_%s=wx.TextCtrl(pnl1,style=wx.TE_CENTER,size=(50,20))"%key
exec command
criteria_sample_window_2 = wx.GridSizer(2, 5, 6, 6)
criteria_sample_window_2.AddMany( [(wx.StaticText(pnl1,label="int_sigma_uT",style=wx.TE_CENTER), wx.EXPAND),
(wx.StaticText(pnl1,label="int_sigma_perc",style=wx.TE_CENTER), wx.EXPAND),
(wx.StaticText(pnl1,label="int_interval",style=wx.TE_CENTER), wx.EXPAND),
(wx.StaticText(pnl1,label="int_interval_perc",style=wx.TE_CENTER), wx.EXPAND),
(wx.StaticText(pnl1,label="sample aniso mean (%)",style=wx.TE_CENTER), wx.EXPAND),
(self.set_sample_int_sigma_uT),
(self.set_sample_int_sigma_perc),
(self.set_sample_int_interval_uT),
(self.set_sample_int_interval_perc),
(self.set_sample_aniso_mean)])
bSizer3.Add( criteria_sample_window_2, 0, wx.ALIGN_LEFT|wx.ALL, 5 )
#---------------------------
# bootstrap criteria
#---------------------------
bSizer4 = wx.StaticBoxSizer( wx.StaticBox( pnl1, wx.ID_ANY, "sample Acceptance criteria: BS / BS-PAR" ), wx.HORIZONTAL )
window_list_samples=['int_BS_68_uT','int_BS_68_perc','int_BS_95_uT','int_BS_95_perc']
for key in window_list_samples:
command="self.set_sample_%s=wx.TextCtrl(pnl1,style=wx.TE_CENTER,size=(50,20))"%key
exec command
# for bootstarp
self.set_specimen_int_max_slope_diff=wx.TextCtrl(pnl1,style=wx.TE_CENTER,size=(50,20))
criteria_sample_window_3 = wx.GridSizer(2, 5, 6, 6)
criteria_sample_window_3.AddMany( [(wx.StaticText(pnl1,label="specimen_int_max_slope_diff",style=wx.TE_CENTER), wx.EXPAND),
(wx.StaticText(pnl1,label="int_BS_68_uT",style=wx.TE_CENTER), wx.EXPAND),
(wx.StaticText(pnl1,label="int_BS_68_perc",style=wx.TE_CENTER), wx.EXPAND),
(wx.StaticText(pnl1,label="int_BS_95_uT",style=wx.TE_CENTER), wx.EXPAND),
(wx.StaticText(pnl1,label="int_BS_95_perc",style=wx.TE_CENTER), wx.EXPAND),
(self.set_specimen_int_max_slope_diff),
(self.set_sample_int_BS_68_uT),
(self.set_sample_int_BS_68_perc),
(self.set_sample_int_BS_95_uT),
(self.set_sample_int_BS_95_perc)])
bSizer4.Add( criteria_sample_window_3, 0, wx.ALIGN_LEFT|wx.ALL, 5 )
#---------------------------
# OK / CANCEL
#---------------------------
hbox3 = wx.BoxSizer(wx.HORIZONTAL)
self.okButton = wx.Button(pnl1, wx.ID_OK, "&OK")
self.cancelButton = wx.Button(pnl1, wx.ID_CANCEL, '&Cancel')
hbox3.Add(self.okButton)
hbox3.AddSpacer(10)
hbox3.Add(self.cancelButton )
#============================
# Intialize values
#============================
for key in window_list_specimens:
command="self.set_specimen_%s.SetBackgroundColour(wx.NullColour)"%key
exec command
#-------------------------------------------
# Intialize values: specimen criteria window
#-------------------------------------------
#criteria_list_for_window=['specimen_gmax','specimen_b_beta','specimen_int_dang','specimen_drats','specimen_int_mad','specimen_md']+\
#['specimen_int_n','specimen_int_ptrm_n','specimen_f','specimen_fvds','specimen_frac','specimen_g','specimen_q']
criteria_list_for_window=self.preferences['show_statistics_on_gui']
for crit in criteria_list_for_window:
value=""
crit="specimen_"+crit
if crit!="specimen_scat":
if self.acceptance_criteria[crit]['value']==-999:
value=""
elif type(self.acceptance_criteria[crit]['threshold_type'])==list:
if type(self.acceptance_criteria[crit]['value'])==str:
value=self.acceptance_criteria[crit]['value']
elif type(self.acceptance_criteria[crit]['value'])==float or type(self.acceptance_criteria[crit]['value'])==int:
if self.acceptance_criteria[crit]['decimal_points']!=-999:
command="value='%%.%if'%%(self.acceptance_criteria[crit]['value'])"%int(self.acceptance_criteria[crit]['decimal_points'])
exec command
else:
value="%.3e"%(self.acceptance_criteria[crit]['value'])
command="self.set_%s.SetValue(value)"%crit
exec command
else:
if self.acceptance_criteria['specimen_scat']['value'] in [True,1,"True","TRUE","1","1.0",'g']:
self.set_specimen_scat.SetValue(True)
else:
self.set_specimen_scat.SetValue(False)
#-------------------------------------------
# Intialize values: anisotropy window
#-------------------------------------------
crit="anisotropy_alt"
if self.acceptance_criteria[crit]['value']==-999:
value=""
else:
command="value='%%.%if'%%(self.acceptance_criteria[crit]['value'])"%int(self.acceptance_criteria[crit]['decimal_points'])
exec command
self.set_anisotropy_alt.SetValue(value)
crit="anisotropy_ftest_flag"
if self.acceptance_criteria[crit]['value'] in [True,1,"True","TRUE","1","1.0",'g']:
self.set_anisotropy_ftest_flag.SetValue(True)
else:
self.set_anisotropy_ftest_flag.SetValue(False)
#-------------------------------------------
# Intialize values: avearge by site or sample
#-------------------------------------------
if 'average_by_sample_or_site' not in self.acceptance_criteria.keys():self.acceptance_criteria['average_by_sample_or_site']['value']='site'
if str(self.acceptance_criteria['average_by_sample_or_site']['value'])=='site':
self.set_average_by_sample_or_site.SetStringSelection('site')
else:
self.set_average_by_sample_or_site.SetStringSelection('sample')
#-------------------------------------------
# Intialize values: sample/site criteria method codes
#-------------------------------------------
if self.acceptance_criteria['interpreter_method']=="bs":
self.set_bs.SetValue(True)
elif self.acceptance_criteria['interpreter_method']=="bs_par":
self.set_bs_par.SetValue(True)
else:
self.set_stdev_opt.SetValue(True)
#-------------------------------------------
# Intialize values: include NRM
#-------------------------------------------
self.set_include_nrm.SetValue(True)
#-------------------------------------------
# Intialize values: sample/site criteria
#-------------------------------------------
criteria_list_for_window=[]+\
['sample_int_n','sample_int_sigma','sample_int_sigma_perc','sample_int_n_outlier_check']+\
['site_int_n','site_int_sigma','site_int_sigma_perc','site_int_n_outlier_check']+\
['sample_aniso_mean','site_aniso_mean']+\
['sample_int_interval_uT','sample_int_interval_perc']+\
['sample_int_BS_68_uT','sample_int_BS_95_uT','sample_int_BS_68_perc','sample_int_BS_95_perc']
for crit in criteria_list_for_window:
# check if averaging by site or sample
if self.acceptance_criteria['average_by_sample_or_site']['value']=='site':
if 'sample' in crit:
continue
else:
if 'site' in crit:
continue
#--------------
# get the value to write
if self.acceptance_criteria[crit]['value']==-999:
value=""
elif crit in ['sample_int_sigma','site_int_sigma']:
value="%.1f"%(float(self.acceptance_criteria[crit]['value'])*1e6)
elif type(self.acceptance_criteria[crit]['value'])==float or type(self.acceptance_criteria[crit]['value'])==int :
command="value='%%.%if'%%(self.acceptance_criteria[crit]['value'])"%int(self.acceptance_criteria[crit]['decimal_points'])
exec command
elif type(self.acceptance_criteria[crit]['value'])==bool:
value="%.s"%str(self.acceptance_criteria[crit]['value'])
elif type(self.acceptance_criteria[crit]['value'])==str:
value=str(self.acceptance_criteria[crit]['value'])
#-------
# write the value to box
if str(self.acceptance_criteria['average_by_sample_or_site']['value'])=='site':
if crit in ['site_int_n','site_int_sigma_perc','site_int_n_outlier_check','site_aniso_mean']:
command="self.set_%s.SetValue(value)"%(crit.replace('site','sample'))
exec command
if crit in ['site_int_sigma']:
command="self.set_%s_uT.SetValue(value)"%(crit.replace('site','sample'))
exec command
else:
if crit in ['sample_int_sigma']:
command="self.set_%s_uT.SetValue(value)"%crit
else:
command="self.set_%s.SetValue(value)"%crit
exec command
#============================
# arrange sizers
#============================
vbox.AddSpacer(10)
vbox.Add(bSizer1, flag=wx.ALIGN_CENTER_HORIZONTAL)
vbox.AddSpacer(10)
vbox.Add(bSizer1a, flag=wx.ALIGN_CENTER_HORIZONTAL)
vbox.AddSpacer(10)
vbox.Add(bSizer2, flag=wx.ALIGN_CENTER_HORIZONTAL)
vbox.AddSpacer(10)
vbox.Add(bSizer2a, flag=wx.ALIGN_CENTER_HORIZONTAL)
vbox.AddSpacer(10)
vbox.Add(bSizer3, flag=wx.ALIGN_CENTER_HORIZONTAL)
vbox.AddSpacer(10)
vbox.Add(bSizer4, flag=wx.ALIGN_CENTER_HORIZONTAL)
vbox.AddSpacer(10)
vbox.Add(hbox3, flag=wx.ALIGN_CENTER_HORIZONTAL)
vbox.AddSpacer(10)
pnl1.SetSizer(vbox)
vbox.Fit(self)
#--------------------------------------------------------------
# Show a table
#--------------------------------------------------------------
class MyForm(wx.Frame):
""""""
#----------------------------------------------------------------------
def __init__(self,number_of_rows_to_ignore,file_name):
"""Constructor"""
wx.Frame.__init__(self, parent=None, title=file_name.split('/')[-1])
panel = wx.Panel(self)
self.read_the_file(file_name)
self.myGrid = wx.grid.Grid(panel)
self.myGrid.CreateGrid(len(self.report)-number_of_rows_to_ignore-1, len(self.report[number_of_rows_to_ignore]))
index=0
for i in range(len(self.report[number_of_rows_to_ignore])):
self.myGrid.SetColLabelValue(i, self.report[number_of_rows_to_ignore][i])
for i in range(1+number_of_rows_to_ignore,len(self.report)):
for j in range(len(self.report[i])):
self.myGrid.SetCellValue(index,j, self.report[i][j])
index+=1
self.myGrid.SetLabelFont(wx.Font(9, wx.SWISS, wx.NORMAL, wx.NORMAL, False, u'Arial'))
self.myGrid.SetDefaultCellFont(wx.Font(9, wx.SWISS, wx.NORMAL, wx.NORMAL, False, u'Arial'))
self.myGrid.AutoSize()
#myGrid.SetRowLabelSize(0)
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(self.myGrid, 1, wx.EXPAND)
#sizer.Fit(self)
panel.SetSizer(sizer)
def read_the_file(self,file_name):
## dlg = wx.FileDialog(
## self, message="choose a file in a pmagpy redo format",
## style=wx.OPEN | wx.CHANGE_DIR
## )
## if dlg.ShowModal() == wx.ID_OK:
## interpreter_output= dlg.GetPath()
## dlg.Destroy()
fin=open(str(file_name),'rU')
self.report=[]
for L in fin.readlines():
line=L.strip('\n').split('\t')
self.report.append(line)
#--------------------------------------------------------------
# Save plots
#--------------------------------------------------------------
class SaveMyPlot(wx.Frame):
""""""
def __init__(self,fig,pars,plot_type):
"""Constructor"""
wx.Frame.__init__(self, parent=None, title="")
file_choices="(*.pdf)|*.pdf|(*.svg)|*.svg| (*.png)|*.png"
default_fig_name="%s_%s.pdf"%(pars['er_specimen_name'],plot_type)
dlg = wx.FileDialog(
self,
message="Save plot as...",
defaultDir=os.getcwd(),
defaultFile=default_fig_name,
wildcard=file_choices,
style=wx.SAVE)
if dlg.ShowModal() == wx.ID_OK:
path = dlg.GetPath()
title=pars['er_specimen_name']
self.panel = wx.Panel(self)
self.dpi=300
canvas_tmp_1 = FigCanvas(self.panel, -1, fig)
canvas_tmp_1.print_figure(path, dpi=self.dpi)
#----------------------------------------------------------------------
#===========================================================
# Consistency Test
#===========================================================
class Consistency_Test(wx.Frame):
""""""
#----------------------------------------------------------------------
def __init__(self,Data,Data_hierarchy,WD,acceptance_criteria,preferences,Thermal,Microwave):
wx.Frame.__init__(self, parent=None)
"""
"""
import thellier_consistency_test
self.WD=WD
self.Data=Data
self.Data_hierarchy=Data_hierarchy
self.acceptance_criteria=acceptance_criteria
self.preferences=preferences
self.panel = wx.Panel(self)
self.make_fixed_criteria()
self.init_optimizer_frame()
global THERMAL
global MICROWAVE
THERMAL = Thermal
MICROWAVE = Microwave
def make_fixed_criteria(self):
Text="Choose fixed acceptance criteria"
dlg = wx.MessageDialog(self, Text, caption="First step", style=wx.OK )
dlg.ShowModal(); dlg.Destroy()
#self.fixed_criteria['specimen_frac']=0
#self.fixed_criteria['specimen_b_beta']=10000000
dia = Criteria_Dialog(None, self.acceptance_criteria,self.preferences,title='Set fixed_criteria_file')
dia.Center()
if dia.ShowModal() == wx.ID_OK: # Until the user clicks OK, show the message
self.On_close_fixed_criteria_box(dia)
def On_close_fixed_criteria_box(self,dia):
"""
after criteria dialog window is closed.
Take the acceptance criteria values and update
self.acceptance_criteria
"""
criteria_list=self.acceptance_criteria.keys()
criteria_list.sort()
#---------------------------------------
# check if averaging by sample or by site
# and intialize sample/site criteria
#---------------------------------------
if dia.set_average_by_sample_or_site.GetValue()=='sample':
for crit in ['site_int_n','site_int_sigma','site_int_sigma_perc','site_aniso_mean','site_int_n_outlier_check']:
self.acceptance_criteria[crit]['value']=-999
if dia.set_average_by_sample_or_site.GetValue()=='site':
for crit in ['sample_int_n','sample_int_sigma','sample_int_sigma_perc','sample_aniso_mean','sample_int_n_outlier_check']:
self.acceptance_criteria[crit]['value']=-999
#---------
for i in range(len(criteria_list)):
crit=criteria_list[i]
#---------
# get the "value" from dialog box
#---------
# dealing with sample/site
if dia.set_average_by_sample_or_site.GetValue()=='sample':
if crit in ['site_int_n','site_int_sigma','site_int_sigma_perc','site_aniso_mean','site_int_n_outlier_check']:
continue
if dia.set_average_by_sample_or_site.GetValue()=='site':
if crit in ['sample_int_n','sample_int_sigma','sample_int_sigma_perc','sample_aniso_mean','sample_int_n_outlier_check']:
continue
#------
if crit in ['site_int_n','site_int_sigma_perc','site_aniso_mean','site_int_n_outlier_check']:
command="value=dia.set_%s.GetValue()"%crit.replace('site','sample')
elif crit=='sample_int_sigma' or crit=='site_int_sigma':
#command="value=float(dia.set_sample_int_sigma_uT.GetValue())*1e-6"
command="value=dia.set_%s.GetValue()"%crit
else:
command="value=dia.set_%s.GetValue()"%crit
#------
try:
exec command
except:
continue
#---------
# write the "value" to self.acceptance_criteria
#---------
if crit=='average_by_sample_or_site':
self.acceptance_criteria[crit]['value']=str(value)
continue
if type(value)==bool and value==True:
self.acceptance_criteria[crit]['value']=True
elif type(value)==bool and value==False:
self.acceptance_criteria[crit]['value']=-999
elif type(value)==unicode and str(value)=="":
self.acceptance_criteria[crit]['value']=-999
elif type(value)==unicode and str(value)!="": # should be a number
try:
self.acceptance_criteria[crit]['value']=float(value)
except:
self.show_messege(crit)
elif type(value)==float or type(value)==int:
if crit=='sample_int_sigma' or crit=='site_int_sigma':
self.acceptance_criteria[crit]['value']=float(value)*1e-6
else:
self.acceptance_criteria[crit]['value']=float(value)
else:
self.show_messege(crit)
#---------
# thellier interpreter calculation type
if dia.set_stdev_opt.GetValue()==True:
self.acceptance_criteria['interpreter_method']['value']='stdev_opt'
elif dia.set_bs.GetValue()==True:
self.acceptance_criteria['interpreter_method']['value']='bs'
elif dia.set_bs_par.GetValue()==True:
self.acceptance_criteria['interpreter_method']['value']='bs_par'
# message dialog
dlg1 = wx.MessageDialog(self,caption="Warning:", message="changes are saved to consistency_test/pmag_fixed_criteria.txt\n " ,style=wx.OK)
result = dlg1.ShowModal()
if result == wx.ID_OK:
try:
new_dir = os.path.join(self.WD, "consistency_test")
os.mkdir(new_dir)
except:
pass
#try:
# self.clear_boxes()
#except:
# pass
#try:
# self.write_acceptance_criteria_to_boxes()
#except:
# pass
ofile = os.path.join(self.WD, "consistency_test/pmag_fixed_criteria.txt")
pmag.write_criteria_to_file(ofile, self.acceptance_criteria)
dlg1.Destroy()
dia.Destroy()
#self.recaclulate_satistics()
# only valid naumber can be entered to boxes
# used by On_close_criteria_box
def show_messege(self,key):
dlg1 = wx.MessageDialog(self,caption="Error:",
message="non-vaild value for box %s"%key ,style=wx.OK)
#dlg1.ShowModal()
result = dlg1.ShowModal()
if result == wx.ID_OK:
dlg1.Destroy()
def init_optimizer_frame(self):
Text="Set Consistency Test function parameters"
dlg = wx.MessageDialog(self, Text, caption="Second step", style=wx.OK )
dlg.ShowModal(); dlg.Destroy()
""" Build main frame od panel: buttons, etc.
choose the first specimen and display data
"""
# import wx.lib.agw.floatspin as FS
stat_list=self.preferences['show_statistics_on_gui']
if "scat" in stat_list:
stat_list.remove("scat")
self.stat_1 = wx.ComboBox(self.panel, -1, value="", choices=stat_list, style=wx.CB_DROPDOWN,name="stat_1")
self.stat_1_low = wx.TextCtrl(self.panel,style=wx.TE_CENTER,size=(50,20))
self.stat_1_high = wx.TextCtrl(self.panel,style=wx.TE_CENTER,size=(50,20))
self.stat_1_delta = wx.TextCtrl(self.panel,style=wx.TE_CENTER,size=(50,20))
self.stat_2 = wx.ComboBox(self.panel, -1, value="", choices=stat_list, style=wx.CB_DROPDOWN,name="stat_2")
self.stat_2_low = wx.TextCtrl(self.panel,style=wx.TE_CENTER,size=(50,20))
self.stat_2_high = wx.TextCtrl(self.panel,style=wx.TE_CENTER,size=(50,20))
self.stat_2_delta = wx.TextCtrl(self.panel,style=wx.TE_CENTER,size=(50,20))
beta_window = wx.GridSizer(2, 4, 5, 10)
beta_window.AddMany( [(wx.StaticText(self.panel,label="statistic",style=wx.TE_CENTER), wx.EXPAND),
(wx.StaticText(self.panel,label="start value",style=wx.TE_CENTER), wx.EXPAND),
(wx.StaticText(self.panel,label="end value",style=wx.TE_CENTER), wx.EXPAND),
(wx.StaticText(self.panel,label="delta",style=wx.TE_CENTER), wx.EXPAND),
(self.stat_1, wx.EXPAND),
(self.stat_1_low, wx.EXPAND) ,
(self.stat_1_high, wx.EXPAND) ,
(self.stat_1_delta, wx.EXPAND) ])
scat_window = wx.GridSizer(2, 4, 5, 10)
scat_window.AddMany( [(wx.StaticText(self.panel,label="statistic",style=wx.TE_CENTER), wx.EXPAND),
(wx.StaticText(self.panel,label="start value",style=wx.TE_CENTER), wx.EXPAND),
(wx.StaticText(self.panel,label="end value",style=wx.TE_CENTER), wx.EXPAND),
(wx.StaticText(self.panel,label="delta",style=wx.TE_CENTER), wx.EXPAND),
(self.stat_2, wx.EXPAND) ,
(self.stat_2_low, wx.EXPAND) ,
(self.stat_2_high, wx.EXPAND) ,
(self.stat_2_delta, wx.EXPAND) ])
Text1="insert functions in the text window below, each function in a seperate line.\n"
Text2="Use a valid python syntax with logic or arithmetic operators\n (see example functions)\n\n"
Text3="List of legal operands:\n"
Text4="study_sample_n: Total number of samples in the study that pass the criteria\n"
Text5="test_group_n: Number of test groups that have at least one sample that passed acceptance criteria\n"
Text6="max_group_int_sigma_uT: standard deviation of the group with the maximum scatter \n"
Text7="max_group_int_sigma_perc: standard deviation of the group with the maximum scatter divided by its mean (in unit of %)\n\n"
Text8="Check \"Check function syntax\" when done inserting functions.\n\n"
self.function_label = wx.StaticText(self.panel, label=Text1+Text2+Text3+Text4+Text5+Text6+Text7+Text8,style=wx.ALIGN_CENTRE)
# text_box
self.text_logger = wx.TextCtrl(self.panel, id=-1, size=(800,200), style= wx.HSCROLL|wx.TE_MULTILINE)
self.Bind(wx.EVT_TEXT,self.on_change_function,self.text_logger)
# check function button
self.check_button = wx.Button(self.panel, id=-1, label='Check function syntax')#,style=wx.BU_EXACTFIT)#, size=(175, 28))
self.Bind(wx.EVT_BUTTON, self.on_check_button, self.check_button)
# check function status
self.check_status=wx.TextCtrl(self.panel,style=wx.TE_CENTER|wx.TE_READONLY,size=(50,20))
# group definition button
# self.optimizer_make_groups_next_button = wx.Button(self.panel, id=-1, label='Next')#,style=wx.BU_EXACTFIT)#, size=(175, 28))
# self.Bind(wx.EVT_BUTTON, self.on_optimizer_make_groups_next_button, self.optimizer_make_groups_next_button)
self.open_existing_optimizer_group_file = wx.Button(self.panel,id=-1, label='Choose a test group file')
self.Bind(wx.EVT_BUTTON, self.on_open_existing_optimizer_group_file, self.open_existing_optimizer_group_file)
self.optimizer_group_file_window=wx.TextCtrl(self.panel,style=wx.TE_CENTER|wx.TE_READONLY,size=(800,20))
#self.make_new_optimizer_group_file = wx.Button(self.panel,id=-1, label='make new group definition file')#,style=wx.BU_EXACTFIT)#, size=(175, 28))
#self.Bind(wx.EVT_BUTTON, self.on_make_new_optimizer_group_file, self.make_new_optimizer_group_file)
# Cancel button
self.cancel_optimizer_button = wx.Button(self.panel, id=-1, label='Cancel')#,style=wx.BU_EXACTFIT)#, size=(175, 28))
self.Bind(wx.EVT_BUTTON, self.on_cancel_optimizer_button, self.cancel_optimizer_button)
self.run_optimizer_button = wx.Button(self.panel, id=-1, label='Run Consistency Test')#,style=wx.BU_EXACTFIT)#, size=(175, 28))
self.Bind(wx.EVT_BUTTON, self.on_run_optimizer_button, self.run_optimizer_button)
# put an example
try:
ofile = os.path.join(self.WD, "consistency_test", "consistency_test_functions.txt")
function_in=open(ofile, 'rU')
TEXT=""
for line in function_in.readlines():
TEXT=TEXT+line
except:
TEXT="study_sample_n\ntest_group_n\nmax_group_int_sigma_uT\nmax_group_int_sigma_perc\n((max_group_int_sigma_uT < 6) or (max_group_int_sigma_perc < 10)) and int(study_sample_n)"
self.text_logger.SetValue(TEXT)
#TEXT=Text1+Text2+Text3+Text4+Text5+Text6+Text7+Text8
#self.text_logger.SetValue()
box=wx.BoxSizer(wx.wx.HORIZONTAL)