From 686814f2265fc287985c8c27d0b59ac4e7a34ede Mon Sep 17 00:00:00 2001 From: stscicrawford Date: Sun, 28 Jul 2019 12:30:46 -0400 Subject: [PATCH 1/2] added warning to transform_image that it does not apply to WCS --- CHANGES.rst | 3 +++ ccdproc/core.py | 13 ++++++++++--- ccdproc/tests/test_ccdproc.py | 9 +++++++++ 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 864425a2..61d33318 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -19,6 +19,9 @@ Other Changes and Additions - Added support for .bz2, .Z and .zip file formats in ``ImageFileCollection``. +- Added warning that ``transform_image`` does not apply the transformation to the WCS [#684] + + Bug Fixes ^^^^^^^^^ - Function ``median_combine`` now correctly calculates the uncertainty for diff --git a/ccdproc/core.py b/ccdproc/core.py index 13da2d84..e95b9a86 100644 --- a/ccdproc/core.py +++ b/ccdproc/core.py @@ -2,10 +2,13 @@ """This module implements the base CCDPROC functions""" +import math import numbers +import logging import numpy as np -import math +from scipy import ndimage + from astropy.units.quantity import Quantity from astropy import units as u from astropy.modeling import fitting @@ -16,12 +19,12 @@ from astropy.utils import deprecated import astropy # To get the version. -from scipy import ndimage - from .utils.slices import slice_from_string from .log_meta import log_to_metadata from .extern.bitfield import bitfield_to_boolean_mask as _bitfield_to_boolean_mask +logger = logging.getLogger(__name__) + __all__ = ['background_deviation_box', 'background_deviation_filter', 'ccd_process', 'cosmicray_median', 'cosmicray_lacosmic', 'create_deviation', 'flat_correct', 'gain_correct', 'rebin', @@ -853,6 +856,10 @@ def transform_image(ccd, transform_func, **kwargs): mask = transform_func(nccd.mask, **kwargs) nccd.mask = mask > 0 + if nccd.wcs is not None: + warn = 'WCS information may be incorrect as no transformation was applied to it' + logging.warning(warn) + return nccd diff --git a/ccdproc/tests/test_ccdproc.py b/ccdproc/tests/test_ccdproc.py index f61c2be5..bfe96bdd 100644 --- a/ccdproc/tests/test_ccdproc.py +++ b/ccdproc/tests/test_ccdproc.py @@ -573,6 +573,15 @@ def test_transform_isfunc(ccd_data): with pytest.raises(TypeError): transform_image(ccd_data, 1) +#test warning is issue if WCS information is available +def test_catch_transform_wcs_warning(ccd_data): + + def tran(arr): + return 10 * arr + + with catch_warnings() as w: + tran = transform_image(ccd_data, tran) + @pytest.mark.parametrize('mask_data, uncertainty', [ (False, False), From fc8f932d4e1c402d4ac472df41ab672cb8fda348 Mon Sep 17 00:00:00 2001 From: Steve Crawford Date: Sun, 28 Jul 2019 14:50:32 -0400 Subject: [PATCH 2/2] Update test_ccdproc.py fix indentation --- ccdproc/tests/test_ccdproc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ccdproc/tests/test_ccdproc.py b/ccdproc/tests/test_ccdproc.py index bfe96bdd..c8f67214 100644 --- a/ccdproc/tests/test_ccdproc.py +++ b/ccdproc/tests/test_ccdproc.py @@ -580,7 +580,7 @@ def tran(arr): return 10 * arr with catch_warnings() as w: - tran = transform_image(ccd_data, tran) + tran = transform_image(ccd_data, tran) @pytest.mark.parametrize('mask_data, uncertainty', [