Skip to content

Commit

Permalink
Fix header overwrite.
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremykubica committed Dec 13, 2023
1 parent a5a88a4 commit 0e35175
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/kbmod/work_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def from_fits(cls, filename):
imgs.append(LayeredImage(sci, var, msk, p))

im_stack = ImageStack(imgs)
result = WorkUnit(im_stack=im_stack, config=config, wcs=global_wcs)
result = WorkUnit(im_stack=im_stack, config=config, wcs=global_wcs)
result.per_image_wcs = per_image_wcs
return result

Expand Down Expand Up @@ -117,9 +117,14 @@ def to_fits(self, filename, overwrite=False):
# the metadata (empty), and the configuration.
hdul = fits.HDUList()
pri = fits.PrimaryHDU()
if self.wcs is not None:
pri.header = self.wcs.to_header()
pri.header["NUMIMG"] = self.im_stack.img_count()

# If the global WCS exists, append the corresponding keys.
if self.wcs is not None:
wcs_header = self.wcs.to_header()
for key in wcs_header:
pri.header[key] = wcs_header[key]

hdul.append(pri)

meta_hdu = fits.BinTableHDU()
Expand Down Expand Up @@ -177,7 +182,7 @@ def extract_wcs(hdu):
return None
if "CRPIX1" not in hdu.header or "CRPIX2" not in hdu.header:
return None

curr_wcs = WCS(hdu.header)
if curr_wcs is None:
return None
Expand Down

0 comments on commit 0e35175

Please sign in to comment.