Skip to content

Commit

Permalink
work in progress, first version of oi_..._lr ready
Browse files Browse the repository at this point in the history
  • Loading branch information
Cristian Lussana committed Sep 2, 2024
1 parent b409dd1 commit 70caf7a
Show file tree
Hide file tree
Showing 3 changed files with 432 additions and 14 deletions.
35 changes: 26 additions & 9 deletions include/gridpp.h
Original file line number Diff line number Diff line change
Expand Up @@ -293,17 +293,34 @@ namespace gridpp {
int max_points,
bool allow_extrapolation=true);

vec2 optimal_interpolation_ensi(const Points& bpoints,
const vec2& background, // T
// const vec2& other_background, // Precip
const vec2& original_background, // T
// const vec2& other_original_background, // Precip
/** Optimal interpolation for an ensemble gridded field (alternative version)
* Work in progress
* @param bgrid Grid of background field
* @param background 3D vector of (left) background values to update (Y, X, E)
* @param background 3D vector of (LEFT) background values (Y, X, E) used to compute correlations
* @param obs_points observation points
* @param obs 2D vector of perturbed observations (S, E)
* @param background 3D vector of (right) background values used to compute innovations (Y, X, E)
* @param background 3D vector of (RIGHT) background values (Y, X, E) used to compute correlations
* @param structure Structure function
* @param variance_ratio (ratio of observation to right background error variance)
* @param standard deviation ratio (ratio of left to right background error standard deviation)
* @param weight given to the analysis increment
* @param max_points Maximum number of observations to use inside localization zone; Use 0 to disable
* @param allow_extrapolation Allow OI to extrapolate increments outside increments at observations
* @returns 3D vector of analised values (Y, X, E)
*/
vec3 optimal_interpolation_ensi_lr(const Grid& bgrid,
const vec3& background_l,
const vec3& background_L,
const Points& obs_points,
const vec& obs, // Precip
const vec& obs_standard_deviations, // Precip
const vec2& background_at_points, // Precip
const vec2& original_background_at_points, // Precip origin
const vec& obs,
const vec2& pbackground_r,
const vec2& pbackground_R,
const StructureFunction& structure,
float var_ratios_or,
float std_ratios_lr,
float weigth,
int max_points,
bool allow_extrapolation=true);

Expand Down
6 changes: 1 addition & 5 deletions src/api/oi_ensi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,6 @@ vec3 gridpp::optimal_interpolation_ensi(const gridpp::Grid& bgrid,
}
vec2 gridpp::optimal_interpolation_ensi(const gridpp::Points& bpoints,
const vec2& background,
const vec2& other_background,
const vec2& original_background,
const gridpp::Points& points,
const vec& pobs, // gObs
const vec& psigmas, // pci
Expand All @@ -128,7 +126,6 @@ vec2 gridpp::optimal_interpolation_ensi(const gridpp::Points& bpoints,
}
if(background.size() != bpoints.size())
throw std::invalid_argument("Input field is not the same size as the grid");
// TODO: Check new backgrounds
if(pobs.size() != points.size())
throw std::invalid_argument("Observations and points exception mismatch");
if(psigmas.size() != points.size())
Expand Down Expand Up @@ -187,7 +184,6 @@ vec2 gridpp::optimal_interpolation_ensi(const gridpp::Points& bpoints,
}

// Calculate number of valid members
// TODO: Check the two other backgrounds
int nValidEns = 0;
ivec validEns;
for(int e = 0; e < nEns; e++) {
Expand Down Expand Up @@ -452,7 +448,7 @@ vec2 gridpp::optimal_interpolation_ensi(const gridpp::Points& bpoints,
int count = 0;
for(int e = 0; e < nValidEns; e++) {
int ei = validEns[e];
float value = original_background[y][ei];
float value = background[y][ei];
if(gridpp::is_valid(value)) {
X(e) = value;
total += value;
Expand Down
Loading

0 comments on commit 70caf7a

Please sign in to comment.