@@ -293,6 +293,36 @@ namespace gridpp {
293
293
int max_points,
294
294
bool allow_extrapolation=true );
295
295
296
+ /* * Optimal interpolation for an ensemble point field (R bindings)
297
+ * See Lussana et al 2019 (DOI: 10.1002/qj.3646)
298
+ * @param bpoints Points of background field
299
+ * @param background 2D vector of background values (L, E)
300
+ * @param obs_points Observation points
301
+ * @param obs 1D vector of observations
302
+ * @param obs_standard_deviations 1D vector of observation standard deviations
303
+ * @param background_at_points 2D vector of background at observation points (L, E)
304
+ * @param which_structfun structure function to use (0=Barnes;1=MixA)
305
+ * @param dh length scale for the horizontal structure function
306
+ * @param dz length scale for the vertical structure function
307
+ * @param dw minimum value of the correlation coefficient for laf structure function
308
+ * @param max_points Maximum number of observations to use inside localization zone; Use 0 to disable
309
+ * @param allow_extrapolation Allow OI to extrapolate increments outside increments at observations
310
+ * @returns 2D vector of analised values (L, E)
311
+ */
312
+ vec2 R_optimal_interpolation_ensi (const Points& bpoints,
313
+ const vec2& background,
314
+ const Points& obs_points,
315
+ const vec& obs,
316
+ const vec& obs_standard_deviations,
317
+ const vec2& background_at_points,
318
+ /* const StructureFunction& structure, */
319
+ int which_structfun,
320
+ float dh,
321
+ float dz,
322
+ float dw,
323
+ int max_points,
324
+ bool allow_extrapolation=true );
325
+
296
326
/* * Optimal interpolation for an ensemble gridded field (alternative version)
297
327
* Work in progress
298
328
* @param bgrid Grid of background field
@@ -324,33 +354,35 @@ namespace gridpp {
324
354
int max_points,
325
355
bool allow_extrapolation=true); */
326
356
327
- /* * Optimal interpolation for an ensemble gridded field (alternative version)
357
+ /* * Optimal interpolation for an ensemble gridded field (alternative version that works with R bindings )
328
358
* Work in progress
329
- * @param bgrid Grid of background field
330
- * @param background 3D vector of (left) background values to update (Y, X, E)
331
- * @param background 3D vector of (LEFT) background values (Y, X, E) used to compute correlations
332
- * @param obs_points observation points
333
- * @param obs 2D vector of perturbed observations (S, E)
334
- * @param background 3D vector of (right) background values used to compute innovations (Y, X, E)
335
- * @param background 3D vector of (RIGHT) background values (Y, X, E) used to compute correlations
336
- * @param dh structure Structure function par 1
337
- * @param dz structure Structure function par 2
338
- * @param dw structure Structure function par 3
359
+ * @param bpoints Points of background field
360
+ * @param background 2D vector of (left) background values to update (M, E) M=num. grid points
361
+ * @param background 2D vector of (LEFT) background values (M, E) used to compute correlations
362
+ * @param obs_points Observation points
363
+ * @param obs 2D vector of perturbed observations (S, E) S=num. obs points
364
+ * @param background 2D vector of (right) background values used to compute innovations (S, E)
365
+ * @param background 2D vector of (RIGHT) background values (S, E) used to compute correlations
366
+ * @param which_structfun structure function to use (0=Barnes;1=MixA)
367
+ * @param dh length scale for the horizontal structure function
368
+ * @param dz length scale for the vertical structure function
369
+ * @param dw minimum value of the correlation coefficient for laf structure function
339
370
* @param variance_ratio (ratio of observation to right background error variance)
340
371
* @param standard deviation ratio (ratio of left to right background error standard deviation)
341
372
* @param weight given to the analysis increment
342
373
* @param max_points Maximum number of observations to use inside localization zone; Use 0 to disable
343
374
* @param allow_extrapolation Allow OI to extrapolate increments outside increments at observations
344
- * @returns 3D vector of analised values (Y, X , E)
375
+ * @returns 2D vector of analised values (M , E)
345
376
*/
346
- vec2 optimal_interpolation_ensi_lr (const Points& bpoints,
377
+ vec2 R_optimal_interpolation_ensi_lr (const Points& bpoints,
347
378
const vec2& background_l,
348
379
const vec2& background_L,
349
380
const Points& obs_points,
350
381
const vec2& obs,
351
382
const vec2& pbackground_r,
352
383
const vec2& pbackground_R,
353
384
/* const StructureFunction& structure, */
385
+ int which_structfun,
354
386
float dh,
355
387
float dz,
356
388
float dw,
@@ -2000,6 +2032,34 @@ namespace gridpp {
2000
2032
* @returns Cressman rho
2001
2033
*/
2002
2034
float cressman_rho (float dist, float length) const ;
2035
+
2036
+ /* * Compactly supported second-order autoregressive correlation function
2037
+ * @param dist Distance between points. Same units as 'length'
2038
+ * @param length Length scale
2039
+ * @returns SOAR rho
2040
+ */
2041
+ float soar_rho (float dist, float length) const ;
2042
+
2043
+ /* * Compactly supported third-order autoregressive correlation function
2044
+ * @param dist Distance between points. Same units as 'length'
2045
+ * @param length Length scale
2046
+ * @returns TOAR rho
2047
+ */
2048
+ float toar_rho (float dist, float length) const ;
2049
+
2050
+ /* * Powerlaw correlation function
2051
+ * @param dist Distance between points. Same units as 'length'
2052
+ * @param length Length scale
2053
+ * @returns powerlaw rho
2054
+ */
2055
+ float powerlaw_rho (float dist, float length) const ;
2056
+
2057
+ /* * Linear correlation function
2058
+ * @param normdist Normalized distance between points. Must be in the range -1 to 1.
2059
+ * @param min Minimum allowed value for the correlation (if less than 0, the return 1)
2060
+ * @returns linear rho
2061
+ */
2062
+ float linear_rho (float normdist, float min) const ;
2003
2063
float m_localization_distance;
2004
2064
};
2005
2065
class MultipleStructure : public StructureFunction {
@@ -2052,6 +2112,39 @@ namespace gridpp {
2052
2112
bool m_is_spatial;
2053
2113
};
2054
2114
2115
+ /* * Mix of structure functions based on distance(SOAR), elevation(Gauss), and land area fraction(linear) */
2116
+ class MixAStructure : public StructureFunction {
2117
+ public:
2118
+ /* * Structure function SOAR - Gaussian - Linear
2119
+ * @param h: Horizontal decorrelation length >=0 [m] (SOAR)
2120
+ * @param v: Vertical decorrelation length >=0 [m] (Gaussian). If 0, disable decorrelation.
2121
+ * @param w: Land/sea decorrelation length >=0 [1] (Linear). If 0, disable decorrelation.
2122
+ * @param hmax: Truncate horizontal correlation beyond this length [m]. If undefined, 3.64 * h.
2123
+ */
2124
+ MixAStructure (float h, float v=0 , float w=0 , float hmax=MV);
2125
+
2126
+ /* * MixA structure function where decorrelation varyies spatially
2127
+ * @param grid: Grid of decorrelation field
2128
+ * @param h: 2D vector of horizontal decorrelation lengths >=0 (SOAR) , same size as grid [m]
2129
+ * @param v: 2D vector of Vertical decorrelation lengths >=0 [m] (Gaussian). Set all to 0 to disable decorrelation.
2130
+ * @param w: 2D vector of land/sea decorrelation lengths >=0 [1] (Linear). Set all to 0 to disable decorrelation.
2131
+ * @param min_rho: Truncate horizontal correlation when rho is less than this value [m].
2132
+ */
2133
+ MixAStructure (Grid grid, vec2 h, vec2 v, vec2 w, float min_rho=StructureFunction::default_min_rho);
2134
+ float corr (const Point& p1, const Point& p2) const ;
2135
+ vec corr (const Point& p1, const std::vector<Point>& p2) const ;
2136
+ StructureFunctionPtr clone () const ;
2137
+ float localization_distance (const Point& p) const ;
2138
+ private:
2139
+ float localization_distance (float h) const ;
2140
+ Grid m_grid;
2141
+ vec2 mH ;
2142
+ vec2 mV ;
2143
+ vec2 mW ;
2144
+ float m_min_rho;
2145
+ bool m_is_spatial;
2146
+ };
2147
+
2055
2148
/* * Simple structure function based on distance, elevation, and land area fraction */
2056
2149
class CressmanStructure : public StructureFunction {
2057
2150
public:
0 commit comments