====== Boolean Masks ======
Boolean masks are often used to 'filter' the values of arrays, based on some logical criteria (e.g. negative or positive values). Using a mask is a two-step process:
- Creation of the mask using boolean operator(s) (e.g. greater than, less than or equal to)
- Application of the mask to some array to be filtered, simply by multiplication.
==== Example ====
Starting with this TOOL object ''newDwellings[dt,t]''
{{:recipies:examplebooleanmask1.png|}}
the mask is created with this code
maskPositive[dt,t] = boolge (newDwellings[dt,t], 0)
{{:recipies:examplebooleanmask3.png|}}
and applied
newDwellingsPos[dt,t] = newDwellings[dt,t] * maskPositive[dt,t]
to produce
{{:recipies:examplebooleanmask2.png|}}
Note that the mask can be easily inverted by subtracting it from one
maskNegative[dt,t] = 1 - maskPositive[dt,t]
{{:recipies:examplebooleanmask4.png|}}
----
\\
{{:recipies:examplebooleanmask.t|}} is the self-contained TOOL script for this example.