question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

a more convenient WCS for tesscut TPFs?

See original GitHub issue

Problem 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');

image

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:closed
  • Created 4 years ago
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
ceb8commented, Jun 7, 2019

@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.

1reaction
barentsencommented, Jul 18, 2019

I ran the code example which @zkbt posted above and now see the following output:

Screenshot from 2019-07-17 19-38-50

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!

Read more comments on GitHub >

github_iconTop Results From Across the Web

a more convenient WCS for tesscut TPFs? · Issue #527 - GitHub
A TPF downloaded from TESS full frame image with search_tesscut has a WCS referenced to the center of the original FFI, using SIP...
Read more >
How to plot a star from TESScut to the right place on the sky ...
The first is that the TPFs that TESScut produces come with the original WCS information from the full-frame image adjusted for the position ......
Read more >
Using Target Pixel Files with Lightkurve
The WCS contains information about how pixel positions map to celestial sky coordinates. This is important when comparing a TPF from a Kepler,...
Read more >
Astrocut Documentation - Read the Docs
The CutoutsComibner class allows the user to take one or more Astrocut cutout FITS files (as from fits_cut ) with a shared WCS...
Read more >
Target Pixel Files - TESS Science Support Center - HEASARC
Understanding TargetPixelFile objects Learning goals In this tutorial we will learn the following, - What a TESS Target Pixel File (TPF) is.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found