kinextract.grow_boolean_mask

kinextract.grow_boolean_mask(mask: ndarray, grow_pix: int) ndarray[source]

Dilate a boolean mask by a fixed number of pixels on each side.

Used to extend rejection/exclusion masks (e.g. absorption-clean rejections or emission-line masks) a few pixels beyond the originally flagged pixels, so that line wings adjacent to a flagged pixel are also excluded rather than leaving a single unmasked pixel at the edge of a feature.

Parameters:
  • mask (ndarray of bool) – Input mask where True means rejected/masked/excluded.

  • grow_pix (int) – Number of pixels by which to grow the mask on each side. Values <= 0 return a copy of mask unchanged.

Returns:

Grown mask, same shape as mask; True wherever any pixel within grow_pix samples was True in the input.

Return type:

ndarray of bool