Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ImageFileCollection fails if the fits headers contain the keyword 'FILE' #726

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions ccdproc/image_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -500,15 +500,24 @@ def _add_val_to_dict(key, value, tbl_dict, n_previous, missing_marker):

h = fits.getheader(file_name, self.ext)

assert 'file' not in h

if self.location:
# We have a location and can reconstruct the path using it
name_for_file_column = path.basename(file_name)
else:
# No location, so use whatever path the user passed in
name_for_file_column = file_name

# Remove the header 'FILE' keyword if present to avoid adding the value
# twice to the summary dictionary.
if h.get('file') is not None:
if h.get('file').strip() != name_for_file_column.strip():
warnings.warn(
'Header from file "{f}" contains keyword "FILE" with '
'FILE={v}" which will be ignored.'
''.format(v=h.get('file').strip(), f=file_name),
UserWarning)
h.remove('file')

# Try opening header before this so that file name is only added if
# file is valid FITS
try:
Expand Down