[Met_help] [rt.rap.ucar.edu #79656] History for Complex masking region in Grid-Stat

John Halley Gotway via RT met_help at ucar.edu
Tue Feb 28 16:01:08 MST 2017

  Initial Request

I have a question about "mask" feature in grid_stat.
I can specify the mask feature in config file, such as

mask = {
   grid = [ "FULL" ];
   poly = [ "${CURFILE} {name = \"age_cldfra\"; level = \"(0,*,*)\" ;} > 9.9" ];

Can I apply more than one conditional with &&  ?  such as
   poly = [ "${CURFILE} {name = \"age_cldfra\"; level = \"(0,*,*)\" ;} > 9.9 && {name = \"Satcorp\"; level = \"(0,*,*)\" ;} >= 0.0" ];

Or do I need to use "Gen-Vx-Mask tool" for this purpose?

Thank you,


  Complete Ticket History

Subject: Complex masking region in Grid-Stat
From: John Halley Gotway
Time: Mon Feb 27 13:23:38 2017


Unfortunately no, the Grid-Stat configuration file doesn't support
logic for defining intersections and unions of multiple fields to
define masks.

However, there is a way to accomplish this through additional steps.
Prior to running Grid-Stat, you can run the Gen-Poly-Mask tool one or
more times to define a more complex masking area by thresholding
multiple fields.  The syntax of doing so gets a little tricky.

Here's an example.  Let's say you have a forecast GRIB file (fcst.grb)
which contains 2 records... one for 2-m temperature and a second for
6-hr accumulated precip.  We only want grid points that are below
freezing with non-zero precip.  We'll run gen_vx_mask twice... once to
define the temperature mask and a second time to intersect that with
the precip mask:

gen_vx_mask fcst.grb fcst.grb tmp_mask.nc \
   -type data \
   -mask_field 'name="TMP"; level="Z2"' -thresh le273

gen_vx_mask tmp_mask.nc fcst.grb tmp_and_precip_mask.nc \
   -type data \
   -input_field 'name="TMP_Z2"; level="(*,*)";' \
   -mask_field 'name="APCP"; level="A6";' -thresh gt0 \
   -intersection -name "FREEZING_PRECIP"

The first one is pretty straight-forward.
  (1) The input field (fcst.grb) defines the domain for the mask.
  (2) Since we're doing data masking and the data we want lives in
fcst.grb, we pass it in again as the mask_file.
  (3) Lastly "-mask_field" specifies the data we want from the mask
file and "-thresh" specifies the event threshold.

The second call is the tricky one... it says...
  (1) Do data masking (-data)
  (2) Read the NetCDF variable named "TMP_Z2" from the input file
  (3) Define the mask by reading 6-hour precip from the mask file
(fcst.grb) and looking for values > 0
  (4) Apply intersection logic when combining the "input" value with
the "mask" value
  (5) Name the output NetCDF variable as "FREEZING_PRECIP".  This is
totally optional, but convenient.

So you'd need to script up multiple calls to gen_vx_mask to apply your
complex masking logic... and then pass the output mask file to Grid-
Stat in its configuration file.

Hope that helps.

John Halley Gotway


More information about the Met_help mailing list