Skip to content

Commit

Permalink
allow specification of FITS suffixes in ImageFileCollection
Browse files Browse the repository at this point in the history
  • Loading branch information
keflavich committed Jan 29, 2020
1 parent b9ec64d commit 82757fa
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions ccdproc/image_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ class ImageFileCollection:
The extension from which the header and data will be read in all
files.Default is ``0``.
extensions: list
A list of FITS extensions to search for. The default is ``['fit',
'fits', 'fts']``.
Raises
------
ValueError
Expand All @@ -87,7 +91,8 @@ class ImageFileCollection:

def __init__(self, location=None, keywords=None,
find_fits_by_reading=False,
filenames=None, glob_include=None, glob_exclude=None, ext=0):
filenames=None, glob_include=None, glob_exclude=None, ext=0,
extensions=None):
# Include or exclude files from the collection based on glob pattern
# matching - has to go above call to _get_files()
if glob_exclude is not None:
Expand All @@ -107,7 +112,7 @@ def __init__(self, location=None, keywords=None,

self._filenames = filenames
self._files = []
self._files = self._get_files()
self._files = self._get_files(extensions=extensions)

if self._files == []:
warnings.warn("no FITS files in the collection.",
Expand Down Expand Up @@ -432,7 +437,7 @@ def filter(self, **kwd):
return ImageFileCollection(filenames=files,
keywords=self.keywords)

def _get_files(self):
def _get_files(self, extensions=None):
""" Helper method which checks whether ``files`` should be set
to a subset of file names or to all file names in a directory.
Expand All @@ -448,7 +453,7 @@ def _get_files(self):
else:
files = self._filenames
else:
files = self._fits_files_in_directory()
files = self._fits_files_in_directory(extensions=extensions)

if self.glob_include is not None:
files = fnmatch.filter(files, self.glob_include)
Expand Down

0 comments on commit 82757fa

Please sign in to comment.