Skip to content

Commit

Permalink
Per #1918, add normalize_flag option to gen_ens_prod.
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnHalleyGotway committed Feb 18, 2022
1 parent e72368f commit 0e658a4
Show file tree
Hide file tree
Showing 8 changed files with 404 additions and 70 deletions.
7 changes: 7 additions & 0 deletions met/data/config/ConfigConstants
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ AW_MEAN = 20;
GAUSSIAN = 21;
MAXGAUSS = 22;
GEOG_MATCH = 23;
HIRA = 24;

// Interpolation types
NONE = 1;
Expand Down Expand Up @@ -169,3 +170,9 @@ BETA = 8;
TOP = TRUE;
BOTTOM = FALSE;

// Normalization types
NONE = 1;
CLIMO_ANOM = 2;
CLIMO_STD_ANOM = 3;
FCST_ANOM = 4;
FCST_STD_ANOM = 5;
9 changes: 5 additions & 4 deletions met/data/config/GenEnsProdConfig_default
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,11 @@ regrid = {
//
// May be set separately in each "field" entry
//
censor_thresh = [];
censor_val = [];
cat_thresh = [];
nc_var_str = "";
censor_thresh = [];
censor_val = [];
cat_thresh = [];
nc_var_str = "";
normalize_flag = NONE;

//
// Ensemble fields to be processed
Expand Down
26 changes: 26 additions & 0 deletions met/src/basic/vx_config/config_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,20 @@ enum MatchType {
MatchType_NoMerge // Match with no additional merging
};

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

//
// Enumeration for normalization options
//

enum NormalizeType {
NormalizeType_None, // No normalization
NormalizeType_ClimoAnom, // Subtract climo mean
NormalizeType_ClimoStdAnom, // Subtract climo mean and divide by standard deviation
NormalizeType_FcstAnom, // Subtract ensemble mean
NormalizeType_FcstStdAnom // Subtract ensemble mean and divide by standard deviation
};

////////////////////////////////////////////////////////////////////////
//
// Constants used in configuartion files
Expand Down Expand Up @@ -752,6 +766,12 @@ static const char conf_key_dist_parm[] = "dist_parm";
static const char conf_key_inst_bias_scale[] = "inst_bias_scale";
static const char conf_key_inst_bias_offset[] = "inst_bias_offset";

//
// Gen-Ens-Prod specific parameter key names
//

static const char conf_key_normalize_flag[] = "normalize_flag";

// Distribution options
static const char conf_val_normal[] = "NORMAL";
static const char conf_val_exponential[] = "EXPONENTIAL";
Expand All @@ -760,6 +780,12 @@ static const char conf_val_gamma[] = "GAMMA";
static const char conf_val_uniform[] = "UNIFORM";
static const char conf_val_beta[] = "BETA";

// Normalization options
static const char conf_val_climo_anom[] = "CLIMO_ANOM";
static const char conf_val_climo_std_anom[] = "CLIMO_STD_ANOM";
static const char conf_val_fcst_anom[] = "FCST_ANOM";
static const char conf_val_fcst_std_anom[] = "FCST_STD_ANOM";

//
// STAT-Analysis specific parameter key names
//
Expand Down
78 changes: 76 additions & 2 deletions met/src/basic/vx_config/config_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,10 @@ RegridInfo::RegridInfo() {
void RegridInfo::validate() {

// Check for unsupported regridding options
if(method == InterpMthd_Best ||
if(method == InterpMthd_Best ||
method == InterpMthd_Geog_Match ||
method == InterpMthd_Gaussian) {
method == InterpMthd_Gaussian ||
method == InterpMthd_HiRA) {
mlog << Error << "\nRegridInfo::validate() -> "
<< "\"" << interpmthd_to_string(method)
<< "\" not valid for regridding, only interpolating.\n\n";
Expand Down Expand Up @@ -2272,6 +2273,7 @@ InterpMthd int_to_interpmthd(int i) {
else if(i == conf_const.lookup_int(interpmthd_gaussian_str)) m = InterpMthd_Gaussian;
else if(i == conf_const.lookup_int(interpmthd_maxgauss_str)) m = InterpMthd_MaxGauss;
else if(i == conf_const.lookup_int(interpmthd_geog_match_str)) m = InterpMthd_Geog_Match;
else if(i == conf_const.lookup_int(interpmthd_hira_str)) m = InterpMthd_HiRA;
else {
mlog << Error << "\nconf_int_to_interpmthd() -> "
<< "Unexpected value of " << i
Expand Down Expand Up @@ -2833,6 +2835,47 @@ ConcatString matchtype_to_string(MatchType type) {

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

NormalizeType int_to_normalizetype(int v) {
NormalizeType t = NormalizeType_None;

// Convert integer to enumerated NormalizeType
if(v == conf_const.lookup_int(conf_val_none)) t = NormalizeType_None;
else if(v == conf_const.lookup_int(conf_val_climo_anom)) t = NormalizeType_ClimoAnom;
else if(v == conf_const.lookup_int(conf_val_climo_std_anom)) t = NormalizeType_ClimoStdAnom;
else if(v == conf_const.lookup_int(conf_val_fcst_anom)) t = NormalizeType_FcstAnom;
else if(v == conf_const.lookup_int(conf_val_fcst_std_anom)) t = NormalizeType_FcstStdAnom;
else {
mlog << Error << "\nint_to_normalizetype() -> "
<< "Unexpected value of " << v << ".\n\n";
exit(1);
}

return(t);
}

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

ConcatString normalizetype_to_string(NormalizeType type) {
ConcatString s;

// Convert enumerated NormalizeType to string
switch(type) {
case(NormalizeType_None): s = conf_val_none; break;
case(NormalizeType_ClimoAnom): s = conf_val_climo_anom; break;
case(NormalizeType_ClimoStdAnom): s = conf_val_climo_std_anom; break;
case(NormalizeType_FcstAnom): s = conf_val_fcst_anom; break;
case(NormalizeType_FcstStdAnom): s = conf_val_fcst_std_anom; break;
default:
mlog << Error << "\nnormalizetype_to_string() -> "
<< "Unexpected NormalizeType value of " << type << ".\n\n";
exit(1);
}

return(s);
}

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

DistType int_to_disttype(int v) {
DistType t = DistType_None;

Expand Down Expand Up @@ -2979,3 +3022,34 @@ StringArray parse_conf_ens_member_ids(Dictionary *dict) {
}

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

NormalizeType parse_conf_normalize_flag(Dictionary *dict) {
NormalizeType t = NormalizeType_None;
int v;

if(!dict) {
mlog << Error << "\nparse_conf_normalize_type() -> "
<< "empty dictionary!\n\n";
exit(1);
}

// Get the integer flag value for the current entry
v = dict->lookup_int(conf_key_normalize_flag);

// Convert integer to enumerated WaveletType
if(v == conf_const.lookup_int(conf_val_none)) t = NormalizeType_None;
else if(v == conf_const.lookup_int(conf_val_climo_anom)) t = NormalizeType_ClimoAnom;
else if(v == conf_const.lookup_int(conf_val_climo_std_anom)) t = NormalizeType_ClimoStdAnom;
else if(v == conf_const.lookup_int(conf_val_fcst_anom)) t = NormalizeType_FcstAnom;
else if(v == conf_const.lookup_int(conf_val_fcst_std_anom)) t = NormalizeType_FcstStdAnom;
else {
mlog << Error << "\nparse_conf_normalize_flag() -> "
<< "Unexpected config file value of " << v << " for \""
<< conf_key_normalize_flag << "\".\n\n";
exit(1);
}

return(t);
}

///////////////////////////////////////////////////////////////////////////////
4 changes: 4 additions & 0 deletions met/src/basic/vx_config/config_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ extern map<ConcatString,ThreshArray>
extern void parse_conf_range_int(Dictionary *dict, int &beg, int &end);
extern void parse_conf_range_double(Dictionary *dict, double &beg, double &end);
extern StringArray parse_conf_ens_member_ids(Dictionary *dict);
extern NormalizeType parse_conf_normalize_flag(Dictionary *dict);

extern void check_mask_names(const StringArray &);

Expand Down Expand Up @@ -119,6 +120,9 @@ extern ConcatString obssummary_to_string(ObsSummary, int);
extern MatchType int_to_matchtype(int);
extern ConcatString matchtype_to_string(MatchType);

extern NormalizeType int_to_normalizetype(int);
extern ConcatString normalizetype_to_string(NormalizeType);

extern DistType int_to_disttype(int);
extern DistType string_to_disttype(const char *);
extern ConcatString disttype_to_string(DistType);
Expand Down
Loading

0 comments on commit 0e658a4

Please sign in to comment.