-
Notifications
You must be signed in to change notification settings - Fork 6
/
LO_FNs.py
623 lines (614 loc) · 26.2 KB
/
LO_FNs.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
import numpy as np
# -*- coding: utf-8 -*-
"""
Created on Sun Oct 18 12:24:42 2020
@author: osamatarabih
"""
#This script runs the main functions of the LOONE Model
class LO_FNs:
def WSM_Zone(Stage_LO,WSM4,WSM3,WSM2,WSM1): #Note that here WSM_Zone(i) return value at time step (i) in LO_Model dataFrame.
WSM = 0
if Stage_LO < WSM4:
WSM = 4
elif Stage_LO < WSM3:
WSM = 3
elif Stage_LO < WSM2:
WSM = 2
elif Stage_LO < WSM1:
WSM = 1
else:
WSM = 0
return(WSM)
def Max_Supply(WSM_Zone,LOSA_dmd_Dailydmd,Pre_defined_Variables_Z1_cutback,Pre_defined_Variables_Z2_cutback,Pre_defined_Variables_Z3_cutback,Pre_defined_Variables_Z4_cutback):
M_S = 0
if WSM_Zone == 1:
M_S = LOSA_dmd_Dailydmd * (1-Pre_defined_Variables_Z1_cutback)
elif WSM_Zone == 2:
M_S = LOSA_dmd_Dailydmd * (1-Pre_defined_Variables_Z2_cutback)
elif WSM_Zone == 3:
M_S = LOSA_dmd_Dailydmd * (1-Pre_defined_Variables_Z3_cutback)
elif WSM_Zone == 4:
M_S = LOSA_dmd_Dailydmd * (1-Pre_defined_Variables_Z4_cutback)
else:
M_S = LOSA_dmd_Dailydmd
return(M_S)
def LOSA_Supply(WSM_Zone,LOSA_dmd,Max_Supply,Pre_defined_Variables_Opt_LOSAws):
Sup = 0
if Pre_defined_Variables_Opt_LOSAws == 1:
if WSM_Zone == 0:
Sup = LOSA_dmd
else:
Sup = min(LOSA_dmd, Max_Supply)
elif Pre_defined_Variables_Opt_LOSAws == 2:
Sup = 0
else:
pass
return(Sup)
#
def Zone_Code(Stage_LO,WSMs_A,WSMs_B,WSMs_C,WSMs_D3,WSMs_D2,WSMs_D1,WSMs_D0,WSMs_WSM1):
Zcd = 2
if Stage_LO > WSMs_A:
Zcd = 9
elif Stage_LO > WSMs_B:
Zcd = 8
elif Stage_LO > WSMs_C:
Zcd = 7
elif Stage_LO > WSMs_D3:
Zcd = 6
elif Stage_LO > WSMs_D2:
Zcd = 5
elif Stage_LO > WSMs_D1:
Zcd = 4
elif Stage_LO > WSMs_D0:
Zcd = 3
elif Stage_LO < WSMs_WSM1:
Zcd = 1
else:
Zcd = 2
return(Zcd)
def LO_Zone(Zone_Code):
Z = 0
if Zone_Code == 1:
Z = 'SSM'
elif Zone_Code == 2:
Z = 'E'
elif Zone_Code == 3:
Z = 'D0'
elif Zone_Code == 4:
Z = 'D1'
elif Zone_Code == 5:
Z = 'D2'
elif Zone_Code == 6:
Z = 'D3'
elif Zone_Code == 7:
Z = 'C'
elif Zone_Code == 8:
Z = 'B'
elif Zone_Code == 9:
Z = 'A'
return(Z)
def DecTree_Relslevel(Zone_Code,Zone_D_Rel_Code,Zone_C_Rel_Code,Zone_B_Rel_Code): #Note that DecTree_Relslevel(i) returns value at time step (i+2) in LO_Model dataFrame.
DTR = 0
if Zone_Code == 1:
DTR = 0
elif Zone_Code == 2:
DTR = 0
elif Zone_Code == 3:
DTR = -1
elif Zone_Code == 4:
DTR = Zone_D_Rel_Code
elif Zone_Code == 5:
if Zone_D_Rel_Code == -1:
DTR = -1
else:
DTR = min(4, Zone_D_Rel_Code*2)
elif Zone_Code == 6:
if Zone_D_Rel_Code == -1:
DTR = -1
else:
DTR = min(4, Zone_D_Rel_Code*3)
elif Zone_Code == 7:
DTR = Zone_C_Rel_Code
elif Zone_Code == 8:
DTR = Zone_B_Rel_Code
else:
DTR = 6
return(DTR)
def PlsDay(DayFlags,DecTree_Relslevel,Pre_defined_Variables_PlsDay_Switch):
PlsD = 0
if DayFlags == 'P.A.Day1':
if DecTree_Relslevel > 0 and DecTree_Relslevel < 4:
PlsD = 1
else:
PlsD = 0
else:
if Pre_defined_Variables_PlsDay_Switch == 1:
if 'PlsD' in locals():
if PlsD > 0 and PlsD < 10 and DecTree_Relslevel < 4:
PlsD = PlsD + 1
elif DecTree_Relslevel > 0 and DecTree_Relslevel < 4:
PlsD = 1
else:
PlsD = 0
else:
PlsD = 0
elif Pre_defined_Variables_PlsDay_Switch == 0:
if 'PlsD' in locals():
if PlsD > 0 and PlsD < 10:
PlsD = PlsD + 1
elif DecTree_Relslevel > 0 and DecTree_Relslevel < 4:
PlsD = 1
else:
PlsD = 0
else:
PlsD = 0
return(PlsD)
def Release_Level(Prev_RL,Stage_LO,Tributary_Condition,PlsDay,Zone_Code,DecTree_Relslevel,Pre_defined_Variables_MaxQstgTrigger):
RL = Prev_RL
if Stage_LO > Pre_defined_Variables_MaxQstgTrigger and Tributary_Condition == 6:#Note that at i =2 then, (i-2) = 0 which indicates 1/1/1965 for TC_LONINO because it starts at 1/1/1965!
RL = 6
elif PlsDay == 0 or Zone_Code > 7:
RL = DecTree_Relslevel
elif PlsDay == 1:
RL = DecTree_Relslevel
else:
RL = RL
return(RL)
def ZoneCodeminus1Code(Zone_Code,WSMs_WSM1,WSMs_D0,WSMs_D1,WSMs_D2,WSMs_D3,WSMs_C,WSMs_B,WSMs_A):
Sam = 0
if (Zone_Code - 1) == 1:
Sam = WSMs_WSM1
elif (Zone_Code - 1) == 2:
Sam = WSMs_D0
elif (Zone_Code - 1) == 3:
Sam = WSMs_D1
elif (Zone_Code - 1) == 4:
Sam = WSMs_D2
elif (Zone_Code - 1) == 5:
Sam = WSMs_D3
elif (Zone_Code - 1) == 6:
Sam = WSMs_C
elif (Zone_Code - 1) == 7:
Sam = WSMs_B
elif (Zone_Code - 1) == 8:
Sam = WSMs_A
return(Sam)
def ZoneCodeCode(Zone_Code,WSMs_WSM1,WSMs_D0,WSMs_D1,WSMs_D2,WSMs_D3,WSMs_C,WSMs_B,WSMs_A):
Roty = 0
if Zone_Code == 1:
Roty = WSMs_WSM1
elif Zone_Code == 2:
Roty = WSMs_D0
elif Zone_Code == 3:
Roty = WSMs_D1
elif Zone_Code == 4:
Roty = WSMs_D2
elif Zone_Code == 5:
Roty = WSMs_D3
elif Zone_Code == 6:
Roty = WSMs_C
elif Zone_Code == 7:
Roty = WSMs_B
elif Zone_Code == 8:
Roty = WSMs_A
return(Roty)
def Fraction_of_Zone_height(Zone_Code,Stage_LO,ZoneCodeminus1Code,ZoneCodeCode):
FZH = 0
if Zone_Code == 1 or Zone_Code == 9:
FZH = 1
else:
FZH = ((Stage_LO - ZoneCodeminus1Code) / (ZoneCodeCode - ZoneCodeminus1Code + 0.01))
return(FZH)
def ReLevelCode_1(Release_Level,Pre_defined_Variables_dstar_D1,Pre_defined_Variables_dstar_D2,Pre_defined_Variables_dstar_D3,Pre_defined_Variables_dstar_C,Pre_defined_Variables_dstar_B):
Hnur = 0
if (Release_Level + 2) == 1:
Hnur = -99
elif (Release_Level + 2) == 2:
Hnur = -99
elif (Release_Level + 2) == 3:
Hnur = Pre_defined_Variables_dstar_D1
elif (Release_Level + 2) == 4:
Hnur = Pre_defined_Variables_dstar_D2
elif (Release_Level + 2) == 5:
Hnur = Pre_defined_Variables_dstar_D3
elif (Release_Level + 2) == 6:
Hnur = Pre_defined_Variables_dstar_C
elif (Release_Level + 2) == 7:
Hnur = Pre_defined_Variables_dstar_B
elif (Release_Level + 2) == 8:
Hnur = -99
return(Hnur)
def ReLevelCode_2(Release_Level,Pre_defined_Variables_astar_D1,Pre_defined_Variables_astar_D2,Pre_defined_Variables_astar_D3,Pre_defined_Variables_astar_C,Pre_defined_Variables_astar_B):
Hnur = 0
if (Release_Level + 2) == 1:
Hnur = 0
elif (Release_Level + 2) == 2:
Hnur = 0
elif (Release_Level + 2) == 3:
Hnur = Pre_defined_Variables_astar_D1
elif (Release_Level + 2) == 4:
Hnur = Pre_defined_Variables_astar_D2
elif (Release_Level + 2) == 5:
Hnur = Pre_defined_Variables_astar_D3
elif (Release_Level + 2) == 6:
Hnur = Pre_defined_Variables_astar_C
elif (Release_Level + 2) == 7:
Hnur = Pre_defined_Variables_astar_B
elif (Release_Level + 2) == 8:
Hnur = 0
return(Hnur)
def ReLevelCode_3_S80(Release_Level,Pre_defined_Variables_bstar_S80_D1,Pre_defined_Variables_bstar_S80_D2,Pre_defined_Variables_bstar_S80_D3,Pre_defined_Variables_bstar_S80_C,Pre_defined_Variables_bstar_S80_B):
Hnur = 0
if (Release_Level + 2) == 1:
Hnur = 1
elif (Release_Level + 2) == 2:
Hnur = 2
elif (Release_Level + 2) == 3:
Hnur = Pre_defined_Variables_bstar_S80_D1
elif (Release_Level + 2) == 4:
Hnur = Pre_defined_Variables_bstar_S80_D2
elif (Release_Level + 2) == 5:
Hnur = Pre_defined_Variables_bstar_S80_D3
elif (Release_Level + 2) == 6:
Hnur = Pre_defined_Variables_bstar_S80_C
elif (Release_Level + 2) == 7:
Hnur = Pre_defined_Variables_bstar_S80_B
elif (Release_Level + 2) == 8:
Hnur = 1
return(Hnur)
def Outlet2DS_Mult(Seasons_Season,Seasons_Month,dh_7days,ReLevelCode_1,Fraction_of_Zone_height,ReLevelCode_2,ReLevelCode_3_S80,Pre_defined_Variables_Opt_QregMult):
Mult = 0
if Pre_defined_Variables_Opt_QregMult == 0 or (Pre_defined_Variables_Opt_QregMult == 1 and Seasons_Season > 2) or\
(Pre_defined_Variables_Opt_QregMult == 2 and Seasons_Month > 4 and Seasons_Month < 9):
Mult = 1
elif dh_7days < ReLevelCode_1 and Fraction_of_Zone_height < ReLevelCode_2:
Mult = ReLevelCode_3_S80
return(Mult)
def Outlet2DS_Mult_2(month,day,PlsDay,S80_Mult_i_PlsDay,S80_Mult_i,Pre_defined_Variables_Opt_QregMult):
S80_M2 = 0
if Pre_defined_Variables_Opt_QregMult == 1 and (month == 6 or month == 11)\
and day < 10 and PlsDay > 1 and PlsDay < 11:
S80_M2 = S80_Mult_i_PlsDay
else:
S80_M2 = S80_Mult_i
return(S80_M2)
def Outlet2DSRS(Release_Level,S80_RegRelRates_Zone_D1,S80avgL1,Pulses_S_80_L1,S80_Mult_2,CE_SLE_turns_SLEturn,S80_RegRelRates_Zone_D2,S80avgL2,Pulses_S_80_L2,S80_RegRelRates_Zone_D3,S80avgL3,Pulses_S_80_L3,S80_RegRelRates_Zone_C,S80_RegRelRates_Zone_B,S80_RegRelRates_Zone_A):
S = 0
if (Release_Level + 2) ==1:
S = 0
elif (Release_Level + 2) ==2:
S = 0
elif (Release_Level + 2) ==3:
S = S80_RegRelRates_Zone_D1/S80avgL1*Pulses_S_80_L1*S80_Mult_2*CE_SLE_turns_SLEturn
elif (Release_Level + 2) ==4:
S = S80_RegRelRates_Zone_D2/S80avgL2*Pulses_S_80_L2*S80_Mult_2*CE_SLE_turns_SLEturn
elif (Release_Level + 2) ==5:
S = S80_RegRelRates_Zone_D3/S80avgL3*Pulses_S_80_L3*S80_Mult_2*CE_SLE_turns_SLEturn
elif (Release_Level + 2) ==6:
S = S80_RegRelRates_Zone_C*S80_Mult_2*CE_SLE_turns_SLEturn
elif (Release_Level + 2) ==7:
S = S80_RegRelRates_Zone_B*S80_Mult_2*CE_SLE_turns_SLEturn
elif (Release_Level + 2) ==8:
S = S80_RegRelRates_Zone_A
return(S)
def Sum_Outlet2USRG1(day,S308RG1):
Sigma = 0
if day ==1:
Sigma = S308RG1
else:
Sigma = S308RG1 + Sigma
return(Sigma)
def Outlet2DSBS(Release_Level,Sum_S308RG1,VLOOKUP1_c,StlEst_baseflow,Pre_defined_Variables_Option_S80Baseflow):
BS = 0
if Release_Level == -1:
if Pre_defined_Variables_Option_S80Baseflow ==0:
BS = StlEst_baseflow
elif Sum_S308RG1/31 > VLOOKUP1_c:
BS = 0
else:
BS = VLOOKUP1_c
else:
BS = 0
return(BS)
def Outlet2USBK(Stage_LO,WSMs_D1,S308RG,C44RO,S308BK_data,Pre_defined_Variables_Opt_S308,Pre_defined_Variables_S308BK_Const,Pre_defined_Variables_S308_BK_Thr):
S308 = 0
if Pre_defined_Variables_Opt_S308 ==1:
if Pre_defined_Variables_S308BK_Const == 1:
if Stage_LO < min(Pre_defined_Variables_S308_BK_Thr, WSMs_D1-0.25) and S308RG == 0:
S308 = C44RO
else:
S308 = 0
else:
S308 = S308BK_data
else:
S308 = 0
return(S308)
def Outlet2USBS(S80BS,S308RG1,ROeast,Pre_defined_Variables_Option_S80Baseflow):
S308 = 0
if Pre_defined_Variables_Option_S80Baseflow == 0:
S308 = max(0, S80BS-(S308RG1+ROeast))
else:
S308 = max(0, S80BS-S308RG1)
return(S308)
def Sum_Outlet2USBK(day,S308BK):
SBK = 0
if day ==1:
SBK = S308BK
else:
SBK = S308BK + SBK
return(SBK)
def Outlet2USRG_Code(S308RG1,S308BS,S308RG_data,STEST_data,Pre_defined_Variables_Option_RegS77S308):
Code_1 = 0
if Pre_defined_Variables_Option_RegS77S308 + 1 == 1:
Code_1 = S308RG1 + S308BS
elif Pre_defined_Variables_Option_RegS77S308 + 1 == 2:
Code_1 = 0
elif Pre_defined_Variables_Option_RegS77S308 + 1 == 3:
Code_1 = S308RG_data + STEST_data
elif Pre_defined_Variables_Option_RegS77S308 + 1 == 4:
Code_1 = 0
return Code_1
def Outlet2USRG(S308RG_Code,S308RG_data,STEST_data,Pre_defined_Variables_Opt_S308,Pre_defined_Variables_S308RG_Const):
S_1 = 0
if Pre_defined_Variables_Opt_S308 ==1:
if Pre_defined_Variables_S308RG_Const == 1:
S_1 = S308RG_Code
else:
S_1 = S308RG_data + STEST_data
else:
S_1 = 0
return(S_1)
def S80(ROeast,S308RG,S80_data,Pre_defined_Variables_S80_Const):
S_80 = 0
if Pre_defined_Variables_S80_Const == 1:
S_80 = ROeast + S308RG
else:
S_80 = S80_data
return(S_80)
def ReLevelCode_3_S77(Release_Level,Pre_defined_Variables_bstar_S77_D1,Pre_defined_Variables_bstar_S77_D2,Pre_defined_Variables_bstar_S77_D3,Pre_defined_Variables_bstar_S77_C,Pre_defined_Variables_bstar_S77_B):
Hnur = 0
if (Release_Level + 2) == 1:
Hnur = 1
elif (Release_Level + 2) == 2:
Hnur = 1
elif (Release_Level + 2) == 3:
Hnur = Pre_defined_Variables_bstar_S77_D1
elif (Release_Level + 2) == 4:
Hnur = Pre_defined_Variables_bstar_S77_D2
elif (Release_Level + 2) == 5:
Hnur = Pre_defined_Variables_bstar_S77_D3
elif (Release_Level + 2) == 6:
Hnur = Pre_defined_Variables_bstar_S77_C
elif (Release_Level + 2) == 7:
Hnur = Pre_defined_Variables_bstar_S77_B
elif (Release_Level + 2) == 8:
Hnur = 1
return(Hnur)
def Outlet1US_Mult(Seasons_Season,Seasons_Month,dh_7days,ReLevelCode_1,Fraction_of_Zone_height,ReLevelCode_2,ReLevelCode_3_S77,Pre_defined_Variables_Opt_QregMult):
Mult = 0
if Pre_defined_Variables_Opt_QregMult == 0 or (Pre_defined_Variables_Opt_QregMult == 1 and Seasons_Season > 2) or\
(Pre_defined_Variables_Opt_QregMult == 2 and Seasons_Month > 4 and Seasons_Month < 9):
Mult = 1
elif dh_7days < ReLevelCode_1 and Fraction_of_Zone_height < ReLevelCode_2:
Mult = ReLevelCode_3_S77
return(Mult)
def Outlet1US_Mult_2(month,day,PlsDay,S77_Mult_i_PlsDay,S77_Mult_i,Pre_defined_Variables_Opt_QregMult):
S77_M2 = 0
if Pre_defined_Variables_Opt_QregMult == 1 and (month == 6 or month == 11)\
and day < 10 and PlsDay > 1 and PlsDay < 11:
S77_M2 = S77_Mult_i_PlsDay
else:
S77_M2 = S77_Mult_i
return(S77_M2)
def Outlet1USRS(Release_Level,S77_RegRelRates_Zone_D1,S77avgL1,Pulses_S_77_L1,S77_Mult_2,C43RO,CE_SLE_turns_CEturn,S77_RegRelRates_Zone_D2,S77avgL2,Pulses_S_77_L2,Zone_Code,S77_RegRelRates_Zone_D3,S77avgL3,Pulses_S_77_L3,S77_RegRelRates_Zone_C,S77_RegRelRates_Zone_B,S77_RegRelRates_Zone_A,Pre_defined_Variables_Opt_Outlet1DSRG):
S = 0
if (Release_Level + 2) ==1:
S = 0
elif (Release_Level + 2) ==2:
S = 0
elif (Release_Level + 2) ==3:
S = max(0, S77_RegRelRates_Zone_D1/S77avgL1*Pulses_S_77_L1*S77_Mult_2 - Pre_defined_Variables_Opt_Outlet1DSRG * C43RO) * CE_SLE_turns_CEturn
elif (Release_Level + 2) ==4:
S = max(0, S77_RegRelRates_Zone_D2/S77avgL2*Pulses_S_77_L2*S77_Mult_2 - Pre_defined_Variables_Opt_Outlet1DSRG * C43RO) * CE_SLE_turns_CEturn
elif (Release_Level + 2) ==5 and Zone_Code < 7:
S = max(0, S77_RegRelRates_Zone_D3/S77avgL3*Pulses_S_77_L3*S77_Mult_2 - Pre_defined_Variables_Opt_Outlet1DSRG * C43RO) * CE_SLE_turns_CEturn
elif (Release_Level + 2) ==5 and Zone_Code >= 7:
S = max(0, S77_RegRelRates_Zone_D3/S77avgL3*Pulses_S_77_L3*S77_Mult_2) * CE_SLE_turns_CEturn
elif (Release_Level + 2) ==6:
S = S77_RegRelRates_Zone_C*S77_Mult_2*CE_SLE_turns_CEturn
elif (Release_Level + 2) ==7:
S = S77_RegRelRates_Zone_B*S77_Mult_2*CE_SLE_turns_CEturn
elif (Release_Level + 2) ==8:
S = S77_RegRelRates_Zone_A
return(S)
def Sum_Outlet1USRS(day,Outlet1USRS):
Sigma = 0
if day ==1:
Sigma = Outlet1USRS
else:
Sigma = Outlet1USRS + Sigma
return(Sigma)
def Outlet1USBK(Stage_LO,Outlet1USRS,Outlet1USBSAP,Outlet1USEWS,C43RO,S77BK_data,Pre_defined_Variables_Outlet1USBK_Switch,Pre_defined_Variables_Outlet1USBK_Threshold):
Y = 0
if Pre_defined_Variables_Outlet1USBK_Switch == 1:
if Stage_LO < Pre_defined_Variables_Outlet1USBK_Threshold and Outlet1USRS == 0 and\
Outlet1USBSAP == 0 and Outlet1USEWS == 0:
Y = max(0,0.3*C43RO-5)
else:
Y = 0
else:
Y = S77BK_data
return(Y)
# def Outlet1DSBS(Release_Level,Sum_Outlet1USRS,VLOOKUP2_c,CalEst_baseflow,Pre_defined_Variables_Option_S77Baseflow):
# BS = 0
# if Release_Level == -1:
# if Pre_defined_Variables_Option_S77Baseflow ==0:
# BS = CalEst_baseflow
# elif Sum_Outlet1USRS/31 > VLOOKUP2_c:
# BS = 0
# else:
# BS = VLOOKUP2_c
# else:
# BS = 0
# return(BS)
def Outlet1DSBS(Release_Level,Sum_Outlet1USRS,VLOOKUP2_c,CalEst_baseflow,Pre_defined_Variables_Option_S77Baseflow):
BS = 0
if Release_Level >= -1:
if Pre_defined_Variables_Option_S77Baseflow ==0:
BS = CalEst_baseflow
elif Sum_Outlet1USRS/31 > VLOOKUP2_c:
BS = 0
else:
BS = VLOOKUP2_c
else:
BS = 0
return(BS)
# def Outlet1DSBS(Release_Level,Sum_Outlet1USRS,VLOOKUP2_c,CalEst_baseflow,Pre_defined_Variables_Option_S77Baseflow):
# BS = 0
# if Release_Level == -1 or Release_Level == 1 or Release_Level == 4:
# if Pre_defined_Variables_Option_S77Baseflow ==0:
# BS = CalEst_baseflow
# elif Sum_Outlet1USRS/31 > VLOOKUP2_c:
# BS = 0
# else:
# BS = VLOOKUP2_c
# else:
# BS = 0
# return(BS)
def Outlet1USBS(Outlet1DSBS,Outlet1USRS,ROwest,Pre_defined_Variables_Option_S77Baseflow):
Z = 0
if Pre_defined_Variables_Option_S77Baseflow == 0:
Z = max(0,Outlet1DSBS-(Outlet1USRS+ROwest))
else:
Z = max(0,Outlet1DSBS-Outlet1USRS)
return(Z)
def Outlet1USBSAP(Outlet1USBS,Post_Ap_Baseflow,Pre_defined_Variables_Opt_AdapProt):
S77 = 0
if Pre_defined_Variables_Opt_AdapProt == 0:
S77 = Outlet1USBS
else:
S77 = Post_Ap_Baseflow
return(S77)
def Outlet1USEWS(Post_AP_EWS,CAEST_data,Pre_defined_Variables_Outlet1USEWS_Switch,Pre_defined_Variables_Opt_AdapProt):
X = 0
if Pre_defined_Variables_Outlet1USEWS_Switch ==1:
if Pre_defined_Variables_Opt_AdapProt == 0:
X = 0
else:
X = Post_AP_EWS
else:
X = CAEST_data
return(X)
def Outlet1USREG(Outlet1USRS,Outlet1USBSAP,S77RG_data,Pre_defined_Variables_Outlet1USREG_Switch,Pre_defined_Variables_Option_RegS77S308):
W = 0
if Pre_defined_Variables_Outlet1USREG_Switch == 1:
if Pre_defined_Variables_Option_RegS77S308 + 1 == 1:
W = Outlet1USRS + Outlet1USBSAP
elif Pre_defined_Variables_Option_RegS77S308 + 1 == 2:
W = 0
elif Pre_defined_Variables_Option_RegS77S308 + 1 == 3:
W = S77RG_data
elif Pre_defined_Variables_Option_RegS77S308 + 1 == 4:
W = 0
else:
W = S77RG_data
return(W)
def Outlet1DS(Outlet1USREG,Outlet1USEWS,ROwest,Outlet1DS_data,Pre_defined_Variables_Outlet1DS_Switch):
S = 0
if Pre_defined_Variables_Outlet1DS_Switch == 1:
S = Outlet1USREG + Outlet1USEWS + ROwest
else:
S = Outlet1DS_data
return(S)
def Choose_WCA(RegWCA_data,Pre_defined_Variables_Option_RegWCA,Pre_defined_Variables_Constant_RegWCA):
Ch = 0
if Pre_defined_Variables_Option_RegWCA == 1:
Ch = 0
elif Pre_defined_Variables_Option_RegWCA == 2:
Ch = RegWCA_data
elif Pre_defined_Variables_Option_RegWCA == 3:
Ch = 0
elif Pre_defined_Variables_Option_RegWCA == 4:
Ch = Pre_defined_Variables_Constant_RegWCA
return(Ch)
def Choose_L8C51(RegL8C51_data,Pre_defined_Variables_Option_RegL8C51,Pre_defined_Variables_Constant_RegL8C51):
Ch = 0
if Pre_defined_Variables_Option_RegL8C51 == 1:
Ch = 0
elif Pre_defined_Variables_Option_RegL8C51 == 2:
Ch = RegL8C51_data
elif Pre_defined_Variables_Option_RegL8C51 == 3:
Ch = 0
elif Pre_defined_Variables_Option_RegL8C51 == 4:
Ch = Pre_defined_Variables_Constant_RegL8C51
return(Ch)
def ET(et_dry_data,Stage2ar,et_litoral_data,Stage2marsh,et_open_data,ETVOL_data,Pre_defined_Variables_ET_Switch):
E = 0
if Pre_defined_Variables_ET_Switch == 1:
E = ((et_dry_data/12)*(466000-Stage2ar)) + ((et_litoral_data/12)*(Stage2marsh))+\
((et_open_data/12)*(Stage2ar-Stage2marsh))
else:
E = ETVOL_data
return(E)
def Choose_WSA_1(WSMs_WSM1,Pre_defined_Variables_Opt_WSA,Pre_defined_Variables_WSAtrig2,Pre_defined_Variables_WSAoff2):
Ch1 = 0
if Pre_defined_Variables_Opt_WSA == 1:
Ch1 = Pre_defined_Variables_WSAtrig2
elif Pre_defined_Variables_Opt_WSA == 2:
Ch1 = WSMs_WSM1 + Pre_defined_Variables_WSAoff2
else:
Ch1 = np.nan
return(Ch1)
def Choose_WSA_2(WSMs_WSM1,Pre_defined_Variables_Opt_WSA,Pre_defined_Variables_WSAtrig1,Pre_defined_Variables_WSAoff1):
Ch2 = 0
if Pre_defined_Variables_Opt_WSA == 1:
Ch2 = Pre_defined_Variables_WSAtrig1
elif Pre_defined_Variables_Opt_WSA == 2:
Ch2 = WSMs_WSM1 + Pre_defined_Variables_WSAoff1
else:
Ch2 = np.nan
return(Ch2)
def WSA_MIA(Are_WCA_stages_too_low,LONINO_Seasonal_Classes,Stage_LO,Choose_WSA_1,MIA_cfs,S3PMP,Choose_WSA_2,Pre_defined_Variables_Opt_WSA,Pre_defined_Variables_WSA_THC,Pre_defined_Variables_MIAcap2,Pre_defined_Variables_MIAcap1):
WSA = 0
if Pre_defined_Variables_Opt_WSA == 0 or Are_WCA_stages_too_low == True or LONINO_Seasonal_Classes > Pre_defined_Variables_WSA_THC:
WSA = 0
elif Stage_LO < Choose_WSA_1:
WSA = max(0,min(Pre_defined_Variables_MIAcap2, MIA_cfs)-S3PMP)
elif Stage_LO < Choose_WSA_2:
WSA = max(0,min(Pre_defined_Variables_MIAcap1, MIA_cfs)-S3PMP)
else:
WSA = 0
return(WSA)
def WSA_NNR(Are_WCA_stages_too_low,LONINO_Seasonal_Classes,Stage_LO,Choose_WSA_1,NNR_cfs,S2PMP,Choose_WSA_2,Pre_defined_Variables_Opt_WSA,Pre_defined_Variables_WSA_THC,Pre_defined_Variables_NNRcap2,Pre_defined_Variables_NNRcap1):
WSA = 0
if Pre_defined_Variables_Opt_WSA == 0 or Are_WCA_stages_too_low == True or LONINO_Seasonal_Classes > Pre_defined_Variables_WSA_THC:
WSA = 0
elif Stage_LO < Choose_WSA_1:
WSA = max(0,min(Pre_defined_Variables_NNRcap2, NNR_cfs)-S2PMP)
elif Stage_LO < Choose_WSA_2:
WSA = max(0,min(Pre_defined_Variables_NNRcap1, NNR_cfs)-S2PMP)
else:
WSA = 0
return(WSA)
def Storage(DayFlags,Storage_i,StartStorage,Storage_iplus1,DSto_iplus2):
Sto = 0
if DayFlags == 'CS start date':
Sto = Storage_i
elif DayFlags == 'SimDay1':
Sto = StartStorage
else:
Sto = Storage_iplus1 + DSto_iplus2
return(Sto)
def Lake_Stage(stg2sto_Storage_iplus2,EOD_Stg_data,Pre_defined_Variables_Option_Stage):
Sta = 0
if Pre_defined_Variables_Option_Stage+1 == 1:
Sta = stg2sto_Storage_iplus2
elif Pre_defined_Variables_Option_Stage+1 == 2:
Sta = np.nan
elif Pre_defined_Variables_Option_Stage+1 == 3:
Sta = EOD_Stg_data
elif Pre_defined_Variables_Option_Stage+1 == 4:
Sta = np.nan
elif Pre_defined_Variables_Option_Stage+1 == 5:
Sta = np.nan
return(Sta)