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

Bugfix 1716 main_v9.1 perc_thresh #1721

Merged
merged 2 commits into from
Mar 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion met/data/config/README
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ The configuration file language supports the following data types:
- In the Gen-Vx-Mask "-thresh" command line option.
- The following percentile threshold types are supported:
- "SFP" for a percentile of the sample forecast values.
e.g. ">SFP50" means greater than the 50-th forecast percentile.
e.g. ">SFP33.3" means greater than the 33.3-rd forecast percentile.
- "SOP" for a percentile of the sample observation values.
e.g. ">SOP75" means greater than the 75-th observation percentile.
- "SCP" for a percentile of the sample climatology values.
Expand Down
78 changes: 40 additions & 38 deletions met/src/basic/vx_config/my_config_scanner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ static bool replace_env(ConcatString &);

static bool is_fort_thresh_no_spaces();

static bool is_simple_perc_thresh();

static int do_simple_perc_thresh();


Expand Down Expand Up @@ -370,6 +372,8 @@ if ( is_float_v2() ) { if ( do_float() ) return ( token(FLOAT) ); }

if ( is_fort_thresh_no_spaces() ) { return ( do_fort_thresh() ); }

if ( is_simple_perc_thresh() ) { return ( do_simple_perc_thresh() ); }

int t;

if ( is_id() ) { t = do_id(); return ( token(t) ); }
Expand Down Expand Up @@ -533,7 +537,6 @@ if ( is_lhs ) { strncpy(configlval.text, configtext, max_id_length); return (

if ( strcmp(configtext, "print" ) == 0 ) { return ( PRINT ); }


//
// boolean?
//
Expand All @@ -554,17 +557,13 @@ for (j=0; j<n_fort_thresh_strings; ++j) {

}





//
// builtin ?
//

int index;

if ( (! is_lhs) && is_builtin((string)configtext, index) ) { configlval.index = index; return ( BUILTIN ); }
if ( (! is_lhs) && is_builtin((string)configtext, index) ) { configlval.index = index; return ( BUILTIN ); }

//
// local variable ? // ie, in argument list
Expand All @@ -580,11 +579,6 @@ const DictionaryEntry * e = dict_stack->lookup(configtext);

if ( e && (e->is_number()) && (! is_lhs) ) {

// cout << "=================== id = \"" << configtext << "\" is_lhs = " << (is_lhs ? "true" : "false") << "\n";

// cout << "do_id() -> \n";
// e->dump(cout);

if ( e->type() == IntegerType ) {

set_int(configlval.nval, e->i_value());
Expand Down Expand Up @@ -613,28 +607,20 @@ if ( e && (! is_lhs) && (e->type() == UserFunctionType) ) {

}


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





//
// fortran threshold without spaces? (example: "le150")
//

if ( (strncmp(configtext, "lt", 2) == 0) && is_number(configtext + 2, max_id_length - 2) ) { return ( do_fort_thresh() ); }

for (j=0; j<n_fort_thresh_strings; ++j) {

if ( (strncmp(configtext, fort_thresh_string[j], 2) == 0)
&& (is_number(configtext + 2, max_id_length - 2))
) { configlval.cval = thresh_lt; return ( do_fort_thresh() ); }
&& (is_number(configtext + 2, max_id_length - 2)) )
{ configlval.cval = thresh_lt; return ( do_fort_thresh() ); }

}


//
// simple percentile threshold? (example: "SOP50")
//
Expand All @@ -649,11 +635,8 @@ for (j=0; j<n_perc_thresh_infos; ++j) {

}



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


//
// nope
//
Expand Down Expand Up @@ -863,7 +846,6 @@ while ( 1 ) {

c1 = c2;

// c2 = nextchar();
c2 = fgetc(configin);

}
Expand Down Expand Up @@ -891,7 +873,6 @@ while ( 1 ) {

if ( feof (configin) ) break;

// c = nextchar();
c = fgetc(configin);

if ( (c == eof) || (c == '\n') ) break;
Expand Down Expand Up @@ -1435,7 +1416,38 @@ int j;

for (j=0; j<n_fort_thresh_strings; ++j) {

if ( (strncmp(configtext, fort_thresh_string[j], 2) == 0) && (is_number(configtext + 2, max_id_length - 2)) ) return ( true );
if ( (strncmp(configtext, fort_thresh_string[j], 2) == 0)
&& (is_number(configtext + 2, max_id_length - 2)) )
{ return ( true ); }

}


return ( false );

}


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


bool is_simple_perc_thresh()

{

int j, k;

//
// simple percentile threshold? (example: "SOP50.0")
//

for (j=0; j<n_perc_thresh_infos; ++j) {

k = perc_thresh_info[j].short_name_length;

if ( (strncmp(configtext, perc_thresh_info[j].short_name, k) == 0)
&& (is_number(configtext + k, max_id_length - k)) )
{ return ( do_simple_perc_thresh() ); }

}

Expand Down Expand Up @@ -1472,7 +1484,6 @@ for (j=0; j<n_perc_thresh_infos; ++j) {

}


if ( index < 0 ) {

mlog << Error << "\ndo_simple_perc_thresh() -> "
Expand All @@ -1482,11 +1493,8 @@ if ( index < 0 ) {

}


configlval.pc_info.perc_index = index;
// configlval.pc_info.is_simple = true;
configlval.pc_info.value = value;
// configlval.pc_info.value2 = bad_data_double;;
configlval.pc_info.value = value;


return ( SIMPLE_PERC_THRESH );
Expand All @@ -1495,9 +1503,3 @@ return ( SIMPLE_PERC_THRESH );


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