Skip to content

Commit

Permalink
Merge pull request #219 from GeminiDRSoftware/feature/cleanskysub
Browse files Browse the repository at this point in the history
add rejection of frames that cannot be sky subtracted to avoid contamination of the good ones.
  • Loading branch information
chris-simpson authored Apr 16, 2021
2 parents 2d899b3 + 8f29c6b commit a98ee3a
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 3 deletions.
41 changes: 40 additions & 1 deletion doc/DRAGONS/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,46 @@
Change Logs
***********

[KL: TO REMOVE BEFORE RELEASE. Last update up to commit Thu Sep 17 16:57 HST 2020]
[KL: TO REMOVE BEFORE RELEASE. Last update up to commit ... need commits
review since beginning of branch.]

3.0.0
=====

This release includes new support for GMOS longslit data. Reduction of
GMOS longslit data is offered only quicklook mode. It does not produce
science quality outputs, yet.

Bug Fixes
---------

* In imaging mode, the science recipes now include a call to
``scaleByExposureTime`` before the stacking step. It is now possible to stack
frames with different exposure times.
* In near-IR imaging mode, frames that fail to be sky subtracted are removed
from the main reduction stream to avoid contamination. The reduction continues
with the "good" frames. If all frames fail the sky subtraction, then all
frames will be passed to the next step of the reduction.

New Features
------------

* Quicklook (``ql`` mode) reduction support for GMOS longslit data.

Compatibility
-------------

* Python 2 support has been dropped. Starting with v3.0.0, DRAGONS requires
Python 3. All tests were run on Python 3.7, and this version of Python
now serves as the minimal required version.


Documentation
-------------

(KL: When we add them: New tutorial for the reduction of GMOS longslit data.)



2.1.2
=====
Expand Down
24 changes: 23 additions & 1 deletion geminidr/core/primitives_preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ def associateSky(self, adinputs=None, **params):
ad.update_filename(suffix=sfx, strip=True)
gt.mark_history(ad, primname=self.myself(), keyword=timestamp_key)

has_skytable = [False] * len(adinputs)
if not adinputs or not ad_skies:
log.warning("Cannot associate sky frames, since at least one "
"science AstroData object and one sky AstroData "
Expand All @@ -283,7 +284,7 @@ def associateSky(self, adinputs=None, **params):
sky_times = dict(zip(ad_skies,
[ad.ut_datetime() for ad in ad_skies]))

for ad in adinputs:
for i, ad in enumerate(adinputs):
# If use_all is True, use all of the sky AstroData objects for
# each science AstroData object
if params["use_all"]:
Expand Down Expand Up @@ -330,11 +331,32 @@ def associateSky(self, adinputs=None, **params):
for sky in sky_list:
log.stdinfo(" {}".format(sky.filename))
ad.SKYTABLE = sky_table
has_skytable[i] = True
else:
log.warning("No sky frames available for {}".format(ad.filename))

# Need to update sky stream in case it came from the "sky" parameter
self.streams['sky'] = ad_skies

# if none of frames have sky tables, just pass them all through
# if only some frames did not have sky corrected, move them out of main and
# to the "no_skytable" stream.
if not any(has_skytable): # "all false", none have been sky corrected
log.warning('Sky frames could not be associated to any input frames.'
'Sky subtraction will not be possible.')
elif not all(has_skytable): # "some false", some frames were NOT sky corrected
log.stdinfo('') # for readablity
false_idx = [idx for idx, trueval in enumerate(has_skytable) if not trueval]
for idx in reversed(false_idx):
ad = adinputs[idx]
log.warning(f'{(ad.filename} does not have any associated sky '
'cannot be sky-subtracted, moving to "no_skies" stream')
if "no_skies" in self.streams:
self.streams["no_skies"].append(ad)
else:
self.streams["no_skies"] = [ad]
del adinputs[idx]
return adinputs
def correctBackgroundToReference(self, adinputs=None, suffix=None,
Expand Down
1 change: 0 additions & 1 deletion geminidr/core/primitives_resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,6 @@ def _resample_to_new_frame(self, adinputs=None, frame=None, order=3,
output_shape = tuple(int(np.floor(max(corners)) - np.ceil(min(corners)) + 1)
for corners in all_corners)

print("ORIGIN", origin)
log.stdinfo("Output image will have shape "+repr(output_shape[::-1]))
adoutputs = []
for ad in adinputs:
Expand Down

0 comments on commit a98ee3a

Please sign in to comment.