Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
tnipen committed Jun 14, 2024
1 parent b2b7593 commit b409dd1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
14 changes: 14 additions & 0 deletions include/gridpp.h
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,20 @@ 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
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 StructureFunction& structure,
int max_points,
bool allow_extrapolation=true);

/** Correction of a gridded field ensuring the distribution of values nearby match that of
* observations. This is an experimental method.
* @param bgrid Grid of background field
Expand Down
6 changes: 5 additions & 1 deletion src/api/oi_ensi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ 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 @@ -126,6 +128,7 @@ 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 @@ -184,6 +187,7 @@ 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 @@ -448,7 +452,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 = background[y][ei];
float value = original_background[y][ei];
if(gridpp::is_valid(value)) {
X(e) = value;
total += value;
Expand Down

0 comments on commit b409dd1

Please sign in to comment.