diff --git a/ccdproc/image_collection.py b/ccdproc/image_collection.py index 383e809f..464d0c91 100644 --- a/ccdproc/image_collection.py +++ b/ccdproc/image_collection.py @@ -592,7 +592,8 @@ def _generator(self, return_type, return_fname : bool, default is False If True, return the tuple (header, file_name) instead of just - header. + header. The file name returned is the name of the file only, + not the full path to the file. kwd : dict Any additional keywords are used to filter the items returned; see @@ -606,7 +607,7 @@ def _generator(self, return_type, ({return_type}, str) If ``return_fname`` is ``True``, yield a tuple of - ({name}, ``file path``) for next the item in the collection. + ({name}, ``file name``) for the next item in the collection. """ # store mask so we can reset at end--must COPY, otherwise @@ -626,6 +627,8 @@ def _generator(self, return_type, hdulist = fits.open(full_path, do_not_scale_image_data=no_scale) + file_name = path.basename(full_path) + return_options = {'header': hdulist[0].header, 'hdu': hdulist[0], 'data': hdulist[0].data} @@ -633,7 +636,7 @@ def _generator(self, return_type, try: yield (return_options[return_type] # pragma: no branch if (not return_fname) else - (return_options[return_type], full_path)) + (return_options[return_type], file_name)) except KeyError: raise ValueError('No generator for {}'.format(return_type)) diff --git a/ccdproc/tests/test_image_collection.py b/ccdproc/tests/test_image_collection.py index 693a6387..9379cf11 100644 --- a/ccdproc/tests/test_image_collection.py +++ b/ccdproc/tests/test_image_collection.py @@ -256,7 +256,7 @@ def test_header_and_filename(self, triage_setup): collection = image_collection.ImageFileCollection(location=triage_setup.test_dir, keywords=['imagetyp']) for header, fname in collection.headers(return_fname=True): - assert (fname in collection._paths()) + assert (fname in collection.summary['file']) assert (isinstance(header, fits.Header)) def test_dir_with_no_fits_files(self, tmpdir):