@@ -30,7 +30,7 @@ void print_matrix(Matrix matrix) {
30
30
template void print_matrix< ::mattype>(::mattype matrix);
31
31
template void print_matrix< ::cxtype>(::cxtype matrix);
32
32
33
- vec3 gridpp::optimal_interpolation_ensi_lr (const gridpp::Grid& bgrid,
33
+ /* vec3 gridpp::optimal_interpolation_ensi_lr(const gridpp::Grid& bgrid,
34
34
const vec3& background_l,
35
35
const vec3& background_L,
36
36
const gridpp::Points& points,
@@ -120,15 +120,18 @@ vec3 gridpp::optimal_interpolation_ensi_lr(const gridpp::Grid& bgrid,
120
120
}
121
121
}
122
122
return output;
123
- }
123
+ } */
124
124
vec2 gridpp::optimal_interpolation_ensi_lr (const gridpp::Points& bpoints,
125
125
const vec2& background_l,
126
126
const vec2& background_L,
127
127
const gridpp::Points& points,
128
128
const vec2& pobs,
129
129
const vec2& pbackground_r,
130
130
const vec2& pbackground_R,
131
- const gridpp::StructureFunction& structure,
131
+ /* const gridpp::StructureFunction& structure, it creates problem with R bindings */
132
+ float dh,
133
+ float dz,
134
+ float dw,
132
135
float var_ratios_or,
133
136
float std_ratios_lr,
134
137
float weigth,
@@ -150,6 +153,9 @@ vec2 gridpp::optimal_interpolation_ensi_lr(const gridpp::Points& bpoints,
150
153
if (pbackground_R.size () != points.size ())
151
154
throw std::invalid_argument (" Background RIGTH and points size mismatch" );
152
155
156
+ float hmax = 7 * dh;
157
+ BarnesStructure structure = BarnesStructure ( dh, dz, dw, hmax);
158
+
153
159
int nS = points.size ();
154
160
if (nS == 0 )
155
161
return background_l;
@@ -162,7 +168,8 @@ vec2 gridpp::optimal_interpolation_ensi_lr(const gridpp::Points& bpoints,
162
168
163
169
// Prepare output matrix
164
170
float missing_value = -99999.999 ;
165
- vec2 output = gridpp::init_vec2 (nY, nEns, missing_value);
171
+ /* vec2 output = gridpp::init_vec2(nY, nEns, missing_value); */
172
+ vec2 output = background_l;
166
173
167
174
vec blats = bpoints.get_lats ();
168
175
vec blons = bpoints.get_lons ();
@@ -366,8 +373,7 @@ vec2 gridpp::optimal_interpolation_ensi_lr(const gridpp::Points& bpoints,
366
373
// lK(1, lS): Kalman gain
367
374
mattype lK = lr_lr * arma::inv (lR_rr + lR_dd);
368
375
// dx(1, nValidEns): analysis increment
369
- vectype dx = std_ratios_lr * weigth * (lK * lInnov);
370
-
376
+ mattype dx = std_ratios_lr * weigth * (lK * lInnov);
371
377
// /////////////////////////////
372
378
// Anti-extrapolation filter //
373
379
// /////////////////////////////
@@ -400,6 +406,17 @@ vec2 gridpp::optimal_interpolation_ensi_lr(const gridpp::Points& bpoints,
400
406
int ei = validEns[e];
401
407
output[y][ei] = background_l[y][ei] + dx[e];
402
408
}
409
+ // debug
410
+ /* for(int i = 0; i < lS; i++) {
411
+ // compute lZ_R and lInnov
412
+ int index = lLocIndices[i];
413
+ std::cout << i << " backg_r obs " << pbackground_r[index][0] << " " << pobs[index][0] << std::endl;
414
+ } // end loop over closer observations
415
+ for(int e = 0; e < nValidEns; e++) {
416
+ int ei = validEns[e];
417
+ std::cout << ei << " backg_l analysis " << background_l[y][ei] << " " << output[y][ei] << std::endl;
418
+ } */
419
+
403
420
} // end loop over gridpoint
404
421
return output;
405
422
}
0 commit comments