Skip to content

Commit

Permalink
Per #1918, rename normalize_flag to just normalize to make its name m…
Browse files Browse the repository at this point in the history
…ore similar to the convert and censor_thresh/censor_val options.
  • Loading branch information
JohnHalleyGotway committed Feb 19, 2022
1 parent 132276e commit 58cbb8f
Show file tree
Hide file tree
Showing 13 changed files with 66 additions and 65 deletions.
1 change: 1 addition & 0 deletions met/data/config/ConfigConstants
Original file line number Diff line number Diff line change
Expand Up @@ -176,3 +176,4 @@ CLIMO_ANOM = 2;
CLIMO_STD_ANOM = 3;
FCST_ANOM = 4;
FCST_STD_ANOM = 5;

10 changes: 5 additions & 5 deletions met/data/config/GenEnsProdConfig_default
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ regrid = {
//
// May be set separately in each "field" entry
//
censor_thresh = [];
censor_val = [];
cat_thresh = [];
nc_var_str = "";
normalize_flag = NONE;
censor_thresh = [];
censor_val = [];
normalize = NONE;
cat_thresh = [];
nc_var_str = "";

//
// Ensemble fields to be processed
Expand Down
10 changes: 5 additions & 5 deletions met/docs/Users_Guide/gen-ens-prod.rst
Original file line number Diff line number Diff line change
Expand Up @@ -181,21 +181,21 @@ _____________________

.. code-block:: none
normalize_flag = NONE;
normalize = NONE;
The **normalize_flag** option defines if and how the input ensemble member data should be normalized. Options are provided to normalize relative to an external climatology, specified using the **climo_mean** and **climo_stdev** dictionaries, or relative to current ensemble data being processed. The anomaly is computed by subtracting the (climatological or ensemble) mean from each ensemble memeber. The standard anomaly is computed by also dividing the anomaly by the (climatological or ensemble) standard deviation. Values for the **normalize_flag** option are described below:
The **normalize** option defines if and how the input ensemble member data should be normalized. Options are provided to normalize relative to an external climatology, specified using the **climo_mean** and **climo_stdev** dictionaries, or relative to current ensemble forecast being processed. The anomaly is computed by subtracting the (climatological or ensemble) mean from each ensemble memeber. The standard anomaly is computed by dividing the anomaly by the (climatological or ensemble) standard deviation. Values for the **normalize** option are described below:

• **NONE** (default) to skip the normalization step and process the raw ensemble member data.

• **CLIMO_ANOM** to subtract the climatological mean field.

• **CLIMO_STD_ANOM** to subtract the climatological mean field and divide by the climatological standard deviation.

• **FCST_ANOM** to subtract the ensemble mean field.
• **FCST_ANOM** to subtract the current ensemble mean field.

• **FCST_STD_ANOM** to subtract the ensemble mean field and divide by the ensemble standard deviation.
• **FCST_STD_ANOM** to subtract the current ensemble mean field and divide by the current ensemble standard deviation.

Note that the **normalize_flag** option may be specified separately for each entry in the **ens.field** array.
Note that the **normalize** option may be specified separately for each entry in the **ens.field** array.

_______________________

Expand Down
2 changes: 1 addition & 1 deletion met/src/basic/vx_config/config_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -770,7 +770,7 @@ 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";
static const char conf_key_normalize[] = "normalize";

// Distribution options
static const char conf_val_normal[] = "NORMAL";
Expand Down
10 changes: 5 additions & 5 deletions met/src/basic/vx_config/config_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3023,18 +3023,18 @@ StringArray parse_conf_ens_member_ids(Dictionary *dict) {

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

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

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

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

// Convert integer to enumerated WaveletType
if(v == conf_const.lookup_int(conf_val_none)) t = NormalizeType_None;
Expand All @@ -3043,9 +3043,9 @@ NormalizeType parse_conf_normalize_flag(Dictionary *dict) {
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() -> "
mlog << Error << "\nparse_conf_normalize() -> "
<< "Unexpected config file value of " << v << " for \""
<< conf_key_normalize_flag << "\".\n\n";
<< conf_key_normalize << "\".\n\n";
exit(1);
}

Expand Down
2 changes: 1 addition & 1 deletion met/src/basic/vx_config/config_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +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 NormalizeType parse_conf_normalize(Dictionary *dict);

extern void check_mask_names(const StringArray &);

Expand Down
38 changes: 19 additions & 19 deletions met/src/tools/other/gen_ens_prod/gen_ens_prod.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
// 000 09/10/21 Halley Gotway MET #1904 Initial version.
// 001 11/15/21 Halley Gotway MET #1968 Ensemble -ctrl error check.
// 002 01/14/21 McCabe MET #1695 All members in one file.
// 003 02/17/22 Halley Gotway MET #1918 Add normalize_flag.
// 003 02/17/22 Halley Gotway MET #1918 Add normalize config option.
//
////////////////////////////////////////////////////////////////////////

Expand Down Expand Up @@ -292,9 +292,9 @@ void process_ensemble() {

// Print out the normalization flag
cs << cs_erase;
if((*var_it)->normalize_flag != NormalizeType_None) {
cs << " with normalize_flag = "
<< normalizetype_to_string((*var_it)->normalize_flag);
if((*var_it)->normalize != NormalizeType_None) {
cs << " with normalize = "
<< normalizetype_to_string((*var_it)->normalize);
}
cs << "\n";

Expand Down Expand Up @@ -347,8 +347,8 @@ void process_ensemble() {
i_var, ens_valid_ut, grid);

// Compute the ensemble summary data, if needed
if((*var_it)->normalize_flag == NormalizeType_FcstAnom ||
(*var_it)->normalize_flag == NormalizeType_FcstStdAnom ) {
if((*var_it)->normalize == NormalizeType_FcstAnom ||
(*var_it)->normalize == NormalizeType_FcstStdAnom ) {
get_ens_mean_stdev((*var_it), emn_dp, esd_dp);
}
else {
Expand All @@ -375,8 +375,8 @@ void process_ensemble() {
}

// Normalize, if requested
if((*var_it)->normalize_flag != NormalizeType_None) {
normalize_data(ctrl_dp, (*var_it)->normalize_flag,
if((*var_it)->normalize != NormalizeType_None) {
normalize_data(ctrl_dp, (*var_it)->normalize,
cmn_dp, csd_dp, emn_dp, esd_dp);
}

Expand All @@ -395,8 +395,8 @@ void process_ensemble() {
} // end if need_reset

// Normalize, if requested
if((*var_it)->normalize_flag != NormalizeType_None) {
normalize_data(ens_dp, (*var_it)->normalize_flag,
if((*var_it)->normalize != NormalizeType_None) {
normalize_data(ens_dp, (*var_it)->normalize,
cmn_dp, csd_dp, emn_dp, esd_dp);
}

Expand Down Expand Up @@ -627,7 +627,7 @@ static void normalize_data(DataPlane &dp, NormalizeType t,
dp.nxy() != cmn_dp.nxy()) {
mlog << Error << "\nnormalize_data()-> "
<< "the climatology mean field is required when "
<< conf_key_normalize_flag << " = "
<< conf_key_normalize << " = "
<< normalizetype_to_string(t) << ".\n\n";
exit(1);
}
Expand All @@ -637,7 +637,7 @@ static void normalize_data(DataPlane &dp, NormalizeType t,
dp.nxy() != csd_dp.nxy()) {
mlog << Error << "\nnormalize_data()-> "
<< "the climatology standard deviation field is required when "
<< conf_key_normalize_flag << " = "
<< conf_key_normalize << " = "
<< normalizetype_to_string(t) << ".\n\n";
exit(1);
}
Expand Down Expand Up @@ -1075,10 +1075,10 @@ void write_ens_var_float(GenEnsProdVarInfo *ens_info, float *ens_data, const Dat
ConcatString ens_var_name, var_str, name_str, cs;

// Append the normalization info, if used
if(ens_info->normalize_flag != NormalizeType_None &&
if(ens_info->normalize != NormalizeType_None &&
strcmp(type_str, "CLIMO_MEAN") != 0 &&
strcmp(type_str, "CLIMO_STDEV") != 0) {
var_str << "_" << normalizetype_to_string(ens_info->normalize_flag);
var_str << "_" << normalizetype_to_string(ens_info->normalize);
}

// Append nc_var_str config file entry
Expand Down Expand Up @@ -1138,8 +1138,8 @@ void write_ens_var_int(GenEnsProdVarInfo *ens_info, int *ens_data, const DataPla
ConcatString ens_var_name, var_str, name_str, cs;

// Append the normalization info, if used
if(ens_info->normalize_flag != NormalizeType_None) {
var_str << "_" << normalizetype_to_string(ens_info->normalize_flag);
if(ens_info->normalize != NormalizeType_None) {
var_str << "_" << normalizetype_to_string(ens_info->normalize);
}

// Append nc_var_str config file entry
Expand Down Expand Up @@ -1226,9 +1226,9 @@ void add_var_att_local(GenEnsProdVarInfo *ens_info,
if(is_int) add_att(nc_var, "_FillValue", bad_data_int);
else add_att(nc_var, "_FillValue", bad_data_float);

if(ens_info->normalize_flag != NormalizeType_None) {
add_att(nc_var, "normalize_flag",
(string)normalizetype_to_string(ens_info->normalize_flag));
if(ens_info->normalize != NormalizeType_None) {
add_att(nc_var, "normalize",
(string)normalizetype_to_string(ens_info->normalize));
}

// Write out times
Expand Down
4 changes: 2 additions & 2 deletions met/src/tools/other/gen_ens_prod/gen_ens_prod_conf_info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,8 @@ void GenEnsProdConfInfo::process_config(GrdFileType etype, StringArray * ens_fil
// Keep track of the maximum number of thresholds
if(ens_info->cat_ta.n() > max_n_cat) max_n_cat = ens_info->cat_ta.n();

// Conf: normalize_flag
ens_info->normalize_flag = parse_conf_normalize_flag(&i_edict);
// Conf: normalize
ens_info->normalize = parse_conf_normalize(&i_edict);

// Conf: ensemble_flag
ens_info->nc_info = parse_nc_info(&i_edict);
Expand Down
4 changes: 2 additions & 2 deletions met/src/tools/other/gen_ens_prod/gen_ens_prod_conf_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ inline int GenEnsProdConfInfo::get_compression_level() { return(conf.nc_compress
class GenEnsProdVarInfo: public EnsVarInfo {

public:
NormalizeType normalize_flag; // Ensemble normalization logic
GenEnsProdNcOutInfo nc_info; // Ensemble product outputs
NormalizeType normalize; // Ensemble normalization logic
GenEnsProdNcOutInfo nc_info; // Ensemble product outputs
};

#endif /* __GEN_ENS_PROD_CONF_INFO_H__ */
Expand Down
10 changes: 5 additions & 5 deletions test/config/GenEnsProdConfig
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ regrid = {
//
// May be set separately in each "field" entry
//
censor_thresh = [];
censor_val = [];
cat_thresh = [];
nc_var_str = "";
normalize_flag = NONE;
censor_thresh = [];
censor_val = [];
normalize = NONE;
cat_thresh = [];
nc_var_str = "";

//
// Ensemble fields to be processed
Expand Down
20 changes: 10 additions & 10 deletions test/config/GenEnsProdConfig_normalize_flag
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ regrid = {
//
// May be set separately in each "field" entry
//
censor_thresh = [];
censor_val = [];
cat_thresh = [];
nc_var_str = "";
normalize_flag = NONE;
censor_thresh = [];
censor_val = [];
normalize = NONE;
cat_thresh = [];
nc_var_str = "";

//
// Ensemble fields to be processed
Expand All @@ -53,11 +53,11 @@ ens = {
level = "Z2";

field = [
{ normalize_flag = NONE; },
{ normalize_flag = CLIMO_ANOM; },
{ normalize_flag = CLIMO_STD_ANOM; },
{ normalize_flag = FCST_ANOM; },
{ normalize_flag = FCST_STD_ANOM; }
{ normalize = NONE; },
{ normalize = CLIMO_ANOM; nc_var_str = "CLIMO_ANOM"; },
{ normalize = CLIMO_STD_ANOM; nc_var_str = "CLIMO_STD_ANOM"; },
{ normalize = FCST_ANOM; nc_var_str = "FCST_ANOM"; },
{ normalize = FCST_STD_ANOM; nc_var_str = "FCST_STD_ANOM"; }
];
}

Expand Down
10 changes: 5 additions & 5 deletions test/config/GenEnsProdConfig_single_file_grib
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ regrid = {
//
// May be set separately in each "field" entry
//
censor_thresh = [];
censor_val = [];
cat_thresh = [];
nc_var_str = "";
normalize_flag = NONE;
censor_thresh = [];
censor_val = [];
normalize = NONE;
cat_thresh = [];
nc_var_str = "";

//
// Ensemble fields to be processed
Expand Down
10 changes: 5 additions & 5 deletions test/config/GenEnsProdConfig_single_file_nc
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ regrid = {
//
// May be set separately in each "field" entry
//
censor_thresh = [];
censor_val = [];
cat_thresh = [];
nc_var_str = "";
normalize_flag = NONE;
censor_thresh = [];
censor_val = [];
normalize = NONE;
cat_thresh = [];
nc_var_str = "";

//
// Ensemble fields to be processed
Expand Down

0 comments on commit 58cbb8f

Please sign in to comment.