From 9cbe5cec580e327ddc26d22a7e713de3c16f0b5c Mon Sep 17 00:00:00 2001 From: gully Date: Tue, 11 Aug 2020 18:02:19 -0500 Subject: [PATCH 1/6] A workaround for unfixable header keys, which are currently populating with missing content and their genuine values, breaking the ImageFileCollection for data with these malformed headers. --- ccdproc/image_collection.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ccdproc/image_collection.py b/ccdproc/image_collection.py index 6fd9f6bb..0500da63 100644 --- a/ccdproc/image_collection.py +++ b/ccdproc/image_collection.py @@ -618,6 +618,14 @@ def _fits_summary(self, header_keywords): file_path, e) continue + ## Bugfix: Unfixable header keywords sometimes yield duplicate + # entries (probably arises the `_dict_from_fits_header` above) + # For now just check if there are more values than files and + # if so, fill with None for now. + for key in summary_dict.keys(): + if len(summary_dict[key]) > len(summary_dict['file']): + summary_dict[key]= [None]*len(summary_dict['file']) + summary_table = Table(summary_dict, masked=True) for column in summary_table.colnames: From 165083f3719f3059086a2ff3796b5bfec373543f Mon Sep 17 00:00:00 2001 From: gully Date: Tue, 17 Nov 2020 12:52:22 -0600 Subject: [PATCH 2/6] Add self to authors list per Pull Request checklist --- AUTHORS.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/AUTHORS.rst b/AUTHORS.rst index aaf34708..d0a05093 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -56,6 +56,7 @@ Alphabetical list of contributors * Nathan Walker (@walkerna22) * Benjamin Weiner (@bjweiner) * Jiyong Youn (@hletrd) +* Michael Gully-Santiago (@gully) (If you have contributed to the ccdproc project and your name is missing, please send an email to the coordinators, or From f1fee7e958c9f330713267e1e4e01cc3486cdc97 Mon Sep 17 00:00:00 2001 From: gully Date: Tue, 17 Nov 2020 12:56:15 -0600 Subject: [PATCH 3/6] Add ldescription of change to CHANGES.rst Per the PR checklist --- CHANGES.rst | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index 1d9ac188..6dd5a24b 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -16,6 +16,8 @@ Bug Fixes - ``test_image_collection.py`` in the test suite no longer produces permanent files on disk and cleans up after itself. [#738] +- Workaround malformed header keyword names [#743] + 2.1.0 (2019-12-24) ------------------ From 136e64cf885cbfcaccdb6c65f72b688348550aff Mon Sep 17 00:00:00 2001 From: gully Date: Tue, 17 Nov 2020 13:31:24 -0600 Subject: [PATCH 4/6] Add warning logger and fix test for edge case of None summary_dict --- ccdproc/image_collection.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ccdproc/image_collection.py b/ccdproc/image_collection.py index 0500da63..95c1eb42 100644 --- a/ccdproc/image_collection.py +++ b/ccdproc/image_collection.py @@ -622,9 +622,11 @@ def _fits_summary(self, header_keywords): # entries (probably arises the `_dict_from_fits_header` above) # For now just check if there are more values than files and # if so, fill with None for now. - for key in summary_dict.keys(): - if len(summary_dict[key]) > len(summary_dict['file']): - summary_dict[key]= [None]*len(summary_dict['file']) + if summary_dict is not None: + for key in summary_dict.keys(): + if len(summary_dict[key]) > len(summary_dict['file']): + logger.warning('malformed header keyword %s cannot be understood.',key) + summary_dict[key] = [None]*len(summary_dict['file']) summary_table = Table(summary_dict, masked=True) From 82f02528a4f47974fc82dcda4cce5ed4061edc42 Mon Sep 17 00:00:00 2001 From: gully Date: Mon, 23 Nov 2020 11:32:59 -0600 Subject: [PATCH 5/6] Turn off deprecation warnings for now. --- ccdproc/log_meta.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ccdproc/log_meta.py b/ccdproc/log_meta.py index 38944afa..59d05e63 100644 --- a/ccdproc/log_meta.py +++ b/ccdproc/log_meta.py @@ -10,6 +10,9 @@ from astropy import units as u from astropy.io import fits +import warnings +warnings.filterwarnings("ignore", category=DeprecationWarning) + import ccdproc # really only need Keyword from ccdproc __all__ = [] From ac01c61882e43d6425a27da545b8b3780f5862f0 Mon Sep 17 00:00:00 2001 From: Matt Craig Date: Sun, 29 Nov 2020 17:03:15 -0600 Subject: [PATCH 6/6] Update ccdproc/log_meta.py --- ccdproc/log_meta.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ccdproc/log_meta.py b/ccdproc/log_meta.py index 59d05e63..262741f3 100644 --- a/ccdproc/log_meta.py +++ b/ccdproc/log_meta.py @@ -11,7 +11,7 @@ from astropy.io import fits import warnings -warnings.filterwarnings("ignore", category=DeprecationWarning) +warnings.filterwarnings("ignore", category=DeprecationWarning) import ccdproc # really only need Keyword from ccdproc