a more convenient WCS for tesscut TPFs?
See original GitHub issueProblem description
A TPF downloaded from TESS full frame image with search_tesscut
has a WCS referenced to the center of the original FFI, using SIP distortion coefficients to account for distortions across the wide field of view. For some uses, it’d be more convenient if this WCS were referenced relative to something like center of the new tiny stamp, and if it didn’t use the wide-field distortion coefficients; in particular, astropy’s WCSAxes
can’t plot with those distortion coefficients.
Example
from lightkurve.search import search_tesscut, search_targetpixelfile
from astropy.coordinates import SkyCoord
from astroquery.mast import Catalogs
import astropy.units as u
import numpy as np
import matplotlib.pyplot as plt
# pick a target
target = 'LHS 3844'
center = SkyCoord.from_name(target)
# download as a two-minute TPF
tpf_twominute = search_targetpixelfile(center).download()
print(tpf_twominute.wcs)
# download as a tesscut from the FFI
size = tpf_twominute.shape[-1]
tpf_tesscut = search_tesscut(center).download(cutout_size=size)
print(tpf_tesscut.wcs)
# download some stars around the target
radius = size/2.0*20*u.arcsec*1.5
stars = Catalogs.query_object(target, radius=radius, catalog='Gaia')
# (neglecting proper motion between Gaia and TESS)
# define a helper for plotting both
def plot(tpf, gs, frame=0):
# use WCSAxes from astropy to plot with WCS
ax = plt.subplot(gs, projection=tpf.wcs)
ax.imshow(tpf.flux[frame])
# overplot the stars, using the WCS tranform on the axes
ra, dec = stars['ra'], stars['dec']
s = np.maximum((17 - stars['phot_g_mean_mag'])*5, 0)
plt.scatter(ra, dec, s=s, transform=ax.get_transform('icrs'), color='red', zorder=100)
return ax
# plot the both together
gs = plt.matplotlib.gridspec.GridSpec(1, 2)
plot(tpf_twominute, gs[0])
plt.title('from TPF')
plot(tpf_tesscut, gs[1])
plt.title('from tesscut');
Expected behavior
It’d be great if a tesscut TPF had a WCS connected to it that acted like those in “normal” TPFs. I found a nice investigation into this by @ceb8 here, including a sketch of a solution for deriving a new local WCS. Have @ceb or folks here at lightkurve
have started implementing this at all? Or is it already implemented somewhere? Or, if not, should I try to tackle it? Thanks!
(I’ll link to this over at tesscut too.)
Issue Analytics
- State:
- Created 4 years ago
- Comments:10 (2 by maintainers)
Top GitHub Comments
@barentsen we’re actually remaking the WCS from scratch using matched pixel and world coordinates. It’s functionality that will hopefully be in the next release of astropy (see https://github.com/astropy/astropy/pull/7884), but I’ll be implementing it early in astrocut.
Also, yes! Thanks for reminding me, I’ve been meaning to open an astropy issue suggesting that they add a warning about wcsaxes doing wcs_pix2world rather than all_pix2world since I figured out what was going on.
I ran the code example which @zkbt posted above and now see the following output:
This looks much better!! Awesome job for fixing this @ceb8!!
I think this can be closed. Feel free to re-open if the issue re-emerges!