Excerpt |
---|
|
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
Code Block |
---|
|
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
Content by Label |
---|
showLabels | false |
---|
max | 5 |
---|
spaces | ~usa |
---|
showSpace | false |
---|
sort | modified |
---|
reverse | true |
---|
type | page |
---|
cql | label = "metview-faqs" and label = "computation" and type = "page" and space = "UDOC" |
---|
labels | kb-how-to-article |
---|
|