Skip to content

Commit 154e6c8

Browse files
change makeBPM to use electrons for the dark limits as after an ADUToElectrons, the original gain is no longer accessible. The code was always using 1 for F2 and NIRI.
1 parent 6624329 commit 154e6c8

4 files changed

Lines changed: 17 additions & 16 deletions

File tree

geminidr/core/parameters_nearIR.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ class addDQConfig(parameters_standardize.addDQConfig, addLatencyToDQConfig):
2020

2121
class makeBPMConfig(config.Config):
2222
override_thresh = config.ChoiceField("Apply user-specified thresholds, overriding any default calculation?", bool, { True : 'Must be True where no default algorithm is implemented' }, default=True, optional=False)
23-
dark_lo_thresh = config.Field("Low rejection threshold for dark (ADU)", float, None, optional=True)
24-
dark_hi_thresh = config.Field("High rejection threshold for dark (ADU)", float, None, optional=True)
23+
dark_lo_thresh = config.Field("Low rejection threshold for dark (electrons)", float, None, optional=True)
24+
dark_hi_thresh = config.Field("High rejection threshold for dark (electrons)", float, None, optional=True)
2525
flat_lo_thresh = config.RangeField("Low rejection threshold for normalized flat", float, None, max=1.0, optional=True)
2626
flat_hi_thresh = config.RangeField("High rejection threshold for normalized flat", float, None, min=1.0, optional=True)
2727
keep_unilluminated = config.Field("Keep unilluminated pixels flags?", bool, False)

geminidr/core/primitives_nearIR.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def makeBPM(self, adinputs=None, **params):
9595
Parameters
9696
----------
9797
dark_lo_thresh, dark_hi_thresh: float, optional
98-
Range of data values (always in ADUs) outside which pixels in the
98+
Range of data values (always in electrons) outside which pixels in the
9999
input dark are considered bad (eg. -20 and 100, but these defaults
100100
vary by instrument). A limit of None is not applied and all pixels
101101
are considered good at that end of the range.
@@ -147,21 +147,22 @@ def makeBPM(self, adinputs=None, **params):
147147
log.stdinfo(msg.format(flat_lo, flat_hi))
148148
flat_mask = np.ma.masked_outside(flat_ext.data, flat_lo, flat_hi)
149149

150-
msg = "BPM Dark Mask Lower < > Upper Limit: {} < > {} ADU\n" \
151-
" ({} < > {})"
152150
bunit = dark_ext.hdr.get('BUNIT', 'ADU').upper()
153-
if bunit in ('ELECTRON', 'ELECTRONS'):
154-
conv = dark_ext.gain()
155-
elif bunit == 'ADU':
156-
conv = 1
157-
else:
151+
if bunit not in ('ELECTRON', 'ELECTRONS', 'ADU'):
158152
raise ValueError("Input units for dark should be ADU or "
159153
"ELECTRON, not {}".format(bunit))
160-
log.stdinfo(msg.format(dark_lo, dark_hi,
161-
conv*dark_lo, conv*dark_hi))
162-
# create the mask -- darks (hot pixels)
154+
155+
msg = "BPM Dark Mask Lower < > Upper Limit: {} < > {} electrons\n" #\
156+
#" ({} < > {})"
157+
if bunit == 'ADU':
158+
msg += " ({:.2f} < > {:.2f}) ADU"
159+
log.stdinfo(msg.format(dark_lo, dark_hi,
160+
dark_lo/dark_ext.gain(), dark_hi/dark_ext.gain()))
161+
else:
162+
log.stdinfo(msg.format(dark_lo, dark_hi))
163163
dark_mask = np.ma.masked_outside(dark_ext.data,
164-
conv*dark_lo, conv*dark_hi)
164+
dark_lo / dark_ext.gain(),
165+
dark_hi / dark_ext.gain())
165166

166167
# combine masks and write to bpm file
167168
data_mask = np.ma.mask_or(np.ma.getmaskarray(dark_mask),

geminidr/f2/parameters_f2_image.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ def setDefaults(self):
1818
class makeBPMConfig(parameters_nearIR.makeBPMConfig):
1919
def setDefaults(self):
2020
self.dark_lo_thresh = -150.
21-
self.dark_hi_thresh = 650.
21+
self.dark_hi_thresh = 3050.
2222
self.flat_lo_thresh = 0.68
2323
self.flat_hi_thresh = 1.28

geminidr/niri/parameters_niri.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ def setDefaults(self):
2323
class makeBPMConfig(parameters_nearIR.makeBPMConfig):
2424
def setDefaults(self):
2525
self.dark_lo_thresh = -20.
26-
self.dark_hi_thresh = 100.
26+
self.dark_hi_thresh = 1300.
2727
self.flat_lo_thresh = 0.8
2828
self.flat_hi_thresh = 1.25

0 commit comments

Comments
 (0)