You can do this by using boolean arithmetic plus theĀ bitmap() function to mask out the negative values. For example

Step-by-step guide

You can do this by using boolean arithmetic plus theĀ bitmap() function to mask out the negative values. For example


g = read("my_data.grib")
negs_mask = bitmap(g < 0, 1)
g = bitmap(g, negs_mask)

On the second line, the boolean expression 'g < 0' returns a fieldset with values of 1 where the input values are less than zero (i.e. they pass the test), and values of 0 everywhere else. This 0/1-fieldset result is passed as the first argument to the bitmap() function, and 1 is the second argument. This will return a mask fieldset based on the computed 0/1-fieldset input, but with all values of 1 replaced with missing value indicators. The third line then applies the pattern of missing values to the original input fieldset; all grid points where the mask is not missing are preserved as they are.

Related articles

Related articles appear here based on the labels you select. Click to edit the macro and add or change labels.