Skip to content

Commit

Permalink
Added WCS to the reprojected image
Browse files Browse the repository at this point in the history
  • Loading branch information
ejeschke committed Dec 19, 2019
1 parent 6a0b318 commit 2eb1c97
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions ginga/rv/plugins/Reproject.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"""
import os.path
import numpy as np
#np.set_printoptions(threshold=np.inf)
from astropy.io import fits
import reproject

Expand Down Expand Up @@ -152,6 +153,7 @@ def close(self):
return True

def stop(self):
self.img_out = None
self._split_sizes = self.w.splitter.get_sizes()

def redo(self):
Expand All @@ -166,7 +168,8 @@ def reproject(self, image, name=None, shape=None, cache_dir=None):
if shape is None:
shape = image.shape

proj_out = self.wcs_out
header = self.img_out.get_header()
proj_out = fits.Header(header)

method = _choose[self._proj_type]['method']

Expand All @@ -186,6 +189,8 @@ def reproject(self, image, name=None, shape=None, cache_dir=None):

# TODO: use mask (probably as alpha mask)
hdu = fits.PrimaryHDU(data_out)
# add conversion wcs keywords
hdu.header.update(self.img_out.wcs.wcs.to_header())
if name is None:
name = self.get_name(image.get('name'), cache_dir)

Expand All @@ -197,7 +202,6 @@ def reproject(self, image, name=None, shape=None, cache_dir=None):
hdulst.writeto(path)
self.logger.info("wrote {}".format(path))

# TODO: decent header with WCS
img_out = AstroImage.AstroImage(logger=self.logger)
img_out.load_hdu(hdu)
img_out.set(name=name, path=path)
Expand All @@ -210,9 +214,7 @@ def set_wcs_cb(self, w):
return

self.rpt_image.set_image(image)
#self.wcs_out = image.wcs.wcs
header = image.get_header()
self.wcs_out = fits.Header(header)
self.img_out = image
self.rpt_image.onscreen_message("WCS set", delay=1.0)

def reproject_cb(self, w):
Expand Down

0 comments on commit 2eb1c97

Please sign in to comment.