Skip to content

Commit

Permalink
Feature 1583 skip_mean (#2090)
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnHalleyGotway authored Mar 8, 2022
1 parent 1b9784e commit ee0be03
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 7 deletions.
21 changes: 21 additions & 0 deletions met/src/basic/vx_util/num_array.cc
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,27 @@ int NumArray::has(double d, bool forward) const
////////////////////////////////////////////////////////////////////////


bool NumArray::is_const(double d) const

{

bool status = true;

for (int j=0; j<n_elements(); ++j) {
if ( !is_eq(e[j], d) ) {
status = false;
break;
}
}

return ( status && n_elements() > 0 );

}


////////////////////////////////////////////////////////////////////////


void NumArray::add(int k)

{
Expand Down
2 changes: 2 additions & 0 deletions met/src/basic/vx_util/num_array.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ class NumArray {
int has(int, bool forward=true) const;
int has(double, bool forward=true) const;

bool is_const(double) const;

void add(int);
void add(double);
void add(const NumArray &);
Expand Down
8 changes: 3 additions & 5 deletions met/src/libcode/vx_statistics/ens_stats.cc
Original file line number Diff line number Diff line change
Expand Up @@ -228,9 +228,6 @@ void ECNTInfo::set(const PairDataEnsemble &pd) {
// Store the number of ensemble members
n_ens = pd.n_ens;

// HiRA data has no ensemble mean
bool skip_mean = pd.mn_na.has(bad_data_double);

// Compute empirical CRPS scores
crps_emp = pd.crps_emp_na.wmean(pd.wgt_na);
crpscl_emp = pd.crpscl_emp_na.wmean(pd.wgt_na);
Expand Down Expand Up @@ -260,8 +257,9 @@ void ECNTInfo::set(const PairDataEnsemble &pd) {
}
}

// Compute ensemble mean based statistics
if(!skip_mean) {
// Compute ensemble mean based statistics, if possible
// HiRA stores the ensemble mean as bad data
if(!pd.mn_na.is_const(bad_data_double)) {

// Compute ME and RMSE values
fbar = obar = ffbar = oobar = fobar = 0.0;
Expand Down
4 changes: 2 additions & 2 deletions met/src/libcode/vx_statistics/pair_data_ensemble.cc
Original file line number Diff line number Diff line change
Expand Up @@ -628,9 +628,9 @@ void PairDataEnsemble::compute_ssvar() {
ssvar_bin_map bins;
NumArray cur;

// SSVAR requires valid ensemble mean input
// HiRA stores the ensemble mean as bad data
// Do not compute SSVAR when bad data is present
if(mn_na.has(bad_data_double)) return;
if(mn_na.is_const(bad_data_double)) return;

// Check number of points
if(o_na.n() != mn_na.n()) {
Expand Down

0 comments on commit ee0be03

Please sign in to comment.