-
Notifications
You must be signed in to change notification settings - Fork 1
/
CAMDT_2017_0310.py
2722 lines (2533 loc) · 147 KB
/
CAMDT_2017_0310.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
##Program: CAMDT (Climate Agriculture Modeling Decision Tool)
## The CAMDT is a computer desktop tool designed to guide decision-makers
## in adopting appropriate crop and water management practices
## that can improve crop yields given a climate condition
##Author: Eunjin Han
##Institute: IRI-Columbia University, NY
##Revised: August, 2, 2016
##Date: February 17, 2016
##===================================================================
title = 'CAMDT User-Interface'
# Import Pmw from this directory tree.
import sys
sys.path[:0] = ['../../..']
from Tkinter import *
import Tkinter #Tkinter is the PYthon interface to Tk, the GUI toolkit ofr Tcl/Tk
import Pmw #Pmw(Python megawidgets) are composite widgets written entirely in Python using Tkinter widgets as base classes
#Pmw provide a convinent ways to add functionality to an appilcation without the need to writ ea lot of code (e.g., Combobox)
import datetime #to convert date to doy or vice versa
from tkFileDialog import * # importing everything from tkFileDialog module for askopenfilename
#Small addendum: tkFileDialog is renamed to tkinter.filedialog in Python 3 ?????
import subprocess #to run executable
import shutil #to remove a foler which is not empty
import os #operating system
import numpy as np
import matplotlib.pyplot as plt #to create plots
import fnmatch # Unix filename pattern matching => to remove PILI0*.WTD
import os.path
from scipy.stats import rankdata #to make a rank to create yield exceedance curve
class CAMDT:
sf = frame = None #initially, no frame
def __init__(self, parent): #initializing an instance
global startyear2 #declare global variables to take user's inputs
global endyear2
global startyear3
global endyear3
global CheckVar, CheckVar21,CheckVar31,CheckVar32,CheckVar33,CheckVar51 #CheckVar22,
global v_name
global planting_date
global Rbutton2,Rbutton3,cul_Rbutton,Fbutton1,IRbutton
global group26,group35
global floodVar1,floodVar2,floodVar3 #constant flooding depth or not :EJ(8/2/2016)
# Create and pack a NoteBook.
notebook = Pmw.NoteBook(parent)
notebook.pack(fill = 'both', expand = 1, padx = 10, pady = 10)
#==========================First page "Simulation Setup"
#Add a page to the notebook.
page = notebook.add('Simulation setup')
notebook.tab('Simulation setup').focus_set()
# page.configure(background = 'white')
# Create the "Simulation mode" contents of the page.
# 1) ADD SCROLLED FRAME
sf = Pmw.ScrolledFrame(page) #,usehullsize=1, hull_width=700, hull_height=220)
sf.pack(padx=5, pady=3, fill='both', expand=YES)
group = Pmw.Group(sf.interior(), tag_text = 'Simulation mode',tag_font = Pmw.logicalfont('Helvetica', 1))
group.pack(fill = 'x',anchor=N, padx = 10, pady = 5)
CheckVar = Tkinter.IntVar()
s_modelist=[('Hindcast', 0), ('Forecast', 1)]
for text, value in s_modelist:
Radiobutton(group.interior(), text=text, value=value, variable=CheckVar).pack(side=LEFT,expand=YES) #anchor=W)
CheckVar.set(0) #By default- hindcast mode
# Create the "Simulation horizon" contents of the page.
group2 = Pmw.Group(sf.interior(), tag_text = 'Simulation horizon(crop growing season)',tag_font = Pmw.logicalfont('Helvetica', 1))
group2.pack(fill = 'x', expand = 1, padx = 10, pady = 5)
#frame 1 within group2
fm_gp21=Frame(group2.interior())
startyear2 = Pmw.EntryField(fm_gp21, labelpos = 'w',
label_text = 'Planting Year(4digit):',value = '2009',
validate = {'validator': 'numeric', 'min' : 1950, 'max' : 2020, 'minstrict' : 0})
# modifiedcommand = self.changed)
startyear2.pack(fill = 'x', padx = 10, pady = 5)
mth_list = ("1","2","3","4","5","6","7","8","9","10","11","12") #,"-99")
self.startmonth2 = Pmw.ComboBox(fm_gp21, label_text='Planting Month:', labelpos='wn',
listbox_width=15, dropdown=1,
scrolledlist_items=mth_list,
entryfield_entry_state=DISABLED)
self.startmonth2.pack(fill = 'x', padx = 10, pady = 5)
self.startmonth2.selectitem(mth_list[11]) #[12]=-99 # Display default item
fm_gp21.pack(fill='x', expand=1,padx=10,side=LEFT)
#frame 2 within group2
fm_gp22=Frame(group2.interior())
#end year
endyear2 = Pmw.EntryField(fm_gp22, labelpos = 'w',
label_text = 'Harvesting Year(4digit):',value = '2010',
validate = {'validator': 'numeric', 'min' : 1950, 'max' : 2020, 'minstrict' : 0})
endyear2.pack(fill = 'x', padx = 10, pady = 5)
#ending month
self.endmonth2 = Pmw.ComboBox(fm_gp22, label_text='Harvesting Month:', labelpos='wn',
listbox_width=15, dropdown=1,
scrolledlist_items=mth_list,
entryfield_entry_state=DISABLED)
self.endmonth2.pack(fill = 'x', padx = 10, pady = 5)
# Display default item
self.endmonth2.selectitem(mth_list[6]) #[12]=-99
label10= Label(fm_gp22, text='*NOTE:Harvesting Month should be long enough \n(~3 months later than expected harvesting dates)')
label10.pack(side=TOP, anchor=N)
fm_gp22.pack(fill='x', expand=1,padx=10,side=LEFT)
# 3rd group: Create the "Predictionhorizon" contents of the page.
group3 = Pmw.Group(sf.interior(), tag_text = 'Prediction horizon (seasonal climate forecast)',tag_font = Pmw.logicalfont('Helvetica', 1))
group3.pack(fill = 'x', expand = 1, padx = 10, pady = 5)
#frame 1 within group3
fm_gp31=Frame(group3.interior())
startyear3 = Pmw.EntryField(fm_gp31, labelpos = 'w',
label_text = 'Forecast Start Year(4digit):',value = '2009',
validate = {'validator': 'numeric', 'min' : 1950, 'max' : 2020, 'minstrict' : 0})
startyear3.pack(fill = 'x', padx = 10, pady = 5)
#starting month
self.startmonth3 = Pmw.ComboBox(fm_gp31, label_text='Forecast Start Month:', labelpos='wn',
listbox_width=15, dropdown=1,
scrolledlist_items=mth_list,
entryfield_entry_state=DISABLED)
self.startmonth3.pack(fill = 'x', padx = 10, pady = 5)
# Display default item
self.startmonth3.selectitem(mth_list[11]) #[12]=-99 [11]=12
fm_gp31.pack(fill='x', expand=1,padx=10,side=LEFT)
#frame 2 within group3
fm_gp32=Frame(group3.interior())
#end year
endyear3 = Pmw.EntryField(fm_gp32, labelpos = 'w',
label_text = 'Forecast End Year(4digit):',value = '2010',
validate = {'validator': 'numeric', 'min' : 1950, 'max' : 2020, 'minstrict' : 0})
endyear3.pack(fill = 'x', padx = 10, pady = 5)
#ending month
self.endmonth3 = Pmw.ComboBox(fm_gp32, label_text='Forecast End Month:', labelpos='wn',
listbox_width=10, dropdown=1,
scrolledlist_items=mth_list,
entryfield_entry_state=DISABLED)
self.endmonth3.pack(fill = 'x', padx = 10, pady = 5)
# Display default item
self.endmonth3.selectitem(mth_list[1]) #[12]=-99 [1]=February
fm_gp32.pack(fill='x', expand=1,padx=10,side=LEFT)
#Planting date
fm1=Frame(sf.interior()) #assign frame 1
planting_date=Pmw.EntryField(fm1, labelpos='w',entry_width=5,
label_text='Planting date (DOY)',value = '349', #doy349=Dec. 15th
validate = {'validator': 'numeric', 'min' : 1, 'max' : 366, 'minstrict' : 0})
planting_date.pack(side=LEFT) #, pady = 5)
label11= Label(fm1, text='*NOTE:Planting date should be within the "Planting Month" of Sim horizon')
label11.pack(anchor=N)
fm1.pack(fill='x', expand=1,padx=10,side=TOP)
# Create and pack the ButtonBox.
buttonBox = Pmw.ButtonBox(sf.interior(),
labelpos = 'w',
label_text = 'Validate inputs ?',
frame_borderwidth = 2,
frame_relief = 'groove')
buttonBox.pack()
#self.buttonBox.pack(fill = 'both', expand = 1, padx = 10, pady = 10)
# Add some buttons to the ButtonBox.
buttonBox.add('Yes', command = self.validate_in)
#==========================Second page for "Seasonal Forecast"
# Add two more empty pages.
page2 = notebook.add('Temporal Downscaling')
notebook.tab('Temporal Downscaling').focus_set()
# 1) ADD SCROLLED FRAME
sf_p2 = Pmw.ScrolledFrame(page2) #,usehullsize=1, hull_width=700, hull_height=220)
sf_p2.pack(padx=5, pady=3, fill='both', expand=YES)
fm1=Frame(sf_p2.interior()) #assign frame 1
# Radio button to select "weather station"
group20 = Pmw.Group(fm1, tag_text = 'Station with Historical Weather Data',tag_font = Pmw.logicalfont('Helvetica', 1))
group20.pack(fill = 'both', side=TOP, padx = 10, pady = 5)
Wstation_list = ("PILI","LEGA")
self.Wstation = Pmw.ComboBox(group20.interior(), label_text='Station Name:', labelpos='wn',
listbox_width=20, dropdown=1,
scrolledlist_items=Wstation_list,
entryfield_entry_state=DISABLED)
self.Wstation.selectitem(Wstation_list[0])
self.Wstation.pack(fill = 'x', side=LEFT,padx = 10, pady = 5)
label20= Label(group20.interior(), text='*Make sure ####.WTD file should exist in workding directory')
label20.pack(anchor=N)
# Radio button to select "Downscaling method"
group21 = Pmw.Group(fm1, tag_text = 'Downscaling Method',tag_font = Pmw.logicalfont('Helvetica', 1))
group21.pack(fill = 'both', side=TOP, padx = 10, pady = 5)
CheckVar21 = Tkinter.IntVar()
down_method=[('FResampler', 0), ('Stochastic Disag', 1)]
for text, value in down_method:
Radiobutton(group21.interior(), text=text, command = self.empty_downscale_label, value=value, variable=CheckVar21).pack(side=LEFT,expand=YES)
CheckVar21.set(1) #By default- Stochastic Disag
# Create button to launch the dialog
down_button=Tkinter.Button(fm1,
text = 'Click to add more details for the selected method',
command = self.getmoreinput,bg='gray70',font = ("weight bold",10)).pack(side=TOP,anchor=N)
# Create the "Downscaling method" contents of the page.
group22 = Pmw.Group(fm1, tag_text = 'FResampler',tag_font = Pmw.logicalfont('Helvetica', 0.7))
group22.pack(fill = 'x', side=LEFT,anchor=N,expand=YES, padx = 10, pady = 5)
#Label to fill user-input for downscaling details
self.label11 = Label(group22.interior(), text='Num. of realization:', padx=5, pady=5)
self.label11.grid(row=0,column=0, sticky=W) #rowspan=1,columnspan=1)
self.label12 = Label(group22.interior(), text='Not added',relief='sunken',width=10, padx=5) #, pady=5)
self.label12.grid(row=0,column=1, sticky=W) #rowspan=1,columnspan=1)
self.label13 = Label(group22.interior(), text='*Must be multiples of 10,', padx=5) #, pady=5)
self.label13.grid(row=1,column=0, sticky=W) #rowspan=1,columnspan=1)
self.label14 = Label(group22.interior(), text=' preferably greater than 30', padx=5) #, pady=5)
self.label14.grid(row=2,column=0, sticky=W) #rowspan=1,columnspan=1)
#contents for Stochastic Disag
group23 = Pmw.Group(fm1, tag_text = 'Stochastic Disag.',tag_font = Pmw.logicalfont('Helvetica', 0.7))
# group23.pack(fill = 'both', side=LEFT, padx = 10, pady = 5)
group23.pack(fill = 'x', side=LEFT,anchor=N,expand=YES,padx = 10, pady = 5)
self.label21 = Label(group23.interior(), text='Num. of realization:', padx=5, pady=5)
self.label21.grid(row=0,column=0, sticky=W) #rowspan=1,columnspan=1)
self.label22 = Label(group23.interior(), text='Not added',relief='sunken',padx=5, pady=5)
self.label22.grid(row=0,column=1, sticky=W) #rowspan=1,columnspan=1)
self.label23 = Label(group23.interior(), text='*Rainfall Target variable for *.MTH', padx=5, pady=5)
self.label23.grid(row=1,column=0, sticky=W) #rowspan=1,columnspan=1)
self.label24 = Label(group23.interior(), text='(1 indicates "chosen")', padx=5, pady=5)
self.label24.grid(row=1,column=1, sticky=W) #rowspan=1,columnspan=1)
self.label25 = Label(group23.interior(), text='Amount:', padx=5, pady=5)
self.label25.grid(row=2,column=0, sticky=W) #rowspan=1,columnspan=1)
self.label26 = Label(group23.interior(), text='Not added',relief='sunken', padx=5, pady=5)
self.label26.grid(row=2,column=1, sticky=W) #rowspan=1,columnspan=1)
self.label27 = Label(group23.interior(), text='Frequency:', padx=5, pady=5)
self.label27.grid(row=3,column=0, sticky=W) #rowspan=1,columnspan=1)
self.label28 = Label(group23.interior(), text='Not added',relief='sunken', padx=5, pady=5)
self.label28.grid(row=3,column=1, sticky=W) #rowspan=1,columnspan=1)
self.label29 = Label(group23.interior(), text='Intensity:', padx=5, pady=5)
self.label29.grid(row=4,column=0, sticky=W) #rowspan=1,columnspan=1)
self.label20 = Label(group23.interior(), text='Not added',relief='sunken', padx=5, pady=5)
self.label20.grid(row=4,column=1, sticky=W) #rowspan=1,columnspan=1)
fm1.pack(side=TOP)
## #assign frame 2
## fm2=Frame(sf_p2.interior())
## # Radio button to select "How to get seasonal forecast"
## group24 = Pmw.Group(fm2, tag_text = 'Tercile-baesd Seasonal Forecast',tag_font = Pmw.logicalfont('Helvetica', 2))
## group24.pack(fill = BOTH, side=TOP, padx = 10, pady = 5)
#assign frame 2
fm2=Frame(sf_p2.interior())
group24 = Pmw.Group(fm2, tag_text = 'Tercile-baesd Seasonal Forecast',tag_font = Pmw.logicalfont('Helvetica', 1))
group24.pack(fill = BOTH, side=TOP, padx = 10, pady = 5)
self.BN = Pmw.EntryField(group24.interior(), labelpos = 'w',
label_text = 'Below Normal(%):', entry_width = 10,
validate = {'validator': 'real', 'min' : 1, 'max' : 99, 'minstrict' : 0})
self.BN.pack(fill = 'x', padx = 5, pady = 5,side=LEFT)
self.AN = Pmw.EntryField(group24.interior(), labelpos = 'w',
label_text = 'Above Normal(%):', entry_width = 10,
validate = {'validator': 'real', 'min' : 1, 'max' : 99, 'minstrict' : 0})
self.AN.pack(fill = 'x', padx = 5, pady = 5,side=LEFT)
#-Near Normal
NN=Label(group24.interior(), text='Near Normal(%):', padx=5, pady=5).pack(side=LEFT)
NN_box = Label(group24.interior(), text='100-BN-AN',padx=5, pady=5).pack(side=LEFT)
fm2.pack(fill = BOTH, side=TOP)
##
## CheckVar22 = Tkinter.IntVar()
## SF_data=[('From CPT', 0), ('User-specified', 1)]
## for text, value in SF_data:
## Radiobutton(group24.interior(), text=text, command = self.empty_scf_label, value=value, variable=CheckVar22).pack(side=LEFT,expand=YES)
## CheckVar22.set(1) #By default- FResampler
## # Create button to launch the dialog for cultivar
## down_button22=Tkinter.Button(fm2,
## text = 'Click to add more details for SF input',
## command = self.getSFinput,bg='gray70').pack(side=TOP,anchor=N)
##
## # Create the "Downscaling method" contents of the page.
## group25 = Pmw.Group(fm2, tag_text = 'CPT input',tag_font = Pmw.logicalfont('Helvetica', 0.7))
## group25.pack(fill = 'x', anchor=N,side=LEFT,expand=1, padx = 10, pady = 5)
## #Label to fill user-input for downscaling details
##
## self.label31 = Label(group25.interior(), text='CPT_file:', padx=5, pady=5)
## self.label31.grid(row=0,column=0, sticky=W) #rowspan=1,columnspan=1)
## self.label32 = Label(group25.interior(), text='Not added',relief='sunken', padx=5, pady=5)
## self.label32.grid(row=0,column=1, sticky=W) #rowspan=1,columnspan=1)
## self.label33 = Label(group25.interior(), text='Latitude:', padx=5, pady=5)
## self.label33.grid(row=1,column=0, sticky=W) #rowspan=1,columnspan=1)
## self.label34 = Label(group25.interior(), text='Not added',relief='sunken',width=10, padx=5, pady=5)
## self.label34.grid(row=1,column=1, sticky=W) #rowspan=1,columnspan=1)
## self.label35 = Label(group25.interior(), text='Longitude:', padx=5, pady=5)
## self.label35.grid(row=2,column=0, sticky=W) #rowspan=1,columnspan=1)
## self.label36 = Label(group25.interior(), text='Not added',relief='sunken',width=10, padx=5, pady=5)
## self.label36.grid(row=2,column=1, sticky=W) #rowspan=1,columnspan=1)
##
## #contents for Stochastic Disag
## group26 = Pmw.Group(fm2, tag_text = 'User-specified',tag_font = Pmw.logicalfont('Helvetica', 0.7))
## # group23.pack(fill = 'both', side=LEFT, padx = 10, pady = 5)
## group26.pack(fill = 'x', anchor=N,side=LEFT,expand=1, padx = 10, pady = 5)
## self.label41 = Label(group26.interior(), text='Below Normal(%):', padx=5, pady=5)
## self.label41.grid(row=0,column=0, sticky=W) #rowspan=1,columnspan=1)
## self.label42 = Label(group26.interior(), text='Not added',relief='sunken',width=10, padx=5, pady=5)
## self.label42.grid(row=0,column=1, sticky=W) #rowspan=1,columnspan=1)
## self.label43 = Label(group26.interior(), text='Near Normal(%):', padx=5, pady=5)
## self.label43.grid(row=1,column=0, sticky=W) #rowspan=1,columnspan=1)
## self.label44 = Label(group26.interior(), text='Not added',relief='sunken',width=10, padx=5, pady=5)
## self.label44.grid(row=1,column=1, sticky=W) #rowspan=1,columnspan=1)
## self.label45 = Label(group26.interior(), text='Above Normal(%):', padx=5, pady=5)
## self.label45.grid(row=2,column=0, sticky=W) #rowspan=1,columnspan=1)
## self.label46 = Label(group26.interior(), text='Not added',relief='sunken',width=10, padx=5, pady=5)
## self.label46.grid(row=2,column=1, sticky=W) #rowspan=1,columnspan=1)
#=========================Third page for "DSSAT baseline setup - I "
page3 = notebook.add('DSSAT setup 1')
notebook.tab('DSSAT setup 1').focus_set()
# 1) ADD SCROLLED FRAME
sf_p3 = Pmw.ScrolledFrame(page3) #,usehullsize=1, hull_width=700, hull_height=220)
sf_p3.pack(padx=5, pady=3, fill='both', expand=YES)
#Assign a group for planting method
group32 = Pmw.Group(sf_p3.interior(), tag_text = 'Planting method',tag_font = Pmw.logicalfont('Helvetica', 0.5))
group32.pack(fill='both', expand=1,side=TOP, padx = 10, pady = 2)
# Radio button to select "Planting method"
Rbutton2 = Tkinter.IntVar()
plt_option=[('Dry seed', 0), ('Transplanting', 1)]
for text, value in plt_option:
Radiobutton(group32.interior(), text=text, value=value, variable=Rbutton2).pack(side=LEFT,expand=YES)
Rbutton2.set(1) #By default- Transplanting
# set up "Planting details"
group33 = Pmw.Group(sf_p3.interior(), tag_text = 'Planting details',tag_font = Pmw.logicalfont('Helvetica', 0.5))
group33.pack(fill = 'x', side=TOP, padx = 10, pady = 2)
#-planting distribution
pdist_list = ("Hills","Rows","Broadcast")
self.plt_dist = Pmw.ComboBox(group33.interior(), label_text='Planting distribution:', labelpos='wn',
listbox_width=15, dropdown=1,
scrolledlist_items=pdist_list,
entryfield_entry_state=DISABLED)
self.plt_dist.pack(fill = 'x', padx = 10, pady = 2)
self.plt_dist.selectitem(pdist_list[1])
#-planting population at seedling (plant/m2)
self.ppop_seed=Pmw.EntryField(group33.interior(), labelpos='w', label_text='Plt population at seedling(plt/m2):',
value = '75',validate = {'validator': 'real', 'min' : 1, 'max' : 100, 'minstrict' : 0})
self.ppop_seed.pack(fill='x', side=TOP,expand=1,padx=10, pady = 0.5)
self.ppop_emer=Pmw.EntryField(group33.interior(), labelpos='w', label_text='Plt population at emergence(plt/m2):',
value = '25',validate = {'validator': 'real', 'min' : 1, 'max' : 80, 'minstrict' : 0})
self.ppop_emer.pack(fill='x', side=TOP,expand=1,padx=10, pady = 0.5)
self.row_space=Pmw.EntryField(group33.interior(), labelpos='w', label_text='Planting row spacing(cm):',
value = '20',validate = {'validator': 'real', 'min' : 1, 'max' : 80, 'minstrict' : 0})
self.row_space.pack(fill='x', side=TOP,expand=1,padx=10, pady = 0.5)
self.row_dir=Pmw.EntryField(group33.interior(), labelpos='w', label_text='Row direction(deg from North):',
value = '0',validate = {'validator': 'real', 'min' : 0, 'max' : 360, 'minstrict' : 0})
self.row_dir.pack(fill='x', side=TOP,expand=1,padx=10, pady = 0.5)
self.plt_depth=Pmw.EntryField(group33.interior(), labelpos='w', label_text='Planting depth(cm):',
value = '2',validate = {'validator': 'real', 'min' : 1, 'max' : 50, 'minstrict' : 0})
self.plt_depth.pack(fill='x', side=TOP,expand=1,padx=10, pady = 0.5)
#aline labels
entries = (self.plt_dist, self.ppop_seed, self.ppop_emer, self.row_space, self.row_dir, self.plt_depth)
Pmw.alignlabels(entries)
#assign frame 3
fm33=Frame(sf_p3.interior())
# group for soil set up
group35 = Pmw.Group(fm33, tag_text = 'Soil',tag_font = Pmw.logicalfont('Helvetica', 0.5))
group35.pack(fill = 'x', side=TOP, padx = 10, pady = 2)
#-soil types
soil_list = ("SCL(WI_ANPH007)","LoamySand(WI_ANPH008)","Clay(WI_VRPH021)","Clay(WI_VRPH043)","SCL2(WI_CMPH009)")
self.soil_type = Pmw.ComboBox(group35.interior(), label_text='Soil type:', labelpos='wn',
listbox_width=15, dropdown=1,
scrolledlist_items=soil_list,
entryfield_entry_state=DISABLED)
self.soil_type.pack(fill = 'x',side=LEFT, padx = 10, pady = 2)
self.soil_type.selectitem(soil_list[0])
#-rooting depth
rdepth_list = ("deep","medium","shallow")
self.rt_depth = Pmw.ComboBox(group35.interior(), label_text='Rooting depth:', labelpos='wn',
listbox_width=15, dropdown=1,
scrolledlist_items=rdepth_list,
entryfield_entry_state=DISABLED)
self.rt_depth.pack(fill = 'x',side=LEFT, padx = 10, pady = 2)
self.rt_depth.selectitem(rdepth_list[1])
fm33.pack(fill = 'both', expand = 1,side=TOP)
#assign frame 4
fm34=Frame(sf_p3.interior())
# set up "cultivar selection"
group36 = Pmw.Group(fm34, tag_text = 'Cultivar selection',tag_font = Pmw.logicalfont('Helvetica', 0.5))
group36.pack(fill = 'x', side=TOP, padx = 10, pady = 2)
cul_Rbutton = Tkinter.IntVar()
cul_option=[('Calibrated', 0), ('User-specified', 1)]
for text, value in cul_option:
Radiobutton(group36.interior(), text=text, value=value, variable=cul_Rbutton).pack(side=LEFT,expand=YES)
cul_Rbutton.set(0) #By default- calibrated
# Create button to launch the dialog
cul_button=Tkinter.Button(fm34,
text = 'Click to add more details for cultivar type',
command = self.getCulinput,bg='gray70').pack(side=TOP,anchor=N)
# Create the "cultivar" contents of the page.
group361 = Pmw.Group(fm34, tag_text = 'Calibrated',tag_font = Pmw.logicalfont('Helvetica', 0.5))
group361.pack(fill = 'x', side=LEFT,anchor=N,expand=YES, padx = 10, pady = 5)
self.label361 = Label(group361.interior(), text='Cultivar ID:', padx=5, pady=5)
self.label361.grid(row=0,column=0, sticky=W) #rowspan=1,columnspan=1)
self.label362 = Label(group361.interior(), text='Not added',relief='sunken',width=10, padx=5, pady=5)
self.label362.grid(row=0,column=1, sticky=W) #rowspan=1,columnspan=1)
self.label363 = Label(group361.interior(), text='Cultivar name:', padx=5, pady=5)
self.label363.grid(row=1,column=0, sticky=W) #rowspan=1,columnspan=1)
self.label364 = Label(group361.interior(), text='Not added',relief='sunken',width=10,padx=5, pady=5)
self.label364.grid(row=1,column=1, sticky=W) #rowspan=1,columnspan=1)
#contents for user-specified cultivar
group362 = Pmw.Group(fm34, tag_text = 'User-specified cultivar',tag_font = Pmw.logicalfont('Helvetica', 0.5))
group362.pack(fill = 'x', side=LEFT,anchor=N,expand=YES,padx = 10, pady = 2)
self.label301 = Label(group362.interior(), text='Cultivar ID:')
self.label302 = Label(group362.interior(), text='Not added',relief='sunken',width=10)
self.label303 = Label(group362.interior(), text='Cultivar name:')
self.label304 = Label(group362.interior(), text='Not added',relief='sunken',width=10)
self.label305 = Label(group362.interior(), text='Ecotype code:')
self.label306 = Label(group362.interior(), text='Not added',relief='sunken',width=10)
self.label307 = Label(group362.interior(), text='P1:')
self.label308 = Label(group362.interior(), text='Not added',relief='sunken',width=10)
self.label309= Label(group362.interior(), text='P2R:')
self.label310 = Label(group362.interior(), text='Not added',relief='sunken',width=10)
self.label311= Label(group362.interior(), text='P5:')
self.label312 = Label(group362.interior(), text='Not added',relief='sunken',width=10)
self.label313= Label(group362.interior(), text='P2O:')
self.label314 = Label(group362.interior(), text='Not added',relief='sunken',width=10)
self.label315= Label(group362.interior(), text='G1:')
self.label316 = Label(group362.interior(), text='Not added',relief='sunken',width=10)
self.label317= Label(group362.interior(), text='G2:')
self.label318 = Label(group362.interior(), text='Not added',relief='sunken',width=10)
self.label319= Label(group362.interior(), text='G3:')
self.label320 = Label(group362.interior(), text='Not added',relief='sunken',width=10)
self.label321= Label(group362.interior(), text='G4:')
self.label322 = Label(group362.interior(), text='Not added',relief='sunken',width=10)
#aline lables names
entries = (self.label301, self.label303, self.label305, self.label307, self.label309,
self.label311,self.label313,self.label315,self.label317,self.label319,self.label321)
i=0
for entry in entries:
entry.grid(row=i,column=0, sticky=W)
i=i+1
#aline empty label
entries = (self.label302, self.label304, self.label306, self.label308, self.label310,
self.label312,self.label314,self.label316,self.label318,self.label320,self.label322)
i=0
for entry in entries:
entry.grid(row=i,column=1) #, sticky=W)
i=i+1
#aline lables names
entries = (self.label313, self.label315, self.label317, self.label319, self.label321)
i=1
for entry in entries:
entry.grid(row=i,column=2, sticky=W)
i=i+1
#aline empty label
entries = (self.label314, self.label316, self.label318, self.label320, self.label322)
i=1
for entry in entries:
entry.grid(row=i,column=3) #, sticky=W)
i=i+1
fm34.pack(fill = 'both', expand = 1,side=TOP)
#=========================4th page for "DSSAT baseline setup - II "
page4 = notebook.add('DSSAT setup 2')
notebook.tab('DSSAT setup 2').focus_set()
# 1) ADD SCROLLED FRAME
sf_p4 = Pmw.ScrolledFrame(page4) #,usehullsize=1, hull_width=700, hull_height=220)
sf_p4.pack(padx=5, pady=3, fill='both', expand=YES)
#assign frame 1
fm41=Frame(sf_p4.interior())
# Radio button to select "Irrigation method"
group41 = Pmw.Group(fm41, tag_text = 'Fertilization application',tag_font = Pmw.logicalfont('Helvetica', 0.5))
group41.pack(fill='both', expand=1, side=TOP, padx = 10, pady = 5)
Fbutton1 = Tkinter.IntVar()
Frt_option=[('Fertilization', 0), ('No Fertilization', 1)]
for text, value in Frt_option:
Radiobutton(group41.interior(), text=text, command = self.empty_fert_label, value=value, variable=Fbutton1).pack(side=LEFT,expand=YES)
Fbutton1.set(1) #By default- no Fertilization
# Create button to launch the dialog
frt_button=Tkinter.Button(fm41,
text = 'Click to add more details for fertilizer',
command = self.getFertInput,bg='gray70').pack(side=TOP,anchor=N)
# Create the "fertilizer" contents of the page.
group42 = Pmw.Group(fm41, tag_text = 'Fertilizer application',tag_font = Pmw.logicalfont('Helvetica', 0.5))
group42.pack(fill = 'x', side=TOP,expand=1, padx = 2, pady = 5)
self.nfertilizer = Pmw.EntryField(group42.interior(), labelpos = 'w',
label_text = 'Number of fertilizer applications? ',
validate = {'validator': 'numeric', 'min' : 1, 'max' : 3, 'minstrict' : 0})
self.nfertilizer.pack( side=TOP, anchor=W,padx = 5, pady = 5)
frame_frt =Frame(group42.interior())
label000 = Label(frame_frt, text='No. application', padx=5, pady=5)
label001 = Label(frame_frt, text='Days after planting',padx=5, pady=5)
label002 = Label(frame_frt, text='Amount (N, kg/ha)', padx=5, pady=5)
label003 = Label(frame_frt, text='Fertilizer material',padx=5, pady=5)
label004 = Label(frame_frt, text='Application method',padx=5, pady=5)
self.label005 = Label(frame_frt, text='1st:',padx=5, pady=5)
self.label006 = Label(frame_frt, text='Not added',relief='sunken',width=13)
self.label007 = Label(frame_frt, text='Not added',relief='sunken',width=15)
self.label008 = Label(frame_frt, text='Not added',relief='sunken',width=13)
self.label009 = Label(frame_frt, text='Not added',relief='sunken',width=25)
self.label010 = Label(frame_frt, text='2nd:',padx=5, pady=5)
self.label011 = Label(frame_frt, text='Not added',relief='sunken',width=13)
self.label012 = Label(frame_frt, text='Not added',relief='sunken',width=15)
self.label013 = Label(frame_frt, text='Not added',relief='sunken',width=13)
self.label014 = Label(frame_frt, text='Not added',relief='sunken',width=25)
self.label015 = Label(frame_frt, text='3rd:',padx=5, pady=5)
self.label016 = Label(frame_frt, text='Not added',relief='sunken',width=13)
self.label017 = Label(frame_frt, text='Not added',relief='sunken',width=15)
self.label018 = Label(frame_frt, text='Not added',relief='sunken',width=13)
self.label019 = Label(frame_frt, text='Not added',relief='sunken',width=25)
#aline empty label
entries = (label000, label001, label002, label003, label004)
i=0
for entry in entries:
entry.grid(row=0,column=i) #, sticky=W)
i=i+1
entries = (self.label005, self.label006, self.label007, self.label008, self.label009)
i=0
for entry in entries:
entry.grid(row=1,column=i) #, sticky=W)
i=i+1
entries = (self.label010, self.label011, self.label012, self.label013, self.label014)
i=0
for entry in entries:
entry.grid(row=2,column=i) #, sticky=W)
i=i+1
entries = (self.label015, self.label016, self.label017, self.label018, self.label019)
i=0
for entry in entries:
entry.grid(row=3,column=i) #, sticky=W)
i=i+1
frame_frt.pack(fill = 'x', expand = 1,side=TOP)
fm41.pack(fill = 'both', expand = 1,side=TOP)
#assign frame 2
fm42=Frame(sf_p4.interior())
# Radio button to select "Planting method"
group43 = Pmw.Group(fm42, tag_text = 'Irrigation',tag_font = Pmw.logicalfont('Helvetica', 0.5))
group43.pack(fill='x', expand=1,side=TOP, padx = 10, pady = 5)
IRbutton = Tkinter.IntVar()
IR_option=[('Automatic when required', 0),('On Reported dates', 2),('No Irrigation', 3)]
for text, value in IR_option:
Radiobutton(group43.interior(), text=text, command = self.empty_irrig_label, value=value, variable=IRbutton).pack(side=LEFT,expand=YES)
IRbutton.set(3) #By default- no irrigation
# Create button to launch the dialog
Irr_button=Tkinter.Button(fm42,
text = 'Click to add more details for irrigation',
command = self.getIrrInput,bg='gray70').pack(side=TOP,anchor=N)
# Create the "Automatic irrigation" contents of the page.
group44 = Pmw.Group(fm42, tag_text = 'Irrigation (Automatic)',tag_font = Pmw.logicalfont('Helvetica', 0.5))
group44.pack(fill = 'x', side=TOP,expand=1, padx = 2, pady = 5)
self.label401 = Label(group44.interior(), text='Management depth(cm):',anchor=W, padx=10)
self.label401.grid(row=0,column=0, sticky=W)
self.label402 = Label(group44.interior(), text='Not added',relief='sunken', padx=5)
self.label402.grid(row=0,column=1, sticky=W)
self.label403 = Label(group44.interior(), text='Threshold(% of max available):',anchor=W,padx=10)
self.label403.grid(row=0,column=2, sticky=W)
self.label404 = Label(group44.interior(), text='Not added',relief='sunken',padx=5)
self.label404.grid(row=0,column=3, sticky=W)
## self.label405 = Label(group44.interior(), text='End point(% of max available):',anchor=W, padx=10)
## self.label405.grid(row=1,column=0, sticky=W)
## self.label406 = Label(group44.interior(), text='Not added',relief='sunken',padx=5)
## self.label406.grid(row=1,column=1, sticky=W)
self.label407 = Label(group44.interior(), text='Efficiency fraction:',anchor=W,padx=10)
self.label407.grid(row=1,column=0, sticky=W)
self.label408 = Label(group44.interior(), text='Not added',relief='sunken',padx=5)
self.label408.grid(row=1,column=1, sticky=W)
# Create the "manual irrigation" contents of the page.
group45 = Pmw.Group(fm42, tag_text = 'Irrigation (Reported)',tag_font = Pmw.logicalfont('Helvetica', 0.5))
group45.pack(fill = 'x', side=TOP,expand=1, padx = 2, pady = 5)
self.nirrigation = Pmw.EntryField(group45.interior(), labelpos = 'w',
label_text = 'Number of irrigations? ',
validate = {'validator': 'numeric', 'min' : 1, 'max' : 3, 'minstrict' : 0})
self.nirrigation.pack( side=TOP, padx = 5, anchor=W, pady = 5)
frame_in1 =Frame(group45.interior())
self.label120 = Label(frame_in1, text='Puddling date(YYDOY):',padx=5)
self.label120.grid(row=0,column=0, sticky=W)
self.label121= Label(frame_in1, text='Not added',relief='sunken',width=13)
self.label121.grid(row=0,column=1, sticky=W)
## self.label122 = Label(frame_in1, text='Puddling:',padx=5)
## self.label122.grid(row=1,column=0, sticky=W)
## self.label123= Label(frame_in1, text='Not added',relief='sunken',width=13)
## self.label123.grid(row=1,column=1, sticky=W)
self.label124 = Label(frame_in1, text='Percolation rate(mm/day):',padx=5)
self.label124.grid(row=2,column=0, sticky=W)
self.label125= Label(frame_in1, text='Not added',relief='sunken',width=13)
self.label125.grid(row=2,column=1, sticky=W)
frame_in1.pack(fill = 'x', expand = 1,side=TOP)
frame_in2 =Frame(group45.interior())
label100 = Label(frame_in2, text='No. irrigation', width=10, padx=5,pady=5)
label101 = Label(frame_in2, text='Date(YYDOY)', width=13,padx=5,pady=5)
label102 = Label(frame_in2, text='Bund height',width=15, padx=5,pady=5)
label103 = Label(frame_in2, text='Flood depth', width=20, padx=5,pady=5)
label1031 = Label(frame_in2, text='Constant depth?', width=20, padx=5,pady=5)
self.label104 = Label(frame_in2, text='1st:',width=10,padx=5)
self.label105 = Label(frame_in2, text='Not added',relief='sunken',width=13)
self.label106 = Label(frame_in2, text='Not added',relief='sunken',width=15)
self.label107 = Label(frame_in2, text='Not added',relief='sunken',width=20)
self.label1071 = Label(frame_in2, text='Not added',relief='sunken',width=20)
self.label108 = Label(frame_in2, text='2nd:',width=10,padx=5)
self.label109 = Label(frame_in2, text='Not added',relief='sunken',width=13)
self.label110 = Label(frame_in2, text='Not added',relief='sunken',width=15)
self.label111 = Label(frame_in2, text='Not added',relief='sunken',width=20)
self.label1111 = Label(frame_in2, text='Not added',relief='sunken',width=20)
self.label112 = Label(frame_in2, text='3rd:',width=10,padx=5)
self.label113 = Label(frame_in2, text='Not added',relief='sunken',width=13)
self.label114 = Label(frame_in2, text='Not added',relief='sunken',width=15)
self.label115 = Label(frame_in2, text='Not added',relief='sunken',width=20)
self.label1151 = Label(frame_in2, text='Not added',relief='sunken',width=20)
#aline empty label
entries = (label100, label101, label102, label103,label1031)
i=0
for entry in entries:
entry.grid(row=0,column=i) #, sticky=W)
i=i+1
entries = (self.label104, self.label105, self.label106, self.label107,self.label1071)
i=0
for entry in entries:
entry.grid(row=1,column=i) #, sticky=W)
i=i+1
entries = (self.label108, self.label109, self.label110, self.label111,self.label1111)
i=0
for entry in entries:
entry.grid(row=2,column=i) #, sticky=W)
i=i+1
entries = (self.label112, self.label113, self.label114, self.label115,self.label1151)
i=0
for entry in entries:
entry.grid(row=3,column=i) #, sticky=W)
i=i+1
frame_in2.pack(fill = 'x', expand = 1,side=TOP)
fm42.pack(fill = 'x', expand = 1,side=TOP)
# fm_in1=Frame(fm31)
#=========================5th page for "DSSAT setup"
page5 = notebook.add('*Scenarios setup')
notebook.tab('*Scenarios setup').focus_set()
# 1) ADD SCROLLED FRAME
sf_p5 = Pmw.ScrolledFrame(page5) #,usehullsize=1, hull_width=700, hull_height=220)
sf_p5.pack(padx=5, pady=3, fill='both', expand=YES)
group51 = Pmw.Group(sf_p5.interior(), tag_text = 'Working directory')
group51.pack(fill = 'x', expand = 1, anchor=N, padx = 10, pady = 5)
#Working directory
fm51=Frame(group51.interior())
self.WDir_label0=Label(fm51, text='Working directory:', padx=5, pady=5)
self.WDir_label0.pack(fill = 'x', side=LEFT, anchor=W, padx = 10, pady = 5)
self.WDir_label = Label(fm51, text='N/A',relief='sunken', padx=5, pady=5)
self.WDir_label.pack(fill = 'x', side=LEFT, anchor=W, padx = 10, pady = 5)
fm51.pack(side=TOP)
fm52=Frame(group51.interior())
# Create button to get file path
self.file_button=Tkinter.Button(fm52,
text = 'Click to select a working directory',
command = self.getWdir,bg='gray70').pack(side=TOP,anchor=N)
fm52.pack(side=TOP)
WDir_label2=Label(fm52, text='*NOTE: Make sure all input files are in the chosen directory').pack(side=TOP,anchor=W)
WDir_label3=Label(fm52, text=' Output files will be created under the chosen directory with new scenario names').pack(side=TOP, anchor=W)
# 3rd group for threshold of water stress index"
group53 = Pmw.Group(sf_p5.interior(), tag_text = 'Threshold for water stress index')
group53.pack(fill = 'x', expand = 1,anchor=N, padx = 10, pady = 5)
self.wsi_threshold = Pmw.EntryField(group53.interior(), labelpos = 'w',
label_text = 'Threshold water stress (0~1) to compute prob. of exceeding it? ', value = '0.5', #by default =0.5
validate = {'validator': 'real', 'min' : 0.01, 'max' : 1, 'minstrict' : 0})
self.wsi_threshold.pack( side=TOP, padx = 5, pady = 5)
# 2nd group for What-If Scenarios"
group52 = Pmw.Group(sf_p5.interior(), tag_text = 'What-If scenarios')
group52.pack(fill = 'x', expand = 1,anchor=N, padx = 10, pady = 5)
## self.nscenario = Pmw.EntryField(group52.interior(), labelpos = 'w',
## label_text = 'How many scenarios? ',
## validate = {'validator': 'numeric', 'min' : 1, 'max' : 5, 'minstrict' : 0})
## self.nscenario.pack( side=TOP, padx = 5, pady = 5)
fm53=Frame(group52.interior())
label51 = Label(fm53, text='Scenario Name').pack(side=TOP)
label510 = Label(fm53, text='(4char) ').pack(side=TOP)
self.name1 = Pmw.EntryField(fm53, labelpos = 'w',entry_width=10,
label_text = '1:',
validate = {'validator': 'alphanumeric', 'min' : 1, 'max' : 10, 'minstrict' : 0})
self.name1.pack( side=TOP, padx = 5, pady = 5)
self.name2 = Pmw.EntryField(fm53, labelpos = 'w',entry_width=10,
label_text = '2:',
validate = {'validator': 'alphanumeric', 'min' : 1, 'max' : 10, 'minstrict' : 0})
self.name2.pack( side=TOP, padx = 5, pady = 5)
self.name3 = Pmw.EntryField(fm53, labelpos = 'w',entry_width=10,
label_text = '3:',
validate = {'validator': 'alphanumeric', 'min' : 1, 'max' : 10, 'minstrict' : 0})
self.name3.pack( side=TOP, padx = 5, pady = 5)
self.name4 = Pmw.EntryField(fm53, labelpos = 'w',entry_width=10,
label_text = '4:',
validate = {'validator': 'alphanumeric', 'min' : 1, 'max' : 10, 'minstrict' : 0})
self.name4.pack( side=TOP, padx = 5, pady = 5)
self.name5 = Pmw.EntryField(fm53, labelpos = 'w',entry_width=10,
label_text = '5:',
validate = {'validator': 'alphanumeric', 'min' : 1, 'max' : 10, 'minstrict' : 0})
self.name5.pack( side=TOP, padx = 5, pady = 5)
fm53.pack(side=LEFT)
#-2nd frame
fm54=Frame(group52.interior())
label52 = Label(fm54, text=' ').pack(side=TOP)
label520 = Label(fm54, text=' ').pack(side=TOP)
# Create button to get file path
self.param_button1=Tkinter.Button(fm54,
text = 'Click to write param1.txt',
command = self.writeParam1,bg='gray70').pack(side=TOP,anchor=N, padx = 5, pady = 2)
self.param_button2=Tkinter.Button(fm54,
text = 'Click to write param2.txt',
command = self.writeParam2,bg='gray70').pack(side=TOP,anchor=N, padx = 5, pady = 2)
self.param_button3=Tkinter.Button(fm54,
text = 'Click to write param3.txt',
command = self.writeParam3,bg='gray70').pack(side=TOP,anchor=N, padx = 5, pady = 2)
self.param_button4=Tkinter.Button(fm54,
text = 'Click to write param4.txt',
command = self.writeParam4,bg='gray70').pack(side=TOP,anchor=N, padx = 5, pady = 2)
self.param_button5=Tkinter.Button(fm54,
text = 'Click to write param5.txt',
command = self.writeParam5,bg='gray70').pack(side=TOP,anchor=N, padx = 5, pady = 2)
fm54.pack(side=LEFT)
#-3rd frame
fm55=Frame(group52.interior())
label53 = Label(fm55, text=' ').pack(side=TOP)
label530 = Label(fm55, text='Crop').pack(side=TOP)
self.label54 = Label(fm55, text='N/A',relief='sunken')
self.label54.pack( side=TOP,padx = 5, pady = 5)
self.label55 = Label(fm55, text='N/A',relief='sunken')
self.label55.pack( side=TOP,padx = 5, pady = 5)
self.label56 = Label(fm55, text='N/A',relief='sunken')
self.label56.pack( side=TOP,padx = 5, pady = 5)
self.label57 = Label(fm55, text='N/A',relief='sunken')
self.label57.pack( side=TOP,padx = 5, pady = 5)
self.label58 = Label(fm55, text='N/A',relief='sunken')
self.label58.pack( side=TOP,padx = 5, pady = 5)
fm55.pack(side=LEFT)
#-4th frame - price
fm56=Frame(group52.interior())
label54 = Label(fm56, text='Crop price').pack(side=TOP)
label540 = Label(fm56, text='(PHP/ton)').pack(side=TOP)
self.price1 = Pmw.EntryField(fm56, labelpos = 'w',entry_width=10,
validate = {'validator': 'real', 'min' : 0, 'minstrict' : 0})
self.price1.pack( side=TOP, padx = 5, pady = 5)
self.price2 = Pmw.EntryField(fm56, labelpos = 'w',entry_width=10,
validate = {'validator': 'real', 'min' : 0, 'minstrict' : 0})
self.price2.pack( side=TOP, padx = 5, pady = 5)
self.price3 = Pmw.EntryField(fm56, labelpos = 'w',entry_width=10,
validate = {'validator': 'real', 'min' : 0, 'minstrict' : 0})
self.price3.pack( side=TOP, padx = 5, pady = 5)
self.price4 = Pmw.EntryField(fm56, labelpos = 'w',entry_width=10,
validate = {'validator': 'real', 'min' : 0, 'minstrict' : 0})
self.price4.pack( side=TOP, padx = 5, pady = 5)
self.price5 = Pmw.EntryField(fm56, labelpos = 'w',entry_width=10,
validate = {'validator': 'real', 'min' : 0, 'minstrict' : 0})
self.price5.pack( side=TOP, padx = 5, pady = 5)
fm56.pack(side=LEFT)
#-5th frame - Price of N fertilizer
fm57=Frame(group52.interior())
label55 = Label(fm57, text='Cost of N fert.').pack(side=TOP)
label550 = Label(fm57, text='(PHP/kg N)').pack(side=TOP)
self.costN1 = Pmw.EntryField(fm57, labelpos = 'w',entry_width=10,
validate = {'validator': 'real', 'min' : 0.1, 'minstrict' : 0})
self.costN1.pack( side=TOP, padx = 5, pady = 5)
self.costN2 = Pmw.EntryField(fm57, labelpos = 'w',entry_width=10,
validate = {'validator': 'real', 'min' : 0.1,'minstrict' : 0})
self.costN2.pack( side=TOP, padx = 5, pady = 5)
self.costN3 = Pmw.EntryField(fm57, labelpos = 'w',entry_width=10,
validate = {'validator': 'real', 'min' : 0.1,'minstrict' : 0})
self.costN3.pack( side=TOP, padx = 5, pady = 5)
self.costN4 = Pmw.EntryField(fm57, labelpos = 'w',entry_width=10,
validate = {'validator': 'real', 'min' : 0.1, 'minstrict' : 0})
self.costN4.pack( side=TOP, padx = 5, pady = 5)
self.costN5 = Pmw.EntryField(fm57, labelpos = 'w',entry_width=10,
validate = {'validator': 'real', 'min' : 0.1, 'minstrict' : 0})
self.costN5.pack( side=TOP, padx = 5, pady = 5)
fm57.pack(side=LEFT)
#-6th frame - Cost of irrigation
fm58=Frame(group52.interior())
label56 = Label(fm58, text='Cost of irrig.').pack(side=TOP)
label560 = Label(fm58, text='(PHP/mm)').pack(side=TOP)
self.costI1 = Pmw.EntryField(fm58, labelpos = 'w',entry_width=10,
validate = {'validator': 'real', 'min' : 0, 'minstrict' : 0})
self.costI1.pack( side=TOP, padx = 5,pady = 5)
self.costI2 = Pmw.EntryField(fm58, labelpos = 'w',entry_width=10,
validate = {'validator': 'real', 'min' : 0, 'minstrict' : 0})
self.costI2.pack( side=TOP, padx = 5,pady = 5)
self.costI3 = Pmw.EntryField(fm58, labelpos = 'w',entry_width=10,
validate = {'validator': 'real', 'min' : 0, 'minstrict' : 0})
self.costI3.pack( side=TOP, padx = 5,pady = 5)
self.costI4 = Pmw.EntryField(fm58, labelpos = 'w',entry_width=10,
validate = {'validator': 'real', 'min' : 0, 'minstrict' : 0})
self.costI4.pack( side=TOP, padx = 5,pady = 5)
self.costI5 = Pmw.EntryField(fm58, labelpos = 'w',entry_width=10,
validate = {'validator': 'real', 'min' : 0, 'minstrict' : 0})
self.costI5.pack( side=TOP, padx = 5,pady = 5)
fm58.pack(side=LEFT)
#-7th frame - General Cost
fm59=Frame(group52.interior())
label57 = Label(fm59, text='General Cost').pack(side=TOP)
label570 = Label(fm59, text='(PHP/ha)').pack(side=TOP)
self.costG1 = Pmw.EntryField(fm59, labelpos = 'w',entry_width=10,
validate = {'validator': 'real', 'min' : 0, 'minstrict' : 0})
self.costG1.pack( side=TOP, padx = 5, pady = 5)
self.costG2 = Pmw.EntryField(fm59, labelpos = 'w',entry_width=10,
validate = {'validator': 'real', 'min' : 0, 'minstrict' : 0})
self.costG2.pack( side=TOP, padx = 5, pady = 5)
self.costG3 = Pmw.EntryField(fm59, labelpos = 'w',entry_width=10,
validate = {'validator': 'real', 'min' : 0, 'minstrict' : 0})
self.costG3.pack( side=TOP, padx = 5, pady = 5)
self.costG4 = Pmw.EntryField(fm59, labelpos = 'w',entry_width=10,
validate = {'validator': 'real', 'min' : 0, 'minstrict' : 0})
self.costG4.pack( side=TOP, padx = 5, pady = 5)
self.costG5 = Pmw.EntryField(fm59, labelpos = 'w',entry_width=10,
validate = {'validator': 'real', 'min' : 0, 'minstrict' : 0})
self.costG5.pack( side=TOP, padx = 5, pady = 5)
fm59.pack(side=LEFT)
#-8th frame for comments
fm591=Frame(group52.interior())
label47 = Label(fm591, text=' ').pack(side=TOP)
label370 = Label(fm591, text='comments').pack(side=TOP)
self.comment1 = Pmw.EntryField(fm591, labelpos = 'w')
self.comment1.pack( side=TOP, padx = 5, pady = 5)
self.comment2 = Pmw.EntryField(fm591, labelpos = 'w')
self.comment2.pack( side=TOP, padx = 5, pady = 5)
self.comment3 = Pmw.EntryField(fm591, labelpos = 'w')
self.comment3.pack( side=TOP, padx = 5, pady = 5)
self.comment4 = Pmw.EntryField(fm591, labelpos = 'w')
self.comment4.pack( side=TOP, padx = 5, pady = 5)
self.comment5 = Pmw.EntryField(fm591, labelpos = 'w')
self.comment5.pack( side=TOP, padx = 5, pady = 5)
fm591.pack(side=LEFT)
group54 = Pmw.Group(sf_p5.interior(), tag_text = 'Run DSSAT & Display Outputs')
group54.pack(fill = 'x', expand = 1,anchor=N, padx = 10, pady = 5)
#2. Run CAMDT
button52=Tkinter.Button(group54.interior(), text = 'Run DSSAT for N weather realizations',
command = self.RunCAMDT,bg='green').pack(fill = 'x', expand = 1,side=TOP,anchor=N, padx = 10, pady = 5)
fm592=Frame(group54.interior())
#Create button to execute graphs (1)yield boxplot
button53=Tkinter.Button(fm592,text = 'I. Display Yield Estimation (Boxplot)',
command = self.Yield_Analysis,bg='peachpuff1').pack(fill = 'x', expand = 1,side=TOP,anchor=N, padx = 10, pady = 5)
# Create button to execute graphs (2) water stress index
button55=Tkinter.Button(fm592, text = 'III. Display Average Water Stress (WS)',
command = self.WSI_Analysis,bg='peachpuff1').pack(fill = 'x', expand = 1,side=TOP,anchor=N, padx = 10, pady = 5)
# Create button to execute graphs (3) gross margin
button57=Tkinter.Button(fm592, text = 'V. Display Gross Margin (Boxplot)',
command = self.Economic_Analysis,bg='peachpuff1').pack(fill = 'x', expand = 1,side=TOP,anchor=N, padx = 10, pady = 5)
fm592.pack(fill = 'x', expand = 1,side=LEFT)
fm593=Frame(group54.interior())
# Create button to execute graphs (2) yield exceedance curve
button54=Tkinter.Button(fm593, text = 'II. Display Yield Estimation (Exceedance Curve)',
command = self.Yield_exceedance,bg='peachpuff1').pack(fill = 'x', expand = 1,side=TOP,anchor=N, padx = 10, pady = 5)
# Create button to execute graphs (3)prob of exceeding X% water stress
button56=Tkinter.Button(fm593, text = 'IV. Display Risk of Exceeding X% WS',
command = self.Risk_Analysis,bg='peachpuff1').pack(fill = 'x', expand = 1,side=TOP,anchor=N, padx = 10, pady = 5)
# Create button to execute graphs (4) gross margin exceedance curve
button58=Tkinter.Button(fm593, text = 'VI. Display Gross Margin (Exceedance Curve)',
command = self.Margin_exceedance,bg='peachpuff1').pack(fill = 'x', expand = 1,side=TOP,anchor=N, padx = 10, pady = 5)
fm593.pack(fill = 'x', expand = 1,side=LEFT)
#=========================6th page for "Credit"
page6 = notebook.add('*CREDIT')
notebook.tab('*CREDIT').focus_set()
# 1) ADD SCROLLED FRAME
sf_p6 = Pmw.ScrolledFrame(page6) #,usehullsize=1, hull_width=700, hull_height=220)
sf_p6.pack(padx=5, pady=3, fill='both', expand=YES)
group61 = Pmw.Group(sf_p6.interior(), tag_text = 'Authors:')
group61.pack(fill = 'x',anchor=N, padx = 10, pady = 5)
self.authrs1=Label(group61.interior(), text='Eunjin Han, Ph.D. at IRI', padx=5, pady=5)
self.authrs1.pack(side=TOP, anchor=W, expand=YES)
self.authrs2=Label(group61.interior(), text='Amor Ines, Ph.D. at Michigan State Univ. and IRI', padx=5, pady=5)
self.authrs2.pack(side=TOP, anchor=W, expand=YES)
group62 = Pmw.Group(sf_p6.interior(), tag_text = 'Other Contributions:')
group62.pack(fill = 'x',anchor=N, padx = 10, pady = 5)
self.cont1=Label(group62.interior(), text='James Hansen, Ph.D. at IRI', padx=5, pady=5)
self.cont1.pack(side=TOP, anchor=W, expand=YES)
self.cont2=Label(group62.interior(), text='Kiyoshi Honda, Ph.D. at Chubu Univ. in Japan', padx=5, pady=5)
self.cont2.pack(side=TOP, anchor=W, expand=YES)
self.cont3=Label(group62.interior(), text='Walter Baethgen, Ph.D. at IRI', padx=5, pady=5)
self.cont3.pack(side=TOP, anchor=W, expand=YES)
notebook.setnaturalsize()
#======End of creatign pages================================
###button original
#Create error message
self.val_dialog1 = Pmw.MessageDialog(parent, title = 'Error in input',
defaultbutton = 0,
message_text = 'Sim Horizon: End-year should be >= Start-year!')
self.val_dialog1.iconname('Error in inputs')
self.val_dialog1.withdraw()
self.val_dialog2 = Pmw.MessageDialog(parent, title = 'Error in input',
defaultbutton = 0,
message_text = 'Sim Horizon: End-Month should be > Start-Month!')
self.val_dialog2.withdraw()
self.val_dialog3 = Pmw.MessageDialog(parent, title = 'Error in input',
defaultbutton = 0,
message_text = 'Sim Horizon: Simulation period is too long! (over 2 years)')
self.val_dialog3.withdraw()
self.val_dialog4 = Pmw.MessageDialog(parent, title = 'Error in input',
defaultbutton = 0,
message_text = 'Pred Horizon: End-year should be >= Start-year!')
self.val_dialog4.withdraw()
self.val_dialog5 = Pmw.MessageDialog(parent, title = 'Validating Simulation Inputs',
defaultbutton = 0,
message_text = 'Pred Horizon: End-Month should be > Start-Month!')
self.val_dialog5.withdraw()
self.val_dialog6 = Pmw.MessageDialog(parent, title = 'Validating Simulation Inputs',
defaultbutton = 0,
message_text = 'Pred Horizon: End-year is too far!(over 2 years)')
self.val_dialog6.withdraw()
self.val_dialog7 = Pmw.MessageDialog(parent, title = 'Validating Simulation Inputs',
defaultbutton = 0,
message_text = 'Pred Year should be >= Sim Year!')
self.val_dialog7.withdraw()
self.val_dialog8 = Pmw.MessageDialog(parent, title = 'Validating Simulation Inputs',
defaultbutton = 0,
message_text = 'Pred Month should be >= Sim Month!')
self.val_dialog8.withdraw()
self.val_dialog9 = Pmw.MessageDialog(parent, title = 'Validating Simulation Inputs',
defaultbutton = 0,
message_text = 'Change End-Month so that pred horizon < 3 months!')
self.val_dialog9.withdraw()
self.val_dialog10 = Pmw.MessageDialog(parent, title = 'Validating Simulation Inputs',
defaultbutton = 0,
message_text = 'Good Job! - No issues found!')
self.val_dialog10.withdraw()
self.val_dialog11 = Pmw.MessageDialog(parent, title = 'Validating Planting date',
defaultbutton = 0,
message_text = 'Planting date should be later than simulation starting date!')
self.val_dialog11.withdraw()
self.val_dialog12 = Pmw.MessageDialog(parent, title = 'Checking missing inputs',
defaultbutton = 0,
message_text = 'Month input is missing!')
self.val_dialog12.withdraw()
#error message when there is no scenario name
self.writeparam_err = Pmw.MessageDialog(parent, title = 'Error message in writing param.txt',
defaultbutton = 0,
message_text = 'No scenario name available!')
self.writeparam_err.withdraw()
#error message when fertilizer info is missing
self.fertilizer_err = Pmw.MessageDialog(parent, title = 'Error in Fertilizer Input',
defaultbutton = 0,
message_text = 'No Fertilizer input! Please click the Button for more detiled input on DSSAT setup2 page.')
self.fertilizer_err.withdraw()
#error message when cultivar info is missing
self.cultivar_err = Pmw.MessageDialog(parent, title = 'Error in Cultivar Input',
defaultbutton = 0,
message_text = 'No Cultivar input! Please click the Button for more detiled input on DSSAT setup1 page.')
self.cultivar_err.withdraw()
#error message when irrigation info is missing
self.irrigation_err = Pmw.MessageDialog(parent, title = 'Error in Irrigation Input',
defaultbutton = 0,
message_text = 'No Irrigaiotn input! Please click the Button for more detiled input on DSSAT setup2 page.')
self.irrigation_err.withdraw()
#error message when there is no number of fertilizer applications
self.nfert_err_dialog = Pmw.MessageDialog(parent, title = 'Error in fertilizer input',
defaultbutton = 0,
message_text = 'Number of fertilizer applications should be provided in "DSSAT setup 2" tab!')
self.nfert_err_dialog .iconname('Error in fertilizer input')
self.nfert_err_dialog .withdraw()