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 1792 gen_vx_mask #1816

Merged
merged 7 commits into from
Jun 4, 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
8 changes: 4 additions & 4 deletions met/docs/Users_Guide/masking.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ The usage statement for the Gen-Vx-Mask tool is shown below:
input_grid
mask_file
out_file
[-type str]
-type str
[-input_field string]
[-mask_field string]
[-complement]
Expand All @@ -36,7 +36,7 @@ The usage statement for the Gen-Vx-Mask tool is shown below:
[-v level]
[-compress level]

gen_vx_mask has three required arguments and can take optional ones.
gen_vx_mask has four required arguments and can take optional ones. Note, -type string (masking type) was previously optional but is now required.

Required arguments for gen_vx_mask
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -57,11 +57,11 @@ Required arguments for gen_vx_mask

3. The **out_file** argument is the output NetCDF mask file to be written.

4. The **-type string** is required to set the masking type. The application will give an error message and exit if "-type string" is not specified on the command line. See description of supported types below.

Optional arguments for gen_vx_mask
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

4. The **-type string** option can be used to override the default masking type (poly). See description of supported types below.

5. The **-input_field string** option can be used to read existing mask data from “input_file”.

6. The **-mask_field string** option can be used to define the field from “mask_file” to be used for “data” masking.
Expand Down
3 changes: 2 additions & 1 deletion met/scripts/examples/test_gen_vx_mask.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ echo "*** Running Gen-Vx-Mask to generate a polyline mask file for the Continent
gen_vx_mask \
../data/sample_fcst/2005080700/wrfprs_ruc13_24.tm00_G212 \
$MET_BASE/poly/CONUS.poly \
${TEST_OUT_DIR}/gen_vx_mask/CONUS_poly.nc -v 2
${TEST_OUT_DIR}/gen_vx_mask/CONUS_poly.nc \
-type poly -v 2

echo
echo "*** Running Gen-Vx-Mask to generate a circle mask file ***"
Expand Down
2 changes: 1 addition & 1 deletion met/scripts/mk/gen_vx_mask.mk
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ gen_vx_mask: ${GEN_VX_MASK_EXEC}
${GEN_VX_MASK_EXEC} \
../data/sample_fcst/2005080700/wrfprs_ruc13_24.tm00_G212 \
../data/poly/CONUS.poly \
${TEST_OUT_DIR}/gen_vx_mask/CONUS_poly.nc -v 2
${TEST_OUT_DIR}/gen_vx_mask/CONUS_poly.nc -type poly -v 2
@
echo
echo "*** Running Gen-Vx-Mask to generate a circle mask file ***"
Expand Down
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 requirement 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
10 changes: 5 additions & 5 deletions test/xml/unit_gen_vx_mask.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
&DATA_DIR_MODEL;/grib1/gfs/gfs_2012040900_F012.grib \
&MET_BASE;/poly/CONUS.poly \
&OUTPUT_DIR;/gen_vx_mask/POLY_GFS_LATLON_CONUS_mask.nc \
-v 1
-type poly -v 1
</param>
<output>
<grid_nc>&OUTPUT_DIR;/gen_vx_mask/POLY_GFS_LATLON_CONUS_mask.nc</grid_nc>
Expand All @@ -48,7 +48,7 @@
&DATA_DIR_MODEL;/grib1/gfs/gfs_2012040900_F012_g008.grib \
&MET_BASE;/poly/CONUS.poly \
&OUTPUT_DIR;/gen_vx_mask/POLY_GFS_MERCATOR_CONUS_mask.nc \
-v 1
-type poly -v 1
</param>
<output>
<grid_nc>&OUTPUT_DIR;/gen_vx_mask/POLY_GFS_MERCATOR_CONUS_mask.nc</grid_nc>
Expand All @@ -65,7 +65,7 @@
&DATA_DIR_MODEL;/grib1/nam/nam_2012040900_F012.grib \
&MET_BASE;/poly/CONUS.poly \
&OUTPUT_DIR;/gen_vx_mask/POLY_NAM_LAMBERT_CONUS_mask.nc \
-v 1
-type poly -v 1
</param>
<output>
<grid_nc>&OUTPUT_DIR;/gen_vx_mask/POLY_NAM_LAMBERT_CONUS_mask.nc</grid_nc>
Expand All @@ -82,7 +82,7 @@
&DATA_DIR_MODEL;/grib1/arw-tom-gep0/arw-tom-gep0_2012040900_F012.grib \
&MET_BASE;/poly/NWC.poly \
&OUTPUT_DIR;/gen_vx_mask/POLY_HMT_STEREO_NWC_mask.nc \
-v 1
-type poly -v 1
</param>
<output>
<grid_nc>&OUTPUT_DIR;/gen_vx_mask/POLY_HMT_STEREO_NWC_mask.nc</grid_nc>
Expand All @@ -100,7 +100,7 @@
&DATA_DIR_MODEL;/grib1/gfs/gfs_2012040900_F012.grib \
&MET_BASE;/poly/NAK.poly \
&OUTPUT_DIR;/gen_vx_mask/POLY_GFS_LATLON_NAK_mask.nc \
-v 1
-type poly -v 1
</param>
<output>
<grid_nc>&OUTPUT_DIR;/gen_vx_mask/POLY_GFS_LATLON_NAK_mask.nc</grid_nc>
Expand Down