Skip to content

Commit

Permalink
Fixes to opening fits files with no pixel data.
Browse files Browse the repository at this point in the history
  • Loading branch information
cmccully committed Nov 10, 2023
1 parent a7f3df5 commit 3acc932
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions banzai/utils/fits_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,12 +199,15 @@ def unpack(compressed_hdulist: fits.HDUList) -> fits.HDUList:
starting_extension = 1
for hdu in compressed_hdulist[starting_extension:]:
if isinstance(hdu, fits.CompImageHDU):
data_type = str(hdu.data.dtype)
if 'int' == data_type[:3]:
data_type = getattr(np, 'u' + data_type)
data = np.array(hdu.data, data_type)
if hdu.data is None:
data = hdu.data
else:
data = np.array(hdu.data, hdu.data.dtype)
data_type = str(hdu.data.dtype)
if 'int' == data_type[:3]:
data_type = getattr(np, 'u' + data_type)
data = np.array(hdu.data, data_type)
else:
data = np.array(hdu.data, hdu.data.dtype)
hdulist.append(fits.ImageHDU(data=data, header=hdu.header))
elif isinstance(hdu, fits.BinTableHDU):
hdulist.append(fits.BinTableHDU(data=hdu.data, header=hdu.header))
Expand Down

0 comments on commit 3acc932

Please sign in to comment.