Skip to content

Commit

Permalink
Per issue #1792, Change -type from optional to required. Set default_…
Browse files Browse the repository at this point in the history
…mask_type to MaskType_None. Added a check on mask_type to see if it's set and print error message accordingly.
  • Loading branch information
Seth Linden committed Jun 3, 2021
1 parent b6bb5e7 commit 9dfbcb9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
22 changes: 17 additions & 5 deletions met/src/tools/other/gen_vx_mask/gen_vx_mask.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
// 006 07/09/18 Bullock Add shapefile masking type.
// 007 04/08/19 Halley Gotway Add percentile thresholds.
// 008 04/06/20 Halley Gotway Generalize input_grid option.
// 009 06/01/21 Seth Linden Change -type from optional to required
//
////////////////////////////////////////////////////////////////////////

Expand Down Expand Up @@ -138,6 +139,17 @@ void process_command_line(int argc, char **argv) {
mask_filename = cline[1];
out_filename = cline[2];

// Check for the mask type (from -type string)
if(mask_type == MaskType_None) {
mlog << Error << "\n" << program_name << " -> "
<< "the -type command line requirement must be set to a specific masking type!\n"
<< "\t\t \"poly\", \"box\", \"circle\", \"track\", \"grid\", "
<< "\"data\", \"solar_alt\", \"solar_azi\", \"lat\", \"lon\" "
<< "or \"shape\""
<< "\n\n";
exit(1);
}

// List the input files
mlog << Debug(1)
<< "Input Grid:\t\t" << input_gridname << "\n"
Expand Down Expand Up @@ -1340,7 +1352,7 @@ void usage() {
<< "\tinput_grid\n"
<< "\tmask_file\n"
<< "\tout_file\n"
<< "\t[-type string]\n"
<< "\t-type string\n"
<< "\t[-input_field string]\n"
<< "\t[-mask_field string]\n"
<< "\t[-complement]\n"
Expand Down Expand Up @@ -1380,12 +1392,12 @@ void usage() {
<< "\t\t\"out_file\" is the output NetCDF mask file to be "
<< "written (required).\n"

<< "\t\t\"-type string\" overrides the default masking type ("
<< masktype_to_string(default_mask_type) << ") (optional)\n"
<< "\t\t\"-type string\" specify the masking type "
<< "(required).\n"
<< "\t\t \"poly\", \"box\", \"circle\", \"track\", \"grid\", "
<< "\"data\", \"solar_alt\", \"solar_azi\", \"lat\", \"lon\" "
<< "or \"shape\"\n"

<< "\t\t\"-input_field string\" reads existing mask data from "
<< "the \"input_grid\" gridded data file (optional).\n"

Expand Down Expand Up @@ -1446,7 +1458,7 @@ void usage() {
void set_type(const StringArray & a) {
if(type_is_set) {
mlog << Error << "\n" << program_name << " -> "
<< "the -type command line option can only be used once!\n"
<< "the -type command line requirment can only be used once!\n"
<< "To apply multiple masks, run this tool multiple times "
<< "using the output of one run as the input to the next."
<< "\n\n";
Expand Down
7 changes: 4 additions & 3 deletions met/src/tools/other/gen_vx_mask/gen_vx_mask.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
// 000 12/09/14 Halley Gotway New
// 001 06/02/16 Halley Gotway Add box masking type.
// 002 11/15/16 Halley Gotway Add solar masking types.
// 003 06/03/21 Seth Linden Changed default mask type to MaskType_None
//
////////////////////////////////////////////////////////////////////////

Expand Down Expand Up @@ -75,7 +76,7 @@ extern const char * masktype_to_string(MaskType);
//
////////////////////////////////////////////////////////////////////////

static const MaskType default_mask_type = MaskType_Poly;
static const MaskType default_mask_type = MaskType_None;
static const double default_mask_val = 1.0;

////////////////////////////////////////////////////////////////////////
Expand All @@ -86,10 +87,10 @@ static const double default_mask_val = 1.0;

// Input data file, mask file, and output NetCDF file
static ConcatString input_gridname, mask_filename, out_filename;

// Optional arguments
static MaskType mask_type = default_mask_type;
static bool type_is_set = false;

// Optional arguments
static ConcatString input_field_str, mask_field_str;
static SetLogic set_logic = SetLogic_None;
static bool complement = false;
Expand Down

0 comments on commit 9dfbcb9

Please sign in to comment.