Skip to content

Commit

Permalink
fixed a small bug in forced mode of cleanReadout
Browse files Browse the repository at this point in the history
  • Loading branch information
soraisam committed Jun 30, 2023
1 parent 60180b3 commit e1b0b43
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
3 changes: 2 additions & 1 deletion geminidr/core/parameters_nearIR.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class cleanReadoutConfig(config.Config):
pattern_y_size = config.Field("Pattern y size (pixels)", int, 4, check=powerof2)
debug_subtract_background = config.Field("Subtract median from each pattern box?", bool, True)
level_bias_offset = config.Field("Level the bias offset across (sub-)quads accompanying pattern noise?", bool, True)
smoothing_extent = config.RangeField("Width (in pix) of the region at a given quad interface to be smoothed over", int, 5, min=5)
smoothing_extent = config.RangeField("Width (in pix) of the region at a given quad interface to be smoothed over", int, 5, min=1)
sg_win_size = config.RangeField("Smoothing window size (pixels) for Savitzky-Golay filter", int, 25, min=3)
simple_thres = config.RangeField("Pattern edge detection threshold", float, 0.6, min=0.0)
pat_strength_thres = config.RangeField("Pattern strength threshold", float, 15.0, min=0.0)
Expand All @@ -67,6 +67,7 @@ class cleanFFTReadoutConfig(config.Config):
l2clean = config.Field("Clean Fourier artifacts?", bool, True)
l2thres = config.RangeField("Sigma factor to be used in thresholding for l2clean", float, 4., min=0)
clean = config.Field("Behavior of the routine? Must be one of default, skip, or force", str, "default")
smoothing_extent = config.RangeField("Width (in pix) of the region at a given quad interface to be smoothed over", int, 5, min=1)

class separateFlatsDarksConfig(config.Config):
pass
11 changes: 7 additions & 4 deletions geminidr/core/primitives_nearIR.py
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ def reblock(data):
"clean": False}

# MS: do not touch the quad if pattern strength is weak
if pattern.std() >= pat_strength_thres:
if pattern.std() >= pat_strength_thres or clean == "force":
# MS: now finding the applicable roi for pattern subtraction.
# Calculate the scaling factors for the pattern in
# all pattern boxes and investigate as a fn of row
Expand Down Expand Up @@ -613,11 +613,13 @@ def cleanFFTReadout(self, adinputs=None, **params):
l2thres: float
Sigma factor to be used in thresholding for l2clean. For stubborn Fourier artifacts,
consider decreasing this value.
smoothing_extent: int
Width (in pixels) of the region at a given quad interface to be smoothed over
on each side of the interface.
clean: str, Default: "skip"
Must be one of "skip", "default", or "force".
Must be one of "skip" or "default". Note "force" option doesn't exist for this FFT method.
skip: Skip this routine entirely when called from a recipe.
default: Apply the pattern subtraction to each quadrant of the image.
force: Force the pattern subtraction in each quadrant.
"""
log = self.log
log.debug(gt.log_message("primitive", self.myself(), "starting"))
Expand All @@ -631,6 +633,7 @@ def cleanFFTReadout(self, adinputs=None, **params):
l2thres = params["l2thres"]
clean = params["clean"]
periodicity = params["periodicity"]
smoothing_extent = params["smoothing_extent"]

def debug_levelQuad(ext, sig=2.0, smoothing_extent=5):
"""
Expand Down Expand Up @@ -778,7 +781,7 @@ def find_offset(ext, arr1_slicers, arr2_slicers, clipper):


## inter-quad leveling
debug_levelQuad(ext)
debug_levelQuad(ext, smoothing_extent=smoothing_extent)

if l2clean:
for ystart, tb in zip((0, qysize),('bottom','top')):
Expand Down

0 comments on commit e1b0b43

Please sign in to comment.