From a35980e0b98c2dc369996193e1994f3cc834b705 Mon Sep 17 00:00:00 2001 From: mdlpstsci Date: Wed, 31 Jul 2024 18:15:34 -0400 Subject: [PATCH] HLA-1302: Avoid application of cosmic ray threshold for ACS/SBC and WFC3/IR (#1859) --- CHANGELOG.rst | 3 +++ drizzlepac/haputils/catalog_utils.py | 25 +++++++++++++------------ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 86b1863ea..3999f143b 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -20,6 +20,9 @@ number of the code change for that issue. These PRs can be viewed at: 3.7.1 (unreleased) ================== +- Avoid applying the estimated cosmic ray vs real sources threshold for the + ACS/SBC and WFC3/IR detectors. [#1858] + - Corrected the way the n1_exposure_time and tot_exposure_time values are computed as these values are used in the computation for rejecting catalog creation based on expected cosmic ray detections. Generalized diff --git a/drizzlepac/haputils/catalog_utils.py b/drizzlepac/haputils/catalog_utils.py index 75d0a0100..b24356fee 100755 --- a/drizzlepac/haputils/catalog_utils.py +++ b/drizzlepac/haputils/catalog_utils.py @@ -565,7 +565,7 @@ class HAPCatalogs: # WFPC2: 1600**2 pixels, pixel size (15um)**2 # acs/wfc-> crfactor = {'aperture': 300, 'segment': 150} # CRs / hr / 4kx4k pixels crfactor = {'WFC': {'aperture': 300, 'segment': 150}, 'HRC': {'aperture': 37, 'segment': 18.5}, - 'UVIS': {'aperture': 300, 'segment': 150}, 'PC': {'aperture': 46, 'segment': 23}} + 'UVIS': {'aperture': 300, 'segment': 150}, 'WFPC2': {'aperture': 46, 'segment': 23}} def __init__(self, fitsfile, param_dict, param_dict_qc, num_images_mask, log_level, diagnostic_mode=False, types=None, tp_sources=None): @@ -690,17 +690,18 @@ def verify_crthresh(self, n1_exposure_time): log.info(" based on EXPTIME = {}sec for the n=1 filters".format(n1_exposure_time)) detector = self.image.keyword_dict["detector"].upper() - for cat_type in self.catalogs: - source_cat = self.catalogs[cat_type] - if source_cat.sources: - thresh = self.crfactor[detector][cat_type] * n1_exposure_time**2 / self.image.keyword_dict['texpo_time'] - source_cat = source_cat.sources if cat_type == 'aperture' else source_cat.source_cat - n_sources = source_cat.sources_num_good # len(source_cat) - all_sources = len(source_cat) - log.info("{} catalog with {} good sources out of {} total sources : CR threshold = {}".format(cat_type, n_sources, all_sources, thresh)) - if n_sources < thresh and 0 < n_sources: - self.reject_cats[cat_type] = True - log.info("{} catalog FAILED CR threshold.".format(cat_type)) + if detector not in ['IR', 'SBC']: + for cat_type in self.catalogs: + source_cat = self.catalogs[cat_type] + if source_cat.sources: + thresh = self.crfactor[detector][cat_type] * n1_exposure_time**2 / self.image.keyword_dict['texpo_time'] + source_cat = source_cat.sources if cat_type == 'aperture' else source_cat.source_cat + n_sources = source_cat.sources_num_good + all_sources = len(source_cat) + log.info("{} catalog with {} good sources out of {} total sources : CR threshold = {}".format(cat_type, n_sources, all_sources, thresh)) + if 0 < n_sources < thresh: + self.reject_cats[cat_type] = True + log.info("{} catalog FAILED CR threshold.".format(cat_type)) # Ensure if any catalog is rejected, the remaining catalogs are also rejected if any([True for k,v in self.reject_cats.items() if v == True]):