27__all__ = [
'AccumulatorMeanStack']
31 """Stack masked images.
36 Shape of the input and output images.
37 bit_mask_value : `int`
38 Bit mask to flag
for "bad" inputs that should
not be stacked.
39 mask_threshold_dict : `dict` [`int`: `float`], optional
40 Dictionary of mapping
from bit number to threshold
for flagging.
41 Only bad bits (
in bit_mask_value) which mask fractional weight
42 greater than this threshold will be flagged
in the output image.
43 mask_map : `list` [`tuple`], optional
44 Mapping
from input image bits to aggregated coadd bits.
45 no_good_pixels_mask : `int`, optional
46 Bit mask to set when there are no good pixels
in the stack.
47 If
not set then will set coadd masked image
'NO_DATA' bit.
48 calc_error_from_input_variance : `bool`, optional
49 Calculate the error
from the input variance?
50 compute_n_image : `bool`, optional
51 Calculate the n_image map
as well
as stack?
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.
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.
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
182 """Add an image to the stack.
184 No bit-filtering is performed when adding an image.
189 Image to add to the stack.
190 weight : `float`
or `np.ndarray`, optional
191 Weight to apply
for weighted mean. If an array,
192 must be same size
and shape
as input image.
195 self.sum_wdata[:, :] += weight*image.array[:]
201 """Fill the image after accumulation.
208 with warnings.catch_warnings():
211 warnings.simplefilter(
"ignore")
218 """Convert stats control to threshold dict.
226 threshold_dict : `dict`
227 Dict mapping from bit to propagation threshold.
230 for bit
in range(64):
231 threshold_dict[bit] = stats_ctrl.getMaskPropagationThreshold(bit)
233 return threshold_dict
table::Key< std::string > object
A class to represent a 2-dimensional array of pixels.
A class to manipulate images, masks, and variance as a single object.
Pass parameters to a Statistics object.
add_masked_image(self, masked_image, weight=1.0)
fill_stacked_masked_image(self, stacked_masked_image)
calc_error_from_input_variance
stats_ctrl_to_threshold_dict(stats_ctrl)
fill_stacked_image(self, stacked_image)
__init__(self, shape, bit_mask_value, mask_threshold_dict={}, mask_map=[], no_good_pixels_mask=None, calc_error_from_input_variance=True, compute_n_image=False)
add_image(self, image, weight=1.0)