-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCilantro Process Model Updated.py
4182 lines (3672 loc) · 186 KB
/
Cilantro Process Model Updated.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
# -*- coding: utf-8 -*-
import pandas as pd
import numpy as np
import math
import random
import pickle
#Important Functions
#%%Functions
def random_chunk(lst, chunk_size):
nb_chunks = int(math.ceil(len(lst)/chunk_size))
choice = random.randrange(nb_chunks) # 0 <= choice < nb_chunks
while choice == nb_chunks-1 and nb_chunks!= 1:
choice = random.randrange(nb_chunks)
return lst[choice*chunk_size:(choice+1)*chunk_size]
def field_cont_percetage2(df, percent_cont, Hazard_lvl,No_Cont_Clusters):
df2=df.copy()
No_Cont_Clusters = 1
#This function contaminated the tomato field randomly based on a cluter of X%.
No_Cont_PartitionUnits= int(len(df2)*(percent_cont/100))
Field_df_1 =df2.loc[(df2["Location"]==1) & (df2["Rej_Acc"]=="Acc")].copy()
if len(Field_df_1)>0:
Hazard_lvl_percluster= Hazard_lvl /No_Cont_Clusters #(No_Cont_PartitionUnits*No_Cont_Clusters)
for i in range(0,No_Cont_Clusters):
random_Chunky = np.array(random_chunk(lst = df2.index, chunk_size = No_Cont_PartitionUnits)) #creating random chunk
Contamination_Pattern = np.random.multinomial(Hazard_lvl_percluster,[1/No_Cont_PartitionUnits]*No_Cont_PartitionUnits,1) #spliting cont into chunks length
#print(len(Contamination_Pattern[0]))
random_Chunky_s= random_Chunky[np.isin(random_Chunky,np.array(Field_df_1.index))]
#print(len(Field_df_1.index))
Contamination_Pattern_s = Contamination_Pattern[0][range(0,len(random_Chunky_s))]
Field_df_1.loc[random_Chunky_s, "Oo"] = Field_df_1.loc[random_Chunky_s, "Oo"] + Contamination_Pattern_s
df2.update(Field_df_1)
return df2
#Sampling function
def Cilantro_Sampling(df , N_Grabs ,Composite_Mass ,Plant_Weight, loaded_model ):
df2 = df.copy()
grabs_weight = (Composite_Mass/N_Grabs)/454 #in lbs.
Oo_list=df2.loc[:,"Oo"]#list of oocyst in the field by location, vectorization
Total_Oocyst_Grab = []
Sample_Indeces = []
for j in range(N_Grabs): #sampling each grab
List_Random=Oo_list.sample(n=1) #slecting one sample from the list
Oo_bunch = List_Random
Oo_Sample = np.random.binomial(Oo_bunch,p=(grabs_weight/Plant_Weight))
Index_Sample = List_Random.index[0]
Total_Oocyst_Grab.append(Oo_Sample[0])
Sample_Indeces.append(Index_Sample)
Total_Oo_Composite = sum(Total_Oocyst_Grab)
if Total_Oo_Composite>=1:
Pr_Detect = loaded_model.predict_proba(np.array([Total_Oo_Composite]).reshape(-1,1))[0][1]
else:
Pr_Detect = 0
if np.random.uniform(0,1) < Pr_Detect:
df2.loc[Sample_Indeces, 'PositiveSamples'] = df2.loc[Sample_Indeces, 'PositiveSamples'] + 1
return df2
def Cilantro_Sampling_25g(df,Sample_Weight,N_25g_Samples,N_Grabs_Sample ,Plant_Weight, loaded_model ):
df2 = df.copy()
grabs_weight = (Sample_Weight/N_Grabs_Sample)/454 #in lbs.
Oo_list=df2.loc[:,"Oo"]#list of oocyst in the field by location, vectorization
probs_detection = []
sample_resuls =[]
sampled_oo_l = []
for i in range(N_25g_Samples):
Total_Oocyst_Grab = []
Sample_Indeces = []
for j in range(N_Grabs_Sample): #sampling each grab
List_Random=Oo_list.sample(n=1) #slecting one sample from the list
Oo_bunch = List_Random
Oo_Sample = np.random.binomial(Oo_bunch,p=(grabs_weight/Plant_Weight))
Total_Oocyst_Grab.append(Oo_Sample[0])
Sample_Indeces.append(List_Random.index[0])
Total_Oo_Composite = sum(Total_Oocyst_Grab)
if Total_Oo_Composite>=1:
Pr_Detect = loaded_model.predict_proba(np.array([Total_Oo_Composite]).reshape(-1,1))[0][1] #from logistic
Sampled_OO = 1
else:
Pr_Detect = 0
Sampled_OO = 0
probs_detection.append(Pr_Detect)
if np.random.uniform(0,1) < Pr_Detect:
sample_resuls.append(1)
df2.loc[Sample_Indeces, 'PositiveSamples'] = df2.loc[Sample_Indeces, 'PositiveSamples'] + 1
else:
sample_resuls.append(0)
sampled_oo_l.append(Sampled_OO)
samp_more_1_o = sum(sampled_oo_l)/N_25g_Samples
if sum(sample_resuls)> 0:
reject_YN = 1
else:
reject_YN = 0
if len(probs_detection)>1:
pdetect = 1-np.prod([1-i for i in probs_detection])
else:
pdetect = probs_detection[0]
return [df2, reject_YN, pdetect, samp_more_1_o]
'''
#Creating the Field
Field_Yield = 22_000 #lb
Plant_Weight = 1 #lb
Total_Plants = int(Field_Yield/Plant_Weight)
Total_Plants_List = range(1,Total_Plants+1)
Cilantro_df=pd.DataFrame({"Plant_ID": Total_Plants_List,
"Weight": Plant_Weight,
"Case_PH": 0,
"Oo": 0,
"Oo_BRej":"",
"Location": 1,
'PositiveSamples':0,
"Rej_Acc" :"Acc"
})
Cilantro_df = field_cont_percetage2(df = Cilantro_df,
percent_cont = 10,
Hazard_lvl =200000,
No_Cont_Clusters = 1)
Cilantro_Sampling_25g(df = Cilantro_df,
Sample_Weight = 25,
N_25g_Samples = 100,
N_Grabs_Sample =10,
Plant_Weight = 1,
loaded_model = qPCR_Model )
'''
def F_Rejection_Rule_C (df):
df_field_1 =df.copy()
Postives = sum(df_field_1['PositiveSamples'] >0)
if Postives>0:
df_field_1.loc[:,"Rej_Acc"] = "REJ"
df_field_1.loc[:,"Oo_BRej"] = df_field_1["Oo"]
df_field_1.loc[:,"Oo"] = 0
return df_field_1
def Func_Water_Sampling (total_oocyst_bw, bw_volume, sample_size_volume,total_samples, loaded_model):
sample_resuls =[]
probs_detection = []
for i in range(total_samples):
Pr_Ocyst_BW= sample_size_volume /(bw_volume)#probability of finding an ocyst in sample water
#total Ocyst that actually made it to our sample
T_Ocyst_SBW = np.random.binomial(n = total_oocyst_bw, p =Pr_Ocyst_BW) #SBW = sample bulk water
#Total Occyst recovered
#T_Ocyst_Rec_SBW = rng.binomial(n=T_Ocyst_SBW, p =filter_recovery)
# PCR Confirmation
if T_Ocyst_SBW>=1:
Pr_Detect = loaded_model.predict_proba(np.array([T_Ocyst_SBW]).reshape(-1,1))[0][1] #from logistic
else:
Pr_Detect = 0
probs_detection.append(Pr_Detect)
if np.random.uniform(0,1) < Pr_Detect:
sample_resuls.append(1)
else:
sample_resuls.append(0)
if sum(sample_resuls)> 0:
reject_YN = 1
else:
reject_YN = 0
if len(probs_detection)>1:
pdetect = 1-np.prod([1-i for i in probs_detection])
else:
pdetect = probs_detection[0]
return [reject_YN,pdetect]
#%% Loading PCR Detection Models
filename_qPCR = 'C://Users/gareyes3/Documents/GitHub/CPS-Farm-To-Facility-Cilantro/logistic_AW_Testing_qPCR.sav'
#filename_qPCR = 'C://Users/Gustavo Reyes/Documents/GitHubFiles/CPS-Farm-To-Facility-Cilantro/logistic_AW_Testing_qPCR.sav'
qPCR_Model_AW = pickle.load(open(filename_qPCR, 'rb'))
qPCR_Model_AW.predict_proba(np.array([20]).reshape(-1,1))[0][1] #from logistic
filename_qPCR = 'C://Users/gareyes3/Documents/GitHub/CPS-Farm-To-Facility-Cilantro/logistic_Prod_Test_qPCR_FDA.sav'
#filename_qPCR = 'C://Users/Gustavo Reyes/Documents/GitHubFiles/CPS-Farm-To-Facility-Cilantro/logistic_Prod_Test_qPCR_FDA.sav'
qPCR_Model = pickle.load(open(filename_qPCR, 'rb'))
#qPCR_Model.predict_proba(np.array([20]).reshape(-1,1))[0][1] #from logistic
#%%
#Cilantro Static Inputs
#Creating the Field
Field_Yield = 22_000 #lb
Plant_Weight = 1 #lb
Total_Plants = int(Field_Yield/Plant_Weight)
Total_Plants_List = range(1,Total_Plants+1)
#not in use because until harvest
Case_Weight = 20 #lb per case
Bunches_Weight = Case_Weight/Plant_Weight
#Water and Season Characteristics
Water_Irrigation_In = 12 #Inches of water per harvest season
Total_L_Season = 63.6*63.6*(0.0254*Water_Irrigation_In)*1000 # field yield 40.46m2 * 0.348 m of water * 10000 to convert tot m3
Days_per_season = 45 #days
Irrigation_Days_per_season = 45
L_water_day = Total_L_Season/Irrigation_Days_per_season
#Contamination
#percentage of field contaminated
#Per_Cont_Field = 100
#Water testing characteristics
W_Sample_Vol = 10 #L
Total_Samples_Water = 1
#Product Sample
Sample_Weight = 25 #g
N_25g_Samples = 1
N_Grabs = 1
#%% output collection functions
def Output_DF_Creation(Column_Names, Niterations):
Outputs_Df =pd.DataFrame(np.NaN, index= range(Niterations), columns =Column_Names)
return Outputs_Df
def Output_Collection_ProduceCont(df, outputDF, Step_Column,iteration):
#df= main model df
#outputDF = contprogdataframe
#Step_column = day of process
outputDF.at[iteration,Step_Column] =np.array(df["Oo"]).sum()
return outputDF
def Output_Collection_any_output(outputDF, Step_Column,iteration, outcome):
#df= main model df
#outputDF = contprogdataframe
#Step_column = day of process
outputDF.at[iteration,Step_Column] =outcome
return outputDF
#%% Function to run the scenarions in the process mdoel
def Process_Model(Days_per_season,
Niterations,
Cont_Scenario, #1 = every day cont, 2 = one random day
Testing_Scenario,# 1=choose every so many days per seson, #2, choose when as input
#Contamination Information, you can also use this for different clustering.
OO_per_L,
#Water Testing Options
Sampling_every_Days_Water, #change to 1 always
Sampling_every_Days_Product, #change to 1 always
#for scenario 2
Testing_Day_Water, #if scenario 2, then select the days you want testing to happen 1,23,45
Testing_Day_Product,#if scenario 2, then select the days you want testing to happen 1,23,45
#Field Contamination
Per_Cont_Field = 100,
#Testing Options
Water_Sampling = 0,#1 is on 0 is off
Product_Sampling_PH = 0, #1 is on 0 is off
Product_Testing_H = 0, ##1 is on 0 is off
#sampling
N_Samples_Prod = 1,
N_Grabs_Prod = 1
):
#Initial levels based on Input
#Initial_Levels_Bulk = int(Total_L_Season*OO_per_L)
#Irrigation_Levels_Days = Initial_Levels_Bulk/Days_per_season
#Dataframe output creation, THIS ARE THE [0], [2], [8] later in the output section
#tells you what if water rejected on a given day
Water_Outcome_DF = Output_DF_Creation(Column_Names =np.arange(1,Days_per_season+1), Niterations= Niterations)
#tells you the probability of detection per days
Water_PrRej_DF = Output_DF_Creation(Column_Names =np.arange(1,Days_per_season+1), Niterations= Niterations)
#tells you if produce sampling detected every day
Produce_Outcome_DF = Output_DF_Creation(Column_Names =np.arange(1,Days_per_season+1), Niterations= Niterations)
#tell you probability of detection of product sampling
Produce_PrRej_DF = Output_DF_Creation(Column_Names =np.arange(1,Days_per_season+1), Niterations= Niterations)
#tells if anything was sampled
Produce_sampledYN_DF = Output_DF_Creation(Column_Names =np.arange(1,Days_per_season+1), Niterations= Niterations)
#tells you contamination at each sampling point per day
Contam_Produce_DF = Output_DF_Creation(Column_Names =np.arange(1,Days_per_season+1), Niterations= Niterations)
#not in use harest samplfin
Harvest_Sampling_Outcome_DF = Output_DF_Creation(Column_Names =[Days_per_season], Niterations= Niterations)
Harvest_Sampling_PrRej_DF = Output_DF_Creation(Column_Names =[Days_per_season], Niterations= Niterations)
Contam_HS_DF = Output_DF_Creation(Column_Names =[Days_per_season], Niterations= Niterations)
#Tells you the cells at the end of each day
Final_CFUS_DF = Output_DF_Creation(Column_Names =np.arange(1,Days_per_season+1), Niterations= Niterations)
for k in (range(Niterations)):
print(k)
Random_Irr_Day_Scen2 = 1
#Contmaination scenario selection
if Cont_Scenario ==2:
Random_Irr_Day_Scen2 = random.randint(1,Days_per_season) #here
#Water Sampling
#Sampling_every_Days_Water = 1
if Testing_Scenario ==1 :
Water_Sampling_Days = np.arange(1,Days_per_season+1,Sampling_every_Days_Water)
elif Testing_Scenario ==2:
Water_Sampling_Days = Testing_Day_Water
#Product Sampling Days
#Sampling_every_Days_Product = 1
if Testing_Scenario ==1 :
Product_Sampling_Days = np.arange(1,Days_per_season+1,Sampling_every_Days_Product)
elif Testing_Scenario ==2:
Product_Sampling_Days =Testing_Day_Product
#Water_Sampling = 1
#Product_Sampling_PH = 1
#Product_Testing_H = 1
# Process Model --------------------------------------------------------------
#Creating field dataframe
Cilantro_df=pd.DataFrame({"Plant_ID": Total_Plants_List,
"Weight": Plant_Weight,
"Case_PH": 0,
"Oo": 0,
"Oo_BRej":"",
"Location": 1,
'PositiveSamples':0,
"Rej_Acc" :"Acc"
})
W_Test_Outcome = 0
for i in range (1,Days_per_season+1):
#Changing water contmaination level for scenario 2: if not 2 then levels are same very day
if Cont_Scenario ==2 and i != Random_Irr_Day_Scen2:
Initial_Levels_Bulk = 0
Irrigation_Levels_Days =0
if Cont_Scenario ==2 and i == Random_Irr_Day_Scen2:
Initial_Levels_Bulk = int(Total_L_Season*OO_per_L)
Irrigation_Levels_Days = Initial_Levels_Bulk/Days_per_season #here
elif Cont_Scenario ==1:
Initial_Levels_Bulk = int(Total_L_Season*OO_per_L)
Irrigation_Levels_Days = Initial_Levels_Bulk/Days_per_season #here
#Water Sampling: Happens in sampling days
if i in Water_Sampling_Days and Water_Sampling == 1 :
W_Test_Outcome = Func_Water_Sampling (total_oocyst_bw = Initial_Levels_Bulk,
bw_volume =Total_L_Season ,
sample_size_volume =W_Sample_Vol,
total_samples = Total_Samples_Water,
loaded_model =qPCR_Model_AW )
Water_Outcome_DF = Output_Collection_any_output(outputDF = Water_Outcome_DF, Step_Column = i,iteration=k, outcome = W_Test_Outcome[0])
Water_PrRej_DF = Output_Collection_any_output(outputDF = Water_PrRej_DF, Step_Column = i,iteration=k, outcome = W_Test_Outcome[1])
#Irrigation with water
#Step 1: Irrigation Event, only run if contamination is there:
if Irrigation_Levels_Days>0:
Cilantro_df = field_cont_percetage2(df = Cilantro_df,
percent_cont = Per_Cont_Field,
Hazard_lvl =Irrigation_Levels_Days,
No_Cont_Clusters = 1)
#Preharvest product testing.
if i in Product_Sampling_Days and Product_Sampling_PH == 1 :
Produce_test_results =Cilantro_Sampling_25g(df=Cilantro_df,
Sample_Weight = Sample_Weight,
N_25g_Samples = N_Samples_Prod,
N_Grabs_Sample = N_Grabs_Prod ,
Plant_Weight = Plant_Weight,
loaded_model = qPCR_Model)
Produce_Outcome_DF = Output_Collection_any_output(outputDF = Produce_Outcome_DF, Step_Column = i,iteration=k, outcome = Produce_test_results[1])
Produce_PrRej_DF = Output_Collection_any_output(outputDF = Produce_PrRej_DF, Step_Column = i,iteration=k, outcome = Produce_test_results[2])
Produce_sampledYN_DF = Output_Collection_any_output(outputDF = Produce_sampledYN_DF, Step_Column = i,iteration=k, outcome = Produce_test_results[3])
Contam_Produce_DF=Output_Collection_ProduceCont(df=Cilantro_df, outputDF=Contam_Produce_DF, Step_Column = i,iteration = k)
#Harvest Sampling
if i == Days_per_season:
#Harvest Testing
if Product_Testing_H == 1:
Harvest_Test_Results =Cilantro_Sampling_25g(df=Cilantro_df,
Sample_Weight = Sample_Weight,
N_25g_Samples =N_Samples_Prod,
N_Grabs_Sample = N_Grabs_Prod ,
Plant_Weight = Plant_Weight,
loaded_model = qPCR_Model)
#Cilantro_df =F_Rejection_Rule_C (df= Cilantro_df )
Harvest_Sampling_Outcome_DF = Output_Collection_any_output(outputDF = Harvest_Sampling_Outcome_DF, Step_Column = i,iteration=k, outcome = Harvest_Test_Results[1])
Harvest_Sampling_PrRej_DF = Output_Collection_any_output(outputDF = Harvest_Sampling_PrRej_DF, Step_Column = i,iteration=k, outcome = Harvest_Test_Results[2])
Contam_HS_DF=Output_Collection_ProduceCont(df=Cilantro_df, outputDF=Contam_HS_DF, Step_Column = i,iteration = k)
Final_CFUS_DF=Output_Collection_ProduceCont(df=Cilantro_df, outputDF=Final_CFUS_DF, Step_Column = i,iteration = k)
return [Water_Outcome_DF,Water_PrRej_DF,Produce_Outcome_DF,Produce_PrRej_DF, Contam_Produce_DF,Harvest_Sampling_Outcome_DF,Harvest_Sampling_PrRej_DF,Contam_HS_DF,Final_CFUS_DF, Produce_sampledYN_DF]
#a_Tring = Process_Model(
# Days_per_season = 45,
# Niterations= 10,
# Cont_Scenario = 2,
# Testing_Scenario=2,#Testing only in given day
# #Contamination Information
# OO_per_L =0.06,
# #Water Testing Options
# Sampling_every_Days_Water = 1, #leave as 1 defaul
# Sampling_every_Days_Product = 1, #as default
# #Testing Options
# Testing_Day_Water = [1], #testing water on day 1
# Testing_Day_Product = [0],
# Water_Sampling = 1,#now water testing is on
# Product_Sampling_PH = 0,
# Product_Testing_H = 0
# )
#%% SCENARIOS THESE ARE EXAMPLES (SOME REAL SCENARIO), TUNE THEM TO MATCH THE SCENARIOS WE SPOKE ABOUT IN DOC
#FOR THE FINAL ANALYSIS nITERATIONS ==10,000
#Baseline Scenario 1, No Sampling one a day. Contamination every Day
#Low Contamination
Out_B1_L = Process_Model(
Days_per_season = 45,
Niterations= 10000,
Cont_Scenario = 1,
Testing_Scenario=2,
#Contamination Information
OO_per_L =0.6,
#Water Testing Options
Sampling_every_Days_Water = 0,
Sampling_every_Days_Product = 0,
#Testing Options
Testing_Day_Water = [0],
Testing_Day_Product = [0],
Water_Sampling = 0,
Product_Sampling_PH = 0,
Product_Testing_H = 0
)
#High Contamination
Out_B1_H = Process_Model(
Days_per_season = 45,
Niterations= 10000,
Cont_Scenario = 1,#Change in baseline scenario
Testing_Scenario=2,#leave as 2 default
#Contamination Information
OO_per_L =20,
#Water Testing Options
Sampling_every_Days_Water = 0,
Sampling_every_Days_Product = 0,
#Testing Options
Testing_Day_Water = [0],
Testing_Day_Product = [0],
Water_Sampling = 0,
Product_Sampling_PH = 0,
Product_Testing_H = 0
)
#Baseline Scenario 2: Irrigation one day randomly
Out_B2_L = Process_Model(
Days_per_season = 45,
Niterations= 10000,
Cont_Scenario = 2, #Change in baseline scenario
Testing_Scenario=2, #leave as 2 default
#Contamination Information
OO_per_L =0.6,
#Water Testing Options
Sampling_every_Days_Water = 0,
Sampling_every_Days_Product = 0,
#Testing Options
Testing_Day_Water = [0],
Testing_Day_Product = [0],
Water_Sampling = 0,
Product_Sampling_PH = 0,
Product_Testing_H = 0
)
Out_B2_H = Process_Model(
Days_per_season = 45,
Niterations= 10000,
Cont_Scenario = 2, #Change in baseline scenario
Testing_Scenario=2, #leave as 2 default
#Contamination Information
OO_per_L =20,
#Water Testing Options
Sampling_every_Days_Water = 0,
Sampling_every_Days_Product = 0,
#Testing Options
Testing_Day_Water = [0],
Testing_Day_Product = [0],
Water_Sampling = 0,
Product_Sampling_PH = 0,
Product_Testing_H = 0
)
#BaselineScenario 1: Plus sampling plans =========================================
#B1_Daily testing water (DTW) - Low
Scen_B1_L_DTW = Process_Model(
Days_per_season = 45,
Niterations= 10000,
Cont_Scenario = 1,#every day contamiantion
Testing_Scenario=1,#every day sampling
#Contamination Information
OO_per_L =0.6,
#Water Testing Options
Sampling_every_Days_Water = 1, #1 for sampling every day
Sampling_every_Days_Product = 1, #as fault
#Testing Options
Testing_Day_Water = [0],
Testing_Day_Product = [0],
Water_Sampling = 1,
Product_Sampling_PH = 0,
Product_Testing_H = 0
)
#B1_Daily testing water (DTW) - High
Scen_B1_H_DTW = Process_Model(
Days_per_season = 45,
Niterations= 10000,
Cont_Scenario = 1,#every day contamiantion
Testing_Scenario=1,#every day sampling
#Contamination Information
OO_per_L =20,
#Water Testing Options
Sampling_every_Days_Water = 1, #1 for sampling every day
Sampling_every_Days_Product = 1, #as fault
#Testing Options
Testing_Day_Water = [0],
Testing_Day_Product = [0],
Water_Sampling = 1,
Product_Sampling_PH = 0,
Product_Testing_H = 0
)
#B1_Daily testing product (DTP) - Low
Scen_B1_L_DTP = Process_Model(
Days_per_season = 45,
Niterations= 10000,
Cont_Scenario = 1,#every day contamiantion
Testing_Scenario=1,#every day sampling
#Contamination Information
OO_per_L =0.6,
#Water Testing Options
Sampling_every_Days_Water = 1, #1 for sampling every day
Sampling_every_Days_Product = 1, #as default
#Testing Options
Testing_Day_Water = [0],
Testing_Day_Product = [0],
Water_Sampling = 0,
Product_Sampling_PH = 1, #now product testing is on
Product_Testing_H = 0
)
#B1_Daily testing product (DTP) - High
Scen_B1_H_DTP = Process_Model(
Days_per_season = 45,
Niterations= 10000,
Cont_Scenario = 1,#every day contamiantion
Testing_Scenario=1,#every day sampling
#Contamination Information
OO_per_L =20,
#Water Testing Options
Sampling_every_Days_Water = 1, #1 for sampling every day
Sampling_every_Days_Product = 1, #as default
#Testing Options
Testing_Day_Water = [0],
Testing_Day_Product = [0],
Water_Sampling = 0,
Product_Sampling_PH = 1, #now product testing is on
Product_Testing_H = 0
)
#B1_Water testing 1 time per season at the end of the season - Low
Scen_B1_L_WT1 = Process_Model(
Days_per_season = 45,
Niterations= 10000,
Cont_Scenario = 1,#every day contamiantion
Testing_Scenario=2,#Testing only in given day
#Contamination Information
OO_per_L =0.6,
#Water Testing Options
Sampling_every_Days_Water = 1, #leave as 1 defaul
Sampling_every_Days_Product = 1, #as default
#Testing Options
Testing_Day_Water = [45], #testing water on day 1
Testing_Day_Product = [0],
Water_Sampling = 1,#now water testing is on
Product_Sampling_PH = 0,
Product_Testing_H = 0
)
#B1_Water testing 1 time per season at the end of the season - High
Scen_B1_H_WT1 = Process_Model(
Days_per_season = 45,
Niterations= 10000,
Cont_Scenario = 1,#every day contamiantion
Testing_Scenario=2,#Testing only in given day
#Contamination Information
OO_per_L =20,
#Water Testing Options
Sampling_every_Days_Water = 1, #leave as 1 defaul
Sampling_every_Days_Product = 1, #as default
#Testing Options
Testing_Day_Water = [45], #testing water on day 1
Testing_Day_Product = [0],
Water_Sampling = 1,#now water testing is on
Product_Sampling_PH = 0,
Product_Testing_H = 0
)
#B1_Water testing 1 time per season at the end of the season - Low
Scen_B1_L_WT4 = Process_Model(
Days_per_season = 45,
Niterations= 10000,
Cont_Scenario = 1,#every day contamiantion
Testing_Scenario=2,#Testing only in given day
#Contamination Information
OO_per_L =0.6,
#Water Testing Options
Sampling_every_Days_Water = 1, #leave as 1 defaul
Sampling_every_Days_Product = 1, #as default
#Testing Options
Testing_Day_Water = [1], #testing water on day 1
Testing_Day_Product = [0],
Water_Sampling = 1,#now water testing is on
Product_Sampling_PH = 0,
Product_Testing_H = 0
)
#B1_Water testing 1 time per season at the end of the season - High
Scen_B1_H_WT4 = Process_Model(
Days_per_season = 45,
Niterations= 10000,
Cont_Scenario = 1,#every day contamiantion
Testing_Scenario=2,#Testing only in given day
#Contamination Information
OO_per_L =20,
#Water Testing Options
Sampling_every_Days_Water = 1, #leave as 1 defaul
Sampling_every_Days_Product = 1, #as default
#Testing Options
Testing_Day_Water = [1], #testing water on day 1
Testing_Day_Product = [0],
Water_Sampling = 1,#now water testing is on
Product_Sampling_PH = 0,
Product_Testing_H = 0
)
#B1_Water testing 2 times per season (end and mid) - Low
Scen_B1_L_WT2 = Process_Model(
Days_per_season = 45,
Niterations= 10000,
Cont_Scenario = 1,#every day contamiantion
Testing_Scenario=2,#Testing only in given day
#Contamination Information
OO_per_L =0.6,
#Water Testing Options
Sampling_every_Days_Water = 1, #leave as 1 defaul
Sampling_every_Days_Product = 1, #as default
#Testing Options
Testing_Day_Water = [1,45], #testing water on day 1
Testing_Day_Product = [0],
Water_Sampling = 1,#now water testing is on
Product_Sampling_PH = 0,
Product_Testing_H = 0
)
#B1_Water testing 2 times per season (end and mid) - High
Scen_B1_H_WT2 = Process_Model(
Days_per_season = 45,
Niterations= 10000,
Cont_Scenario = 1,#every day contamiantion
Testing_Scenario=2,#Testing only in given day
#Contamination Information
OO_per_L =20,
#Water Testing Options
Sampling_every_Days_Water = 1, #leave as 1 defaul
Sampling_every_Days_Product = 1, #as default
#Testing Options
Testing_Day_Water = [1,45], #testing water on day 1
Testing_Day_Product = [0],
Water_Sampling = 1,#now water testing is on
Product_Sampling_PH = 0,
Product_Testing_H = 0
)
#B1_Water testing 3 times per season (end,mid,start) - Low
Scen_B1_L_WT3 = Process_Model(
Days_per_season = 45,
Niterations= 10000,
Cont_Scenario = 1,#every day contamiantion
Testing_Scenario=2,#Testing only in given day
#Contamination Information
OO_per_L =0.6,
#Water Testing Options
Sampling_every_Days_Water = 1, #leave as 1 defaul
Sampling_every_Days_Product = 1, #as default
#Testing Options
Testing_Day_Water = [1,22,45], #testing water on day 1
Testing_Day_Product = [0],
Water_Sampling = 1,#now water testing is on
Product_Sampling_PH = 0,
Product_Testing_H = 0
)
#B1_Water testing 3 times per season (end,mid,start) - High
Scen_B1_H_WT3 = Process_Model(
Days_per_season = 45,
Niterations= 10000,
Cont_Scenario = 1,#every day contamiantion
Testing_Scenario=2,#Testing only in given day
#Contamination Information
OO_per_L =20,
#Water Testing Options
Sampling_every_Days_Water = 1, #leave as 1 defaul
Sampling_every_Days_Product = 1, #as default
#Testing Options
Testing_Day_Water = [1,22,45], #testing water on day 1
Testing_Day_Product = [0],
Water_Sampling = 1,#now water testing is on
Product_Sampling_PH = 0,
Product_Testing_H = 0
)
#B1_product testing 1 time per season at the end of the season - Low
Scen_B1_L_PT1 = Process_Model(
Days_per_season = 45,
Niterations= 10000,
Cont_Scenario = 1,#every day contamiantion
Testing_Scenario=2,#Testing only in given day
#Contamination Information
OO_per_L =0.6,
#Water Testing Options
Sampling_every_Days_Water = 1, #leave as 1 defaul
Sampling_every_Days_Product = 1, #as default
#Testing Options
Testing_Day_Water = [0], #testing water on day 1
Testing_Day_Product = [45],
Water_Sampling = 0,
Product_Sampling_PH = 1,
Product_Testing_H = 0
)
#B1_product testing 1 time per season at the end of the season - High
Scen_B1_H_PT1 = Process_Model(
Days_per_season = 45,
Niterations= 10000,
Cont_Scenario = 1,#every day contamiantion
Testing_Scenario=2,#Testing only in given day
#Contamination Information
OO_per_L =20,
#Water Testing Options
Sampling_every_Days_Water = 1, #leave as 1 defaul
Sampling_every_Days_Product = 1, #as default
#Testing Options
Testing_Day_Water = [0],
Testing_Day_Product = [45],
Water_Sampling = 0,
Product_Sampling_PH = 1,
Product_Testing_H = 0
)
#B1_product testing 1 time per season at the end of the season - Low
Scen_B1_L_PT4 = Process_Model(
Days_per_season = 45,
Niterations= 10000,
Cont_Scenario = 1,#every day contamiantion
Testing_Scenario=2,#Testing only in given day
#Contamination Information
OO_per_L =0.6,
#Water Testing Options
Sampling_every_Days_Water = 1, #leave as 1 defaul
Sampling_every_Days_Product = 1, #as default
#Testing Options
Testing_Day_Water = [0], #testing water on day 1
Testing_Day_Product = [1],
Water_Sampling = 0,
Product_Sampling_PH = 1,
Product_Testing_H = 0
)
#B1_product testing 1 time per season at the end of the season - High
Scen_B1_H_PT4 = Process_Model(
Days_per_season = 45,
Niterations= 10000,
Cont_Scenario = 1,#every day contamiantion
Testing_Scenario=2,#Testing only in given day
#Contamination Information
OO_per_L =20,
#Water Testing Options
Sampling_every_Days_Water = 1, #leave as 1 defaul
Sampling_every_Days_Product = 1, #as default
#Testing Options
Testing_Day_Water = [0],
Testing_Day_Product = [1],
Water_Sampling = 0,
Product_Sampling_PH = 1,
Product_Testing_H = 0
)
#B1_product testing 2 times per season end and mid season - Low
Scen_B1_L_PT2 = Process_Model(
Days_per_season = 45,
Niterations= 10000,
Cont_Scenario = 1,#every day contamiantion
Testing_Scenario=2,#Testing only in given day
#Contamination Information
OO_per_L =0.6,
#Water Testing Options
Sampling_every_Days_Water = 1, #leave as 1 defaul
Sampling_every_Days_Product = 1, #as default
#Testing Options
Testing_Day_Water = [0],
Testing_Day_Product = [1,45],
Water_Sampling = 0,
Product_Sampling_PH = 1,
Product_Testing_H = 0
)
#B1_product testing 2 times per season end and mid season - High
Scen_B1_H_PT2 = Process_Model(
Days_per_season = 45,
Niterations= 10000,
Cont_Scenario = 1,#every day contamiantion
Testing_Scenario=2,#Testing only in given day
#Contamination Information
OO_per_L =20,
#Water Testing Options
Sampling_every_Days_Water = 1, #leave as 1 defaul
Sampling_every_Days_Product = 1, #as default
#Testing Options
Testing_Day_Water = [0],
Testing_Day_Product = [1,45],
Water_Sampling = 0,
Product_Sampling_PH = 1,
Product_Testing_H = 0
)
#B1_product testing 3 times per season (1 start, 1 end of the season) - Low
Scen_B1_L_PT3 = Process_Model(
Days_per_season = 45,
Niterations= 10000,
Cont_Scenario = 1,#every day contamiantion
Testing_Scenario=2,#Testing only in given day
#Contamination Information
OO_per_L =0.6,
#Water Testing Options
Sampling_every_Days_Water = 1, #leave as 1 defaul
Sampling_every_Days_Product = 1, #as default
#Testing Options
Testing_Day_Water = [0], #testing water on day 1
Testing_Day_Product = [1,22,45],
Water_Sampling = 0,
Product_Sampling_PH = 1,
Product_Testing_H = 0
)
#B1_product testing 3 times per season (1 start, 1 end of the season) - High
Scen_B1_H_PT3 = Process_Model(
Days_per_season = 45,
Niterations= 10000,
Cont_Scenario = 1,#every day contamiantion
Testing_Scenario=2,#Testing only in given day
#Contamination Information
OO_per_L =20,
#Water Testing Options
Sampling_every_Days_Water = 1, #leave as 1 defaul
Sampling_every_Days_Product = 1,
#Testing Options
Testing_Day_Water = [0],
Testing_Day_Product = [1,22,45],#testing water on day 1
Water_Sampling = 0,
Product_Sampling_PH = 1, #now product testing is on
Product_Testing_H = 0
)
#BaselineScenario 2: Plus sampling plans =========================================
#B2_Daily testing water (DTW) - Low
Scen_B2_L_DTW = Process_Model(
Days_per_season = 45,
Niterations= 10000,
Cont_Scenario = 2,
Testing_Scenario=1,#every day sampling
#Contamination Information
OO_per_L =0.6,
#Water Testing Options
Sampling_every_Days_Water = 1, #1 for sampling every day
Sampling_every_Days_Product = 1, #as fault
#Testing Options
Testing_Day_Water = [0],
Testing_Day_Product = [0],
Water_Sampling = 1,
Product_Sampling_PH = 0,
Product_Testing_H = 0
)
#B2_Daily testing water (DTW) - High
Scen_B2_H_DTW = Process_Model(
Days_per_season = 45,
Niterations= 10000,
Cont_Scenario = 2,
Testing_Scenario=1,#every day sampling
#Contamination Information
OO_per_L =20,
#Water Testing Options
Sampling_every_Days_Water = 1, #1 for sampling every day
Sampling_every_Days_Product = 1, #as fault
#Testing Options
Testing_Day_Water = [0],
Testing_Day_Product = [0],
Water_Sampling = 1,
Product_Sampling_PH = 0,
Product_Testing_H = 0
)
#B2_Daily testing product (DTP) - Low
Scen_B2_L_DTP = Process_Model(
Days_per_season = 45,
Niterations= 10000,
Cont_Scenario = 2,
Testing_Scenario=1,#every day sampling
#Contamination Information
OO_per_L =0.6,
#Water Testing Options
Sampling_every_Days_Water = 1, #1 for sampling every day
Sampling_every_Days_Product = 1, #as default
#Testing Options
Testing_Day_Water = [0],
Testing_Day_Product = [0],
Water_Sampling = 0,
Product_Sampling_PH = 1, #now product testing is on
Product_Testing_H = 0
)
#B2_Daily testing product (DTP) - High
Scen_B2_H_DTP = Process_Model(
Days_per_season = 45,
Niterations= 10000,
Cont_Scenario = 2,
Testing_Scenario=1,#every day sampling
#Contamination Information
OO_per_L =20,
#Water Testing Options
Sampling_every_Days_Water = 1, #1 for sampling every day
Sampling_every_Days_Product = 1, #as default
#Testing Options
Testing_Day_Water = [0],
Testing_Day_Product = [0],
Water_Sampling = 0,
Product_Sampling_PH = 1, #now product testing is on
Product_Testing_H = 0
)
#B2_Water testing 1 time per season at the end of the season - Low
Scen_B2_L_WT1 = Process_Model(
Days_per_season = 45,
Niterations= 10000,
Cont_Scenario = 2,
Testing_Scenario=2,#Testing only in given day
#Contamination Information
OO_per_L =0.6,
#Water Testing Options
Sampling_every_Days_Water = 1, #leave as 1 defaul
Sampling_every_Days_Product = 1, #as default
#Testing Options
Testing_Day_Water = [45], #testing water on day 1
Testing_Day_Product = [0],
Water_Sampling = 1,#now water testing is on
Product_Sampling_PH = 0,
Product_Testing_H = 0
)
#B2_Water testing 1 time per season at the start of the season - High
Scen_B2_H_WT1 = Process_Model(