-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsink_n_source.py
166 lines (126 loc) · 5.38 KB
/
sink_n_source.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
def sink_n_source(precipitation_ts, et_model = None, snow_model = None, \
interception_losses = None, interception_threshold = None, \
temperature_ts = None, t_threshold = None):
if et_model is None and snow_model is None and interception_losses is None:
x = list(precipitation_ts)
elif et_model is None and snow_model is None:
precipitation = list(precipitation_ts)
x = precipitation_ts * interception_losses
if interception_threshold is None:
x = precipitation - x
else:
x[x > interception_threshold] = interception_threshold
x = precipitation - x
elif snow_model is None and interception_losses is None:
x = precipitation_ts - et_model
x = list(x)
elif et_model is None and interception_losses is None:
temp = temperature_ts
precipitation = precipitation_ts
melt_x = [0] * len(precipitation_ts)
x = [0] * len(precipitation_ts)
x[0] = 0
for i in range(len(precipitation_ts)-1):
if(temp[i] < t_threshold):
melt_x[i] = 0
x[i+1] = x[i] + precipitation[i+1]
elif(x[i] >= snow_model[i]):
melt_x[i] = snow_model[i]
x[i+1] = x[i] - snow_model[i]
else:
melt_x[i] = x[i]
x[i+1] = 0
x[0] = 0
for i in range(len(precipitation_ts)-1):
if(temp[i] < t_threshold):
x[i] = 0
elif(melt_x[i] > 0):
x[i] = melt_x[i] + precipitation[i]
else:
x[i] = precipitation[i]
elif interception_losses is None:
temp = temperature_ts
precipitation = precipitation_ts
melt_x = [0] * len(precipitation_ts)
x = [0] * len(precipitation_ts)
x[0] = 0
for i in range(len(precipitation_ts)-1):
if(temp[i] < t_threshold):
melt_x[i] = 0
x[i+1] = x[i] + precipitation[i+1]
elif(x[i] >= snow_model[i]):
melt_x[i] = snow_model[i]
x[i+1] = x[i] - snow_model[i]
else:
melt_x[i] = x[i]
x[i+1] = 0
for i in range(len(precipitation_ts)-1):
if(temp[i] < t_threshold):
x[i] = 0
elif(melt_x[i] > 0):
x[i] = melt_x[i] + precipitation[i]
else:
x[i] = precipitation[i]
x = [a - b for a, b in zip(x,et_model)]
elif et_model is None:
temp = temperature_ts
precipitation = list(precipitation_ts)
x = precipitation_ts * interception_losses
if interception_threshold is None:
x = precipitation - x
else:
x[x > interception_threshold] = interception_threshold
x = precipitation - x
precipitation = list(x)
melt_x = [0] * len(precipitation_ts)
x = [0] * len(precipitation_ts)
x[0] = 0
for i in range(len(precipitation_ts)-1):
if(temp[i] < t_threshold):
melt_x[i] = 0
x[i+1] = x[i] + precipitation[i+1]
elif(x[i] >= snow_model[i]):
melt_x[i] = snow_model[i]
x[i+1] = x[i] - snow_model[i]
else:
melt_x[i] = x[i]
x[i+1] = 0
for i in range(len(precipitation_ts)-1):
if(temp[i] < t_threshold):
x[i] = 0
elif(melt_x[i] > 0):
x[i] = melt_x[i] + precipitation[i]
else:
x[i] = precipitation[i]
else:
temp = temperature_ts
precipitation = list(precipitation_ts)
x = precipitation_ts * interception_losses
if interception_threshold is None:
x = precipitation - x
else:
x[x > interception_threshold] = interception_threshold
x = precipitation - x
precipitation = list(x)
melt_x = [0] * len(precipitation_ts)
x = [0] * len(precipitation_ts)
x[0] = 0
for i in range(len(precipitation_ts)-1):
if(temp[i] < t_threshold):
melt_x[i] = 0
x[i+1] = x[i] + precipitation[i+1]
elif(x[i] >= snow_model[i]):
melt_x[i] = snow_model[i]
x[i+1] = x[i] - snow_model[i]
else:
melt_x[i] = x[i]
x[i+1] = 0
for i in range(len(precipitation_ts)-1):
if(temp[i] < t_threshold):
x[i] = 0
elif(melt_x[i] > 0):
x[i] = melt_x[i] + precipitation[i]
else:
x[i] = precipitation[i]
x = [a - b for a, b in zip(x,et_model)]
return(x);