Skip to content

Commit

Permalink
Add SpectralFlatField to the list of correctors (fixes #127)
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiopasra committed Feb 4, 2019
1 parent a098a3e commit 3b1c204
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
25 changes: 24 additions & 1 deletion emirdrp/core/correctors.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright 2008-2018 Universidad Complutense de Madrid
# Copyright 2008-2019 Universidad Complutense de Madrid
#
# This file is part of PyEmir
#
Expand Down Expand Up @@ -92,6 +92,7 @@ def get_corrector_s(rinput, meta, ins, datamodel):


def get_corrector_f(rinput, meta, ins, datamodel):
"""Corrector for intensity flat"""
from emirdrp.processing.flatfield import FlatFieldCorrector
flat_info = meta['master_flat']
with rinput.master_flat.open() as hdul:
Expand All @@ -112,6 +113,28 @@ def get_corrector_f(rinput, meta, ins, datamodel):
return flat_corrector


def get_corrector_sf(rinput, meta, ins, datamodel):
"""Corrector for spectral flat"""
from emirdrp.processing.flatfield import FlatFieldCorrector
flat_info = meta['master_flat']
with rinput.master_flat.open() as hdul:
_logger.info('loading spectral flat')
_logger.debug('flat info: %s', flat_info)
mflat = hdul[0].data
# Check NaN and Ceros
mask1 = mflat < 0
mask2 = ~numpy.isfinite(mflat)
if numpy.any(mask1):
_logger.warning('flat has %d values below 0', mask1.sum())
if numpy.any(mask2):
_logger.warning('flat has %d NaN', mask2.sum())
flat_corrector = FlatFieldCorrector(mflat,
datamodel=datamodel,
calibid=datamodel.get_imgid(hdul))

return flat_corrector


def get_corrector_d(rinput, meta, ins, datamodel):
key = 'master_dark'

Expand Down
5 changes: 3 additions & 2 deletions emirdrp/core/recipe.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright 2008-2018 Universidad Complutense de Madrid
# Copyright 2008-2019 Universidad Complutense de Madrid
#
# This file is part of PyEmir
#
Expand Down Expand Up @@ -68,10 +68,11 @@ def types_getter(self):
prods.MasterBias,
prods.MasterDark,
prods.MasterIntensityFlat,
prods.MasterSpectralFlat,
prods.MasterSky
]
getters = [cor.get_corrector_p, cor.get_corrector_b, cor.get_corrector_d,
[cor.get_corrector_f, cor.get_checker], cor.get_corrector_s]
[cor.get_corrector_f, cor.get_checker], cor.get_corrector_sf, cor.get_corrector_s]

return imgtypes, getters

Expand Down

0 comments on commit 3b1c204

Please sign in to comment.