forked from osamatarabih/LOONE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Dec_Tree_FNs.py
172 lines (171 loc) · 6.48 KB
/
Dec_Tree_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
# -*- coding: utf-8 -*-
"""
Created on Tue Oct 20 16:00:47 2020
@author: osamatarabih
"""
class Dec_Tree_FNs:
def Zone_D_Trib(Tributary_Condition,Pre_defined_Variables_Opt_NewTree):
if Pre_defined_Variables_Opt_NewTree == 1:
if Tributary_Condition == 1 or Tributary_Condition == 2:
Z = 1
elif Tributary_Condition == 3:
Z = 2
elif Tributary_Condition == 4:
Z = 3
else:
Z = 4
else:
if Tributary_Condition == 1 or Tributary_Condition == 2:
Z = 1
elif Tributary_Condition == 3:
Z = 2
elif Tributary_Condition == 4 or Tributary_Condition == 5:
Z = 3
else:
Z = 4
return(Z)
def Zone_D_stage(Stage_LO,WSMs_Cb):
if Stage_LO > WSMs_Cb:
ZDS = 2
else:
ZDS = 1
return(ZDS)
def Zone_D_Seas(LONINO_Seasonal_Classes,Zone_D_Trib,Pre_defined_Variables_Opt_NewTree):
if Pre_defined_Variables_Opt_NewTree == 0:
if LONINO_Seasonal_Classes == 4:
ZDSeas = 2
else:
ZDSeas = 1
else:
if Zone_D_Trib == 2:
if LONINO_Seasonal_Classes == 1:
ZDSeas = 1
else:
ZDSeas = 2
else:
if LONINO_Seasonal_Classes == 4:
ZDSeas = 2
else:
ZDSeas = 1
return(ZDSeas)
def Zone_D_MSeas(LONINO_MultiSeasonal_Classes):
if LONINO_MultiSeasonal_Classes == 1 or LONINO_MultiSeasonal_Classes == 2:
ZDMSeas = 1
else:
ZDMSeas = 2
return(ZDMSeas)
def Zone_D_Rel_Code(Zone_D_Branch_Code,Pre_defined_Variables_Opt_DecTree):
if Pre_defined_Variables_Opt_DecTree == 1:
if Zone_D_Branch_Code in (1111, 1112, 1121, 1122, 1211, 1212, 1221, 1222, 2111, 2112, 2121, 2211, 2212, 2221, 3111, 3211, 3121, 3221, 4111, 4121):
ZDRC = -1
elif Zone_D_Branch_Code in (2122, 2222, 3112, 3122, 3212, 3222, 4112, 4122, 4211, 4212):
ZDRC = 1
elif Zone_D_Branch_Code in (4221, 4222):
ZDRC = 4
else:
ZDRC = float("nan")
else:
ZDRC = 1
return(ZDRC)
def Zone_C_Trib(Tributary_Condition,Pre_defined_Variables_Opt_NewTree):
if Pre_defined_Variables_Opt_NewTree == 1:
if Tributary_Condition == 1 or Tributary_Condition == 2:
Z = 1
elif Tributary_Condition == 3 or Tributary_Condition == 4:
Z = 2
else:
Z = 3
else:
if Tributary_Condition == 1 or Tributary_Condition == 2 or Tributary_Condition == 3:
Z = 1
elif Tributary_Condition == 4 or Tributary_Condition == 5:
Z = 2
else:
Z = 3
return(Z)
def Zone_C_Seas(LONINO_Seasonal_Classes,Pre_defined_Variables_Opt_NewTree):
if Pre_defined_Variables_Opt_NewTree == 1:
if LONINO_Seasonal_Classes == 1:
ZCSeas = 1
else:
ZCSeas = 2
else:
if LONINO_Seasonal_Classes == 1 or LONINO_Seasonal_Classes == 2:
ZCSeas = 1
else:
ZCSeas = 2
return(ZCSeas)
def Zone_C_MSeas(LONINO_MultiSeasonal_Classes):
if LONINO_MultiSeasonal_Classes == 1:
ZCMSeas = 1
else:
ZCMSeas = 2
return(ZCMSeas)
def Zone_C_MetFcast(Zone_C_Seas,LONINO_Seasonal_Classes,Pre_defined_Variables_Zone_C_MetFcast_Indicator):
if Pre_defined_Variables_Zone_C_MetFcast_Indicator == 0:
MF = Zone_C_Seas
else:
if LONINO_Seasonal_Classes == 1 or LONINO_Seasonal_Classes == 2:
MF = 1
else:
MF = 2
return(MF)
def Zone_C_Rel_Code(Zone_C_Branch_Code,Pre_defined_Variables_Opt_DecTree):
if Pre_defined_Variables_Opt_DecTree == 1:
if Zone_C_Branch_Code in(1111, 1211):
ZCRC = -1
elif Zone_C_Branch_Code in (1112, 1212):
ZCRC = 3
elif Zone_C_Branch_Code in (1121, 1122, 1221, 1222, 2111, 2112, 2121, 2122, 2211, 2212, 2221, 2222, 3111, 3112, 3121, 3122):
ZCRC = 4
elif Zone_C_Branch_Code in (3211, 3212, 3221, 3222):
ZCRC = 5
else:
ZCRC = float("nan")
else:
ZCRC = 4
return(ZCRC)
def Zone_B_Trib(Tributary_Condition,Pre_defined_Variables_Opt_NewTree):
if Pre_defined_Variables_Opt_NewTree == 1:
if Tributary_Condition == 1 or Tributary_Condition == 2:
Z = 1
elif Tributary_Condition == 3 or Tributary_Condition == 4:
Z = 2
else:
Z = 3
else:
if Tributary_Condition == 1 or Tributary_Condition == 2:
Z = 1
elif Tributary_Condition == 6:
Z = 3
else:
Z = 2
return(Z)
def Zone_B_Stage(Stage_LO,Seasons_Season):
if Stage_LO < 17.5:
if Seasons_Season in (1, 2, 3, 4):
St = 1
else:
St = 2
else:
St = 2
return(St)
def Zone_B_Seas(LONINO_Seasonal_Classes):
if LONINO_Seasonal_Classes == 1 or LONINO_Seasonal_Classes == 2:
ZBSeas = 1
else:
ZBSeas = 2
return(ZBSeas)
def Zone_B_Rel_Code(Zone_B_Branch_Code,Pre_defined_Variables_Opt_DecTree):
if Pre_defined_Variables_Opt_DecTree == 1:
if Zone_B_Branch_Code in(1111, 1211):
ZBRC = 3
elif Zone_B_Branch_Code in (1112, 1121, 1122, 1212, 1221, 1222, 2111, 2112, 2121, 2122, 2211, 2212, 2221, 2222, 3111, 3112, 3121, 3122, 3211, 3212, 3221, 3222, 1131, 1132, 1141, 1142, 1231, 1232, 1241, 1242, 2131, 2132, 2141, 2142, 2231, 2232, 2241, 2242):
ZBRC = 5
elif Zone_B_Branch_Code in (3131, 3132, 3141, 3142, 3231, 3232, 3241, 3242):
ZBRC = 6
else:
ZBRC = float("nan")
else:
ZBRC = 5
return(ZBRC)