Открытие файла FITS с результатами Astropy в FileNotFoundError - PullRequest
0 голосов
/ 30 января 2019

Когда я использую

fits_datasweep_gal = fits.open('Macintosh HD/Users/lingxuan/Downloads/datasweep-index-gal.fits')

, чтобы открыть файл FITS на ноутбуке Jupyter, он возвращает:

FileNotFoundError                         Traceback (most recent call last)
<ipython-input-13-e5886f60eba2> in <module>
----> 1 fits_datasweep_gal = fits.open('Macintosh HD/Users/lingxuan/Downloads/datasweep-index-gal.fits')

~/anaconda3/lib/python3.7/site-packages/astropy/io/fits/hdu/hdulist.py in fitsopen(name, mode, memmap, save_backup, cache, lazy_load_hdus, **kwargs)
    149 
    150     return HDUList.fromfile(name, mode, memmap, save_backup, cache,
--> 151                             lazy_load_hdus, **kwargs)
    152 
    153 

~/anaconda3/lib/python3.7/site-packages/astropy/io/fits/hdu/hdulist.py in fromfile(cls, fileobj, mode, memmap, save_backup, cache, lazy_load_hdus, **kwargs)
    388         return cls._readfrom(fileobj=fileobj, mode=mode, memmap=memmap,
    389                              save_backup=save_backup, cache=cache,
--> 390                              lazy_load_hdus=lazy_load_hdus, **kwargs)
    391 
    392     @classmethod

~/anaconda3/lib/python3.7/site-packages/astropy/io/fits/hdu/hdulist.py in _readfrom(cls, fileobj, data, mode, memmap, save_backup, cache, lazy_load_hdus, **kwargs)
   1037             if not isinstance(fileobj, _File):
   1038                 # instantiate a FITS file object (ffo)
-> 1039                 fileobj = _File(fileobj, mode=mode, memmap=memmap, cache=cache)
   1040             # The Astropy mode is determined by the _File initializer if the
   1041             # supplied mode was None

~/anaconda3/lib/python3.7/site-packages/astropy/utils/decorators.py in wrapper(*args, **kwargs)
    501                         # one with the name of the new argument to the function
    502                         kwargs[new_name[i]] = value
--> 503             return function(*args, **kwargs)
    504 
    505         return wrapper

~/anaconda3/lib/python3.7/site-packages/astropy/io/fits/file.py in __init__(self, fileobj, mode, memmap, overwrite, cache)
    176             self._open_fileobj(fileobj, mode, overwrite)
    177         elif isinstance(fileobj, str):
--> 178             self._open_filename(fileobj, mode, overwrite)
    179         else:
    180             self._open_filelike(fileobj, mode, overwrite)

~/anaconda3/lib/python3.7/site-packages/astropy/io/fits/file.py in _open_filename(self, filename, mode, overwrite)
    553 
    554         if not self._try_read_compressed(self.name, magic, mode, ext=ext):
--> 555             self._file = fileobj_open(self.name, IO_FITS_MODES[mode])
    556             self.close_on_error = True
    557 

~/anaconda3/lib/python3.7/site-packages/astropy/io/fits/util.py in fileobj_open(filename, mode)
    386     """
    387 
--> 388     return open(filename, mode, buffering=0)
    389 
    390 

FileNotFoundError: [Errno 2] No such file or directory: 'Macintosh HD/Users/lingxuan/Downloads/datasweep-index-gal.fits'

Что мне делать?

1 Ответ

0 голосов
/ 30 января 2019

Удалить Macintosh HD деталь из пути

fits_datasweep_gal = fits.open('/Users/lingxuan/Downloads/datasweep-index-gal.fits')
...