From 6827b1d72e305cac1d56378984b6f4a1efb330a6 Mon Sep 17 00:00:00 2001 From: Michele De La Pena Date: Thu, 7 Nov 2024 09:08:16 -0500 Subject: [PATCH] Fixed a bug associated with a previous commit when computing statistics on the illuminated portion only of the drizzled image. The computation now uses the footprint_mask computed on the DRZ CTX image which reports the number of images which contributed to the final pixel value. If the CTX > 0, then the pixel is illuminated. --- drizzlepac/haputils/catalog_utils.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drizzlepac/haputils/catalog_utils.py b/drizzlepac/haputils/catalog_utils.py index 54016f766..ffef2e5e8 100755 --- a/drizzlepac/haputils/catalog_utils.py +++ b/drizzlepac/haputils/catalog_utils.py @@ -275,14 +275,13 @@ def compute_background(self, box_size, win_size, # this for SBC. if (self.imghdu[0].header['DETECTOR'].upper() == "SBC"): num_of_zeros = np.count_nonzero(imgdata[self.footprint_mask] == 0) - num_of_nonzeros = num_of_illuminated_pixels - num_of_zeros # If there are too many background zeros in the image # (> number_of_zeros_in_background_threshold), set the background median to # zero and the background rms to the real rms of the non-zero values in the image. if num_of_zeros / float(num_of_illuminated_pixels) * 100.0 > zero_percent: self.bkg_median = 0.0 - self.bkg_rms_median = stats.tstd(num_of_nonzeros, limits=[0, None], inclusive=[False, True]) + self.bkg_rms_median = stats.tstd(imgdata[self.footprint_mask], limits=[0, None], inclusive=[False, True]) self.bkg_background_ra = np.full_like(imgdata, 0.0) self.bkg_rms_ra = np.full_like(imgdata, self.bkg_rms_median) self.bkg_type = 'zero_background'