From 53c70d74a0f26e6727b5695267fecb3bd8b332b1 Mon Sep 17 00:00:00 2001 From: Eli Rykoff Date: Mon, 23 Oct 2023 13:21:13 -0700 Subject: [PATCH] Ensure that we skip empty maps that should not be appended. This also reorders the initialization operation to ensure that tract maps are built prior to any filtering of bad inputs. --- python/lsst/pipe/tasks/healSparseMapping.py | 35 ++++++++++++--------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/python/lsst/pipe/tasks/healSparseMapping.py b/python/lsst/pipe/tasks/healSparseMapping.py index 9144c72c5..90ac3adcb 100644 --- a/python/lsst/pipe/tasks/healSparseMapping.py +++ b/python/lsst/pipe/tasks/healSparseMapping.py @@ -546,9 +546,29 @@ def run(self, sky_map, tract, band, coadd_dict, input_map_dict, visit_summary_di patch_info = tract_info[patch] input_map = input_map_dict[patch].get() + + # Initialize the tract maps as soon as we have the first input + # map for getting nside information. + if not tract_maps_initialized: + # We use the first input map nside information to initialize + # the tract maps + nside_coverage = self._compute_nside_coverage_tract(tract_info) + nside = input_map.nside_sparse + + do_compute_approx_psf = False + # Initialize the tract maps + for property_map in self.property_maps: + property_map.initialize_tract_maps(nside_coverage, nside) + if property_map.requires_psf: + do_compute_approx_psf = True + + tract_maps_initialized = True + if input_map.valid_pixels.size == 0: self.log.warning("No valid pixels for band %s, tract %d, patch %d; skipping.", band, tract, patch) + continue + coadd_photo_calib = coadd_dict[patch].get(component="photoCalib") coadd_inputs = coadd_dict[patch].get(component="coaddInputs") @@ -568,21 +588,6 @@ def run(self, sky_map, tract, band, coadd_dict, input_map_dict, visit_summary_di patch_poly_map = patch_poly.get_map_like(input_map) input_map = hsp.and_intersection([input_map, patch_poly_map]) - if not tract_maps_initialized: - # We use the first input map nside information to initialize - # the tract maps - nside_coverage = self._compute_nside_coverage_tract(tract_info) - nside = input_map.nside_sparse - - do_compute_approx_psf = False - # Initialize the tract maps - for property_map in self.property_maps: - property_map.initialize_tract_maps(nside_coverage, nside) - if property_map.requires_psf: - do_compute_approx_psf = True - - tract_maps_initialized = True - valid_pixels, vpix_ra, vpix_dec = input_map.valid_pixels_pos(return_pixels=True) # Check if there are no valid pixels for the inner (unique) patch region