127 def run(self, hpx_container: Iterable[tuple[DeferredDatasetHandle, int]]) -> Struct:
128 """Produce Hips images with hips order 8 inputs to the configured min_order.
132 hpx_container : `Iterable` of `tuple` of `DeferredDatasetHanle`, `int`
133 This is an iterable of handles to already down-sampled hpx order 8
134 arrays and their corresponding order 8 pixel id.
139 This tasks does not produce an output, so will return an empty `Struct`
147 for order
in range(7, self.config.min_order - 1, -1):
148 self.log.info(
"Processing order %d", order)
154 hpx_next_container = []
156 size_thresh = len(hpx_next_mapping) // 10
159 for hpx_next_id, hpx_next_items
in hpx_next_mapping.items():
162 if size_counter > size_thresh:
163 percent_counter += 10
164 self.log.info(
"Done %d percent", percent_counter)
167 hpx_next_array = np.zeros((npix, npix, 3), dtype=np.float32)
168 for img_prev, hpx_prev_id
in hpx_next_items:
171 img_prev: NDArray = img_prev.get()
174 sub_index = hpx_prev_id - np.left_shift(hpx_next_id, 2)
177 hpx_next_array[0 : npix // 2 :, 0 : npix // 2] = img_prev
179 hpx_next_array[npix // 2 :, 0 : npix // 2] = img_prev
181 hpx_next_array[0 : npix // 2, npix // 2 :] = img_prev
183 hpx_next_array[npix // 2 :, npix // 2 :] = img_prev
190 self.config.file_extension,
191 self.config.array_type,
196 zoomed = cv2.resize(hpx_next_array, (256, 256), interpolation=cv2.INTER_LANCZOS4)
198 hpx_next_container.append((zoomed, hpx_next_id))
199 hpx_container = hpx_next_container
204 hpx_container: Iterable[tuple[NDArray | DeferredDatasetHandle, int]],
205 ) -> dict[int, Iterable[tuple[NDArray | DeferredDatasetHandle, int]]]:
206 """Sort a list of [images (or handels), hpx_id] into corresponding pixels at a higher order."""
207 hpx_output_mapping = {}
208 for pair
in hpx_container:
209 hpx_output_id = np.right_shift(pair[1], 2)
210 hpx_output_container = hpx_output_mapping.setdefault(hpx_output_id, [])
211 hpx_output_container.append(pair)
212 return hpx_output_mapping
216 butlerQC: QuantumContext,
217 inputRefs: InputQuantizedConnection,
218 outputRefs: OutputQuantizedConnection,
222 for ref
in inputRefs.input_hips:
223 hpx_container.append((butlerQC.get(ref), ref.dataId[
"healpix8"]))
225 outputs = self.
run(hpx_container)
226 butlerQC.put(outputs, outputRefs)