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`, optional
103 Weight to apply for weighted mean.
105 good_pixels = np.where(((masked_image.mask.array & self.
bit_mask_value) == 0)
106 & np.isfinite(masked_image.mask.array))
109 self.
sum_wdata[good_pixels] += weight*masked_image.image.array[good_pixels]
115 self.
sum_w2var[good_pixels] += (weight**2.)*masked_image.variance.array[good_pixels]
118 self.
sum_wdata2[good_pixels] += weight*(masked_image.image.array[good_pixels]**2.)
121 self.
or_mask[good_pixels] |= masked_image.mask.array[good_pixels]
125 bad_pixels = ((masked_image.mask.array & 2**bit) > 0)
130 """Fill the stacked mask image after accumulation.
134 stacked_masked_image : `lsst.afw.image.MaskedImage`
137 with warnings.catch_warnings():
139 warnings.simplefilter(
"ignore")
155 stacked_masked_image.variance.array[:, :] = mean_var
162 self.
or_mask[propagate] |= 2**bit
169 stacked_masked_image.mask.array[:, :] = self.
or_mask
172 mask_dict = stacked_masked_image.mask.getMaskPlaneDict()
173 no_good_pixels_mask = 2**(mask_dict[
'NO_DATA'])
178 stacked_masked_image.mask.array[bad_pixels] |= no_good_pixels_mask