sdss / marvin

Data access and visualization for MaNGA. http://sdss-marvin.readthedocs.io/en/latest/
BSD 3-Clause "New" or "Revised" License
56 stars 32 forks source link

Can't access Image due to 'No such file or directory' for drpall #739

Open affanadly opened 3 years ago

affanadly commented 3 years ago

Describe the bug I can't access any Images due to 'No such file or directory error' for the drpall-v2_4_3.fits, even when the file is successfully downloaded and verified to be available.

To Reproduce Simply run

from marvin.tools.image import Image
im = Image('8567-3704')

Expected behavior Gives out an error [Errno 2] No such file or directory: '/root/sas/dr16/manga/spectro/redux/v2_4_3/drpall-v2_4_3.fits' Full error:

[WARNING]: drpall file not found. Downloading it. (MarvinUserWarning)
Progress:   0%|          | 0/1 [00:00<?, ?files/s, n_files=1, n_streams=1]
[WARNING]: drpall file not found. Downloading it. (MarvinUserWarning)
SDSS_ACCESS> Done!
Progress:   0%|          | 0/1 [00:00<?, ?files/s, n_files=1, n_streams=1]SDSS_ACCESS> Done!

---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
<ipython-input-9-fc6de919d3c6> in <module>()
----> 1 im = Image('8567-3704')

10 frames
/usr/local/lib/python3.7/dist-packages/marvin/tools/image.py in __init__(self, input, filename, mangaid, plateifu, mode, data, release, download)
     75             raise MarvinError('Images cannot currently be accessed from the db')
     76         elif self.data_origin == 'api':
---> 77             self._load_image_from_api()
     78 
     79         # initialize attributes

/usr/local/lib/python3.7/dist-packages/marvin/tools/image.py in _load_image_from_api(self)
    170         ''' Load an image from a remote location '''
    171 
--> 172         filepath = self._getFullPath()
    173         response = requests.get(self.url)
    174         if not response.ok:

/usr/local/lib/python3.7/dist-packages/marvin/tools/image.py in _getFullPath(self)
    132 
    133         plate, ifu = self.plateifu.split('-')
--> 134         dir3d = self._get_image_dir()
    135 
    136         name = 'mangaimage'

/usr/local/lib/python3.7/dist-packages/marvin/tools/image.py in _get_image_dir(self)
    121 
    122         # get the appropriate image directory
--> 123         is_mastar = target_is_mastar(self.plateifu, drpver=self._drpver)
    124         image_dir = 'mastar' if is_mastar else 'stack'
    125         return image_dir

/usr/local/lib/python3.7/dist-packages/marvin/utils/general/general.py in target_is_mastar(plateifu, drpver, drpall)
   1725     '''
   1726 
-> 1727     row = get_drpall_row(plateifu, drpver=drpver, drpall=drpall)
   1728     return row['srvymode'] == 'APOGEE lead'
   1729 

/usr/local/lib/python3.7/dist-packages/marvin/utils/general/general.py in get_drpall_row(plateifu, drpver, drpall)
    986 
    987     # get the drpall table
--> 988     drpall_table = get_drpall_table(drpver=drpver, drpall=drpall, hdu='MANGA')
    989     in_table = plateifu in drpall_table['plateifu']
    990     # check the mastar extension

/usr/local/lib/python3.7/dist-packages/marvin/utils/general/general.py in get_drpall_table(drpver, drpall, hdu)
   1768     if hdu not in drpTable[drpver]:
   1769         drpall = drpall if drpall else get_drpall_path(drpver=drpver)
-> 1770         data = {hduext: table.Table.read(drpall, hdu=hduext)}
   1771         drpTable[drpver].update(data)
   1772 

/usr/local/lib/python3.7/dist-packages/astropy/table/connect.py in __call__(self, *args, **kwargs)
     59         descriptions = kwargs.pop('descriptions', None)
     60 
---> 61         out = registry.read(cls, *args, **kwargs)
     62 
     63         # For some readers (e.g., ascii.ecsv), the returned `out` class is not

/usr/local/lib/python3.7/dist-packages/astropy/io/registry.py in read(cls, format, cache, *args, **kwargs)
    510                     try:
    511                         ctx = get_readable_fileobj(args[0], encoding='binary', cache=cache)
--> 512                         fileobj = ctx.__enter__()
    513                     except OSError:
    514                         raise

/usr/lib/python3.7/contextlib.py in __enter__(self)
    110         del self.args, self.kwds, self.func
    111         try:
--> 112             return next(self.gen)
    113         except StopIteration:
    114             raise RuntimeError("generator didn't yield") from None

/usr/local/lib/python3.7/dist-packages/astropy/utils/data.py in get_readable_fileobj(name_or_obj, encoding, cache, show_progress, remote_timeout, sources, http_headers)
    260                 timeout=remote_timeout, sources=sources,
    261                 http_headers=http_headers)
--> 262         fileobj = io.FileIO(name_or_obj, 'r')
    263         if is_url and not cache:
    264             delete_fds.append(fileobj)

FileNotFoundError: [Errno 2] No such file or directory: '/root/sas/dr16/manga/spectro/redux/v2_4_3/drpall-v2_4_3.fits'

Screenshots image

Desktop:

havok2063 commented 3 years ago

@affanadly I'm not sure but looks like it might be a permissions issue(?). It looks like you're trying to write the SAS contents into /root. If that's a root level system directory, your user running marvin might not have permissions to write files/folders into that place. Can you check your permissions on /root? Or can you try setting the SAS_BASE_DIR environment variable to a new directory inside your user's home directory, or a folder where you have correct permissions. What version of Marvin are you using?

It also looks like you're using a system installation of the Python. These have been known to cause issues. We recommend using a separate Python installation, e.g. from Anaconda or Miniconda.