Skip to content

Commit 6dde0eb

Browse files
authored
Fix creation of cube source from file name (#559)
2 parents 6cd5de7 + 2f1b3c6 commit 6dde0eb

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

scopesim/source/source.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -346,10 +346,15 @@ def _from_cube(self, cube, ext=0, **kwargs):
346346
wcs = WCS(cube)
347347
else:
348348
with fits.open(cube) as hdul:
349-
data = hdul[ext].data
350-
header = hdul[ext].header
351-
header["FILENAME"] = Path(cube).name
352-
wcs = WCS(cube)
349+
try:
350+
data = hdul[ext].data
351+
header = hdul[ext].header
352+
header["FILENAME"] = Path(cube).name
353+
wcs = WCS(header)
354+
except ValueError: # e.g. TAB WCS
355+
self._from_cube(hdul, ext)
356+
self.fields[0].header["FILENAME"] = Path(cube).name
357+
return
353358

354359
try:
355360
bunit = header["BUNIT"]

0 commit comments

Comments
 (0)