@@ -31,7 +31,7 @@ variables are fast.
31
31
32
32
Input:
33
33
- `z` : vector of size (K + K*J)
34
- - `p` : parameters
34
+ - `p` : parameters (L96m struct)
35
35
- `t` : time (not used here since L96m is autonomous)
36
36
37
37
Output:
@@ -89,7 +89,7 @@ Both `rhs` and `x` are vectors of size p.K.
89
89
90
90
Input:
91
91
- `x` : vector of size K
92
- - `p` : parameters
92
+ - `p` : parameters (L96m struct)
93
93
- `t` : time (not used here since L96m is autonomous)
94
94
95
95
Output:
@@ -121,7 +121,7 @@ Both `rhs` and `x` are vectors of size p.K.
121
121
122
122
Input:
123
123
- `x` : vector of size K
124
- - `p` : parameters
124
+ - `p` : parameters (L96m struct)
125
125
- `t` : time (not used here since L96m is autonomous)
126
126
127
127
Output:
@@ -177,4 +177,55 @@ function set_G0(p::L96m, slope::Real)
177
177
set_G0 (p, slope = slope)
178
178
end
179
179
180
+ """
181
+ Gather (xk, Yk) pairs that are further used to train a GP regressor
182
+
183
+ Input:
184
+ - `p` : parameters (L96m struct)
185
+ - `sol` : time series of a solution; time steps are in the 2nd dimension
186
+ (usually, just `sol` output from a time-stepper)
187
+
188
+ Output:
189
+ - `pairs` : a 2-d array of size (N, 2) containing (xk, Yk) pairs, where N is
190
+ the 2nd dimension in `sol` (number of time steps)
191
+
192
+ """
193
+ function gather_pairs (p:: L96m , sol)
194
+ N = size (sol, 2 )
195
+ pairs = Array {Float64, 2} (undef, p. K * N, 2 )
196
+ for n in 1 : N
197
+ pairs[p. K * (n- 1 ) + 1 : p. K * n, 1 ] = sol[1 : p. K, n]
198
+ pairs[p. K * (n- 1 ) + 1 : p. K * n, 2 ] = compute_Yk (p, sol[:,n])
199
+ end
200
+ return pairs
201
+ end
202
+
203
+ """
204
+ Returns a randomly initialized array that can be used as an IC to ODE solver
205
+
206
+ The returned array is of size `p.K + p.K * p.J`.
207
+ The first `p.K` variables are slow and are drawn randomly ~ U[-5; 10]; each of
208
+ the fast variables corresponding to the same slow variable is set to the value
209
+ of that slow variable.
210
+
211
+ For example, if K == 2 and J = 3, the returned array will be
212
+ [ rand1, rand2, rand1, rand1, rand1, rand2, rand2, rand2 ]
213
+
214
+ Input:
215
+ - `p` : parameters (L96m struct)
216
+
217
+ Output:
218
+ - `z00` : array of size `p.K + p.K * p.J` with random values
219
+ """
220
+ function random_init (p:: L96m )
221
+ z00 = Array {Float64} (undef, p. K + p. K * p. J)
222
+
223
+ z00[1 : p. K] .= rand (p. K) * 15 .- 5
224
+ for k_ in 1 : p. K
225
+ z00[p. K+ 1 + (k_- 1 )* p. J : p. K + k_* p. J] .= z00[k_]
226
+ end
227
+
228
+ return z00
229
+ end
230
+
180
231
0 commit comments