What is the proper syntax for taking the complement of a mask of type "data" using gen_vx_mask? #1219
-
Dear MET Discussions, I am trying to take the simple complement of an existing mask (EQUATORIAL.nc" which is a mask for the equatorial regions (defined by lat >-30 and <30 in this case). So the goal is to obtain a mask which is "NOT_EQUATORIAL". I cannot find any guidance in the documentation or tutorial materials that explains how to create compound masks using -type data. The only thing I found was a simpler example for poly masks that doesn't give enough information my case. While I realize that this simple example could probably be done with gen_vx_mask using the poly method, I actually have much more complex masking regions that I'm seeking to take the complement of (which I'm not sure I can post), so this is just an example -- I want to know what the syntax to use gen_vx_mask to take the complement of a data mask. Here's my attempt: gen_vx_mask Note: I am using EQUATORIAL.nc both as the input_file and mask_file because I'm not sure what other file else to use for these when taking the complement. If I use -thresh eq1, then I just get back an entire grid of ones. If I use a thresh of 0, I think I just get back the original equatorial grid. My simple data mask example is attached. Thank you in advance, |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
Hi @jvigh. I see that you already have an existing mask and you'd like to run gen_vx_mask to take its complement. The confusion is caused by a feature that was added a while back to make it easier to run gen_vx_mask iteratively to compute complex masks. Whenever you run gen_vx_mask with INPUT_FIELD = the output of a previous run of the tool, it automatically initializes the value at each grid point to the contents of that input mask. That makes it easier to run iteratively since you no longer need to specify the "-input_field" option each time to specify the name of the NetCDF variable containing the input mask data. But this logic in turn, makes this seemingly simple task you're trying to do confusing. Let me step back and tell you how you could easily define these EQUITORIAL and NONEQIUTORIAL regions. Since I don't have your original 72x72 NetCDF input file, I'll just manually define that grid on the command line. For EQUATORIAL, let's just threshold the latitudes:
And for NONEQUITORIAL, let's just add the -complement option:
And the results are exactly what you'd expect: So in general, if you want the complement of mask A, just rerun the command you used to generate mask A and add the -complement option. Next, let's see how running gen_vx_mask iteratively is useful. For this I'll use a GFS file that contains a land/sea mask. And I'll define a mask for all nonequatorial water points:
Since we passed WATER.nc as input (and that was previously generated by gen_vx_mask), the tool initialized the value for all of the grid points to the input mask. Next, it defined the new mask for this run... the NONEQUATORIAL one which includes the use of the complement option. Note that I could easily have switched the latitude threshold instead, but wanted to show that -complement applies to the definition of the new mask. And lastly, the -intersection option defines how to combine the input mask value with the newly generated mask value. Switching -intersection to -union results in this mask: Hope these examples help clarify the functionality. |
Beta Was this translation helpful? Give feedback.
-
I think a separate utility would make the most sense. That would free the
user from the complexity of gen_vx_mask for the case when they are trying
to do something simple (but which can become quite complex if done in a
powerful tool like gen_vx_mask). It's good to also have some simple tools
for simple tasks :)
|
Beta Was this translation helpful? Give feedback.
Hi @jvigh. I see that you already have an existing mask and you'd like to run gen_vx_mask to take its complement. The confusion is caused by a feature that was added a while back to make it easier to run gen_vx_mask iteratively to compute complex masks. Whenever you run gen_vx_mask with INPUT_FIELD = the output of a previous run of the tool, it automatically initializes the value at each grid point to the contents of that input mask. That makes it easier to run iteratively since you no longer need to specify the "-input_field" option each time to specify the name of the NetCDF variable containing the input mask data.
But this logic in turn, makes this seemingly simple task you're trying t…