54 bit_mask_value, mask_threshold_dict={},
55 mask_map=[], no_good_pixels_mask=None,
56 calc_error_from_input_variance=True,
57 compute_n_image=False):
67 for bit
in mask_threshold_dict:
76 if calc_error_from_input_variance:
85 self.
or_mask = np.zeros(shape, dtype=np.int64)
93 self.
n_image = np.zeros(shape, dtype=np.int32)
96 """Add a masked image to the stack.
100 masked_image : `lsst.afw.image.MaskedImage`
101 Masked image to add to the stack.
102 weight : `float` or `np.ndarray`, optional
103 Weight to apply for weighted mean. If an array,
104 must be same size and shape as input masked_image.
106 good_pixels = np.where(((masked_image.mask.array & self.
bit_mask_value) == 0)
107 & np.isfinite(masked_image.mask.array))
110 self.
sum_wdata[good_pixels] += weight*masked_image.image.array[good_pixels]
116 self.
sum_w2var[good_pixels] += (weight**2.)*masked_image.variance.array[good_pixels]
119 self.
sum_wdata2[good_pixels] += weight*(masked_image.image.array[good_pixels]**2.)
122 self.
or_mask[good_pixels] |= masked_image.mask.array[good_pixels]
126 bad_pixels = ((masked_image.mask.array & 2**bit) > 0)
131 """Fill the stacked mask image after accumulation.
135 stacked_masked_image : `lsst.afw.image.MaskedImage`
138 with warnings.catch_warnings():
140 warnings.simplefilter(
"ignore")
156 stacked_masked_image.variance.array[:, :] = mean_var
163 self.
or_mask[propagate] |= 2**bit
170 stacked_masked_image.mask.array[:, :] = self.
or_mask
173 mask_dict = stacked_masked_image.mask.getMaskPlaneDict()
174 no_good_pixels_mask = 2**(mask_dict[
'NO_DATA'])
179 stacked_masked_image.mask.array[bad_pixels] |= no_good_pixels_mask