Skip to content

Commit

Permalink
accounting for data units
Browse files Browse the repository at this point in the history
  • Loading branch information
cshanahan1 authored Feb 7, 2023
1 parent f163d57 commit 759ecb5
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions romancal/source_detection/source_detection_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class SourceDetectionStep(RomanStep):

spec = """
save_catalogs = boolean(default=True) # Save source catalog to file? Will overwrite an existing catalog of the same name.
coverage_mask = boolean(default=True) # Mask DO_NOT_USE pixels in image?
coverage_mask = boolean(default=False) # Mask DO_NOT_USE pixels in image?
kernel_fwhm = float(default=1.5) # DAOStarFinder: size of Gaussian kernel, in pixels.
sharplo = float(default=0.5) # DAOStarFinder: lower bound for sharpness.
sharphi = float(default=1.0) # DAOStarFinder: upper bound for sharpness.
Expand All @@ -57,11 +57,18 @@ def process(self, input):
# This will need to be changed later to deal with associations
with rdd.open(input) as input_model:

self.data = input_model.data
# strip units from data - 'threshold' must be a scalar and cannot be compared to
# data with units.
if hasattr(input_model.data, 'unit'):
self.data = input_model.data.value
else:
self.data = input_model.data

if self.coverage_mask: # mask DO_NOT_USE pixels
self.coverage_mask = ((dqflags.pixel['DO_NOT_USE']) &
input_model.dq).astype(bool)
else:
self.coverage_mask = None

# first, determine threshold for source detection
# check if at least and only one of the threshold options is present
Expand All @@ -75,6 +82,7 @@ def process(self, input):

detect_sources_in_segments = False # always False unless using calc_threshold_2d


# if a pre-determined threshold value for detection for the whole
# image is provided, use this
if self.scalar_threshold:
Expand Down Expand Up @@ -102,7 +110,7 @@ def process(self, input):
detect_sources_in_segments = True
bkg = self._calc_2D_background()
threshold_img = bkg.background + (self.snr_threshold * bkg.background_rms)
detect_sources_in_segments = True
# detect_sources_in_segments = True

# run DAOStar finder in segments, combine outputs and cut table if
# max_sources is larger than the total final table
Expand Down

0 comments on commit 759ecb5

Please sign in to comment.