Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature 1695 ensemble single file (gen_ens_prod) #2001

Merged
merged 38 commits into from
Jan 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
06b2bfb
added make.log to git ignore file since this file is typically create…
georgemccabe Dec 28, 2021
c64f718
per #1695, added logic to replace value set in environment variable M…
georgemccabe Dec 28, 2021
02d27c0
removed include because file includes itself
georgemccabe Dec 28, 2021
f399191
per #1695, added support for reading ens_member_ids and control_id fr…
georgemccabe Dec 28, 2021
d779e0f
renamed n_ens to n_ens_files for clarity
georgemccabe Dec 29, 2021
0f81e60
read ens_member_ids and control_id from config file, pass number of e…
georgemccabe Dec 29, 2021
44370e1
clean up comments in config file
georgemccabe Dec 29, 2021
ecc6f2f
per #1695, created a structs to hold field info, file info, nc_var_st…
georgemccabe Dec 29, 2021
a2e5ac8
remove unused variable
georgemccabe Dec 29, 2021
1951290
changed return value of string_value function from ConcatString* to C…
georgemccabe Dec 29, 2021
a7e2449
output log for each field info from the same file
georgemccabe Dec 29, 2021
868e78b
added support for getting control member from single file
georgemccabe Dec 29, 2021
8071aec
added GitHub Actions workflow to build a Docker image and push it to …
georgemccabe Dec 29, 2021
4d7cadd
added variable to trigger GHA
georgemccabe Dec 29, 2021
3c94663
renamed files to be more clear of their purpose, added groups for Git…
georgemccabe Dec 30, 2021
be60222
test triggering a workflow in another repository
georgemccabe Dec 30, 2021
500bd08
fixed typo in workflow id
georgemccabe Dec 30, 2021
fe74c21
fixed formatting of workflow file
georgemccabe Dec 30, 2021
201aeda
changed automation logic to only trigger on develop branch (for now) …
georgemccabe Dec 30, 2021
de1cedf
added current path to end of new path
georgemccabe Jan 4, 2022
1a033ae
renamed EnsInfo to EnsVarInfo
georgemccabe Jan 4, 2022
f2f5a46
warn if control_id is set in conf but -ctrl not set
georgemccabe Jan 4, 2022
ef81fb0
create class to hold ensemble var info, use class functions to obsfus…
georgemccabe Jan 4, 2022
c028a16
formatting
georgemccabe Jan 4, 2022
399f28f
error if control_id is found in ens_member_ids list
georgemccabe Jan 4, 2022
4bf7a56
removed logs used for debugging
georgemccabe Jan 4, 2022
afd74c6
unset MET_ENS_MEMBER_ID before reading config because otherwise value…
georgemccabe Jan 4, 2022
a500c77
created function to handle getting raw magic string
georgemccabe Jan 4, 2022
62d38a9
removed files from this branch to add in a different pull request
georgemccabe Jan 5, 2022
246b048
added documentation for new config variables in gen_ens_prod
georgemccabe Jan 5, 2022
bc084c9
clean up formatting in docs
georgemccabe Jan 5, 2022
a43fac0
added unit tests for new GenEnsProd logic
georgemccabe Jan 5, 2022
be623ff
Merge branch 'develop' into feature_1695_ensemble_single_file
georgemccabe Jan 6, 2022
4cc6492
per #1695, added unit tests for single file gen_ens_prod runs on NetC…
georgemccabe Jan 6, 2022
d8a87b1
per #1695, updated valid check to use number of ensemble inputs (vari…
georgemccabe Jan 10, 2022
8572870
updated error message when valid threshold is not met to be more clea…
georgemccabe Jan 11, 2022
1e08c5f
Merge branch 'develop' into feature_1695_ensemble_single_file
JohnHalleyGotway Jan 12, 2022
be7164b
per PR #2001 review comment for #1695, added new default config varia…
georgemccabe Jan 12, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions met/data/config/GenEnsProdConfig_default
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,13 @@ ens = {
];
}

//
// IDs for ensemble members
// Only set if processing a single file with all ensembles
georgemccabe marked this conversation as resolved.
Show resolved Hide resolved
//
ens_member_ids = [];
control_id = "";

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

//
Expand Down
46 changes: 45 additions & 1 deletion met/docs/Users_Guide/gen-ens-prod.rst
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Required arguments gen_ens_prod
Optional arguments for gen_ens_prod
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

4. The **-ctrl file** option specifies the input file for the ensemble control member. Data for this member is included in the computation of the ensemble mean, but excluded from the spread. The control file should not appear in the **-ens** list of ensemble member files.
4. The **-ctrl file** option specifies the input file for the ensemble control member. Data for this member is included in the computation of the ensemble mean, but excluded from the spread. The control file should not appear in the **-ens** list of ensemble member files (unless processing a single file that contains all ensemble members).

5. The **-log** file outputs log messages to the specified file.

Expand Down Expand Up @@ -134,6 +134,50 @@ For each dictionary entry in the **field** array, give the name and vertical or

_______________________

.. code-block:: none
ens_member_ids = [];
control_id = "";
The **ens_member_ids** array is only used if reading a single file that contains all ensemble members.
It should contain a list of string identifiers that are substituted into the **ens** dictionary fields
to determine which data to read from the file.
The length of the array determines how many ensemble members will be processed for a given field.
Each value in the array will replace the text **MET_ENS_MEMBER_ID**.

**NetCDF Example:**

.. code-block:: none
ens = {
field = [
{
name = "fcst";
level = "(MET_ENS_MEMBER_ID,0,*,*)";
}
];
}
**GRIB Example:**

.. code-block:: none
ens = {
field = [
{
name = "fcst";
level = "L0";
GRIB_ens = "+MET_ENS_MEMBER_ID";
}
];
}
**control_id** is a string that is substituted in the same way as the **ens_member_ids** values
to read a control member. This value is only used when the **-ctrl** command line argument is
used. The value should not be found in the **ens_member_ids** array.

_______________________

.. code-block:: none
nbrhd_prob = {
Expand Down
2 changes: 2 additions & 0 deletions met/src/basic/vx_config/config_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,8 @@ static const char conf_key_eclv_points[] = "eclv_points";
static const char conf_key_var_name_map[] = "var_name_map";
static const char conf_key_metadata_map[] = "metadata_map";
static const char conf_key_missing_thresh[] = "missing_thresh";
static const char conf_key_control_id[] = "control_id";
static const char conf_key_ens_member_ids[] = "ens_member_ids";

//
// Entries to override file metadata
Expand Down
2 changes: 1 addition & 1 deletion met/src/basic/vx_config/config_file.cc
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ ConcatString MetConfig::get_tmp_dir()
// Use the MET_TMP_DIR environment variable, if set.
if(!get_env("MET_TMP_DIR", tmp_dir)) {
const DictionaryEntry * _e = lookup(conf_key_tmp_dir);
if ( LastLookupStatus ) tmp_dir = *(_e->string_value());
if ( LastLookupStatus ) tmp_dir = _e->string_value();
else tmp_dir = default_tmp_dir;
}

Expand Down
16 changes: 16 additions & 0 deletions met/src/basic/vx_config/config_util.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2965,3 +2965,19 @@ ConcatString wavelettype_to_string(WaveletType type) {
}

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

StringArray parse_conf_ens_member_ids(Dictionary *dict) {
const char *method_name = "parse_conf_ens_member_ids() -> ";

StringArray sa = parse_conf_string_array(dict, conf_key_ens_member_ids, method_name);

if(sa.n() > 0) {
mlog << Debug(4) << method_name
<< "Ensemble Member IDs \"" << conf_key_ens_member_ids << "\" list contains "
<< sa.n() << " entries.\n";
}

return(sa);
}

///////////////////////////////////////////////////////////////////////////////
1 change: 1 addition & 0 deletions met/src/basic/vx_config/config_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ extern map<ConcatString,ThreshArray>
parse_conf_filter_attr_map(Dictionary *dict);
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 void check_mask_names(const StringArray &);

Expand Down
29 changes: 19 additions & 10 deletions met/src/basic/vx_config/dictionary.cc
Original file line number Diff line number Diff line change
Expand Up @@ -762,21 +762,30 @@ return ( Bval );
////////////////////////////////////////////////////////////////////////


const ConcatString * DictionaryEntry::string_value() const
const ConcatString DictionaryEntry::string_value() const

{

if ( Type != StringType ) {
if ( Type != StringType ) {

mlog << Error
<< "\nDictionaryEntry::string_value() -> bad type\n\n";
mlog << Error
<< "\nDictionaryEntry::string_value() -> bad type\n\n";

exit ( 1 );
exit ( 1 );

}
}

ConcatString sub_text = ConcatString(*Text);
ConcatString cur_env_val;
if ( get_env(met_ens_member_id, cur_env_val) ) {

if(!cur_env_val.empty()) {
sub_text.replace(met_ens_member_id, cur_env_val.c_str(), false);
}

}

return ( Text );
return ( sub_text );

}

Expand Down Expand Up @@ -1816,7 +1825,7 @@ if ( !Entry || !is_correct_type ) {

}

return ( *(Entry->string_value()) );
return ( Entry->string_value() );

}

Expand Down Expand Up @@ -1874,7 +1883,7 @@ if ( !Entry || !is_correct_type ) {

if ( Entry->type() == StringType ) {

array.add( *(Entry->string_value()) );
array.add( Entry->string_value() );

return ( array );

Expand Down Expand Up @@ -1911,7 +1920,7 @@ if ( Dict->n_entries() > 0 ) {

for (int i=0; i<Dict->n_entries(); i++) {

array.add(*(*Dict)[i]->string_value());
array.add((*Dict)[i]->string_value());

}

Expand Down
5 changes: 4 additions & 1 deletion met/src/basic/vx_config/dictionary.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ class Dictionary; // forward reference

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

static const char met_ens_member_id [] = "MET_ENS_MEMBER_ID";

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

class DictionaryEntry {

Expand Down Expand Up @@ -122,7 +125,7 @@ class DictionaryEntry {

int n_args () const;

const ConcatString * string_value () const;
const ConcatString string_value () const;

Dictionary * dict_value () const;

Expand Down
1 change: 0 additions & 1 deletion met/src/basic/vx_log/file_fxns.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include <fcntl.h>

#include "concat_string.h"
#include "file_fxns.h"

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

Expand Down
1 change: 1 addition & 0 deletions met/src/tools/core/ensemble_stat/ensemble_stat_conf_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ class EnsembleStatVxOpt {
VxPairDataEnsemble vx_pd; // Ensemble pair data

ConcatString var_str; // nc_pairs_var_str string
ConcatString control_id; // Control ID

int beg_ds; // Begin observation time window offset
int end_ds; // End observation time window offset
Expand Down
Loading