Skip to content

Commit

Permalink
Fix creation of cube source from file name
Browse files Browse the repository at this point in the history
  • Loading branch information
teutoburg committed Feb 11, 2025
1 parent 3cb4fd0 commit 2f1b3c6
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions scopesim/source/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -324,10 +324,15 @@ def _from_cube(self, cube, ext=0, **kwargs):
wcs = WCS(cube)
else:
with fits.open(cube) as hdul:
data = hdul[ext].data
header = hdul[ext].header
header["FILENAME"] = Path(cube).name
wcs = WCS(cube)
try:
data = hdul[ext].data
header = hdul[ext].header
header["FILENAME"] = Path(cube).name
wcs = WCS(header)
except ValueError: # e.g. TAB WCS
self._from_cube(hdul, ext)
self.fields[0].header["FILENAME"] = Path(cube).name
return

Check warning on line 335 in scopesim/source/source.py

View check run for this annotation

Codecov / codecov/patch

scopesim/source/source.py#L327-L335

Added lines #L327 - L335 were not covered by tests

try:
bunit = header["BUNIT"]
Expand Down

0 comments on commit 2f1b3c6

Please sign in to comment.