# TESSreduce: transient focused TESS data reduction pipeline

R. Ridden-Harper,1,2 A. Rest,2,3 R. Hounsell,4,5 T. E. Müller-Bravo,6 Q.
Wang,2 V. A. Villar7,8,9
1 School of Physical and Chemical Sciences | Te Kura Matū, University of Canterbury, Private Bag 4800, Christchurch 8140, New Zealand
2 Department of Physics and Astronomy, The Johns Hopkins University,
Baltimore, MD 21218, USA.
3 Space Telescope Science Institute, 3700 San Martin Drive, Baltimore, MD
21218, USA.
4 University of Maryland, Baltimore County, 1000 Hilltop Cir, Baltimore, MD
21250, USA
5 NASA Goddard Space Flight Center, Greenbelt, MD 20771, USA
6 School of Physics and Astronomy, University of Southampton, Southampton,
Hampshire, SO17 1BJ, UK
7 Department of Astronomy & Astrophysics, The Pennsylvania State University,
University Park, PA 16802, USA
8 Institute for Computational & Data Sciences, The Pennsylvania State
University, University Park, PA 16802, USA
9 Institute for Gravitation and the Cosmos, The Pennsylvania State University,
University Park, PA 16802, USA
<EMAIL_ADDRESS>
(Accepted XXX. Received YYY; in original form ZZZ)

###### Abstract

Since its launch, TESS has provided high cadence observations for objects
across the sky. Although high cadence TESS observations provide a unique
possibility to study the rapid time evolution of numerous objects, artifacts
in the data make it particularly challenging to use in studying transients.
Furthermore, the broadband red filter of TESS, makes calibrating it to
physical flux units, or magnitudes, challenging. Here we present TESSreduce an
open-source, and user-friendly Python package which is built to lower the
barrier to entry for transient science with TESS. In a few commands users can
produce a reliable TESS light curve, accounting for systematic biases that are
present in other models (such as instrument drift and the varied TESS
background) and calculate a zeropoint to percent level precision. With this
package anyone can use TESS for science, such as studying rapid transients and
constraining progenitors of supernovae.

###### keywords:

methods: data analysis – techniques: image processing – supernovae: general

††pubyear: 2015††pagerange: TESSreduce: transient focused TESS data reduction
pipeline–D

##  1 Introduction

Built to discover and study exoplanets, the Transiting Exoplanet Survey
Telescope (TESS) has a unique mission profile of rapidly imaging large
(24${}^{\circ}\times$90∘) sectors of the sky (Ricker et al., 2015). During the
prime mission, which ran from July 25th 2018 to July 4th 2020, TESS recorded
full frame images (FFIs) at a 30 minute cadence, however, this cadence was
increased for the extended mission to 10 minutes. The combination of the
missions wide filed of view, continuous coverage ($\sim$27 days per sector),
high cadenced observations, and ability to perform precision photometry makes
TESS a unique instrument, not just for exoplanet studies, rather for all time
varying phenomena.

As we saw from the Kepler/K2 missions, 30 minute observations of transients
can reveal new and unique features that are key to understanding progenitor
systems of transient phenomena. Throughout the 8 year mission, Kepler/K2
observed numerous supernovae revealing features, in never-before seen time
resolution. For example, in a study of 3 core collapse supernovae (CCSNe)
observed by Kepler, Garnavich et al. (2016) detected the first known shock
breakout from a Type II SN (SN II) in KSN 2011d; this result was used to
strongly constrain the progenitor star and SN properties, as well as
theoretical explosion models. Because optical shock break out signatures only
last for minutes to hours, high cadence observations from instruments such as
Kepler and TESS are crucial to detecting and understanding this phenomenon.
Similarly, Armstrong et al. (2021) presents the first full shock cooling curve
of the CCSN AT 2017jgh. This unique data set again showed that it is crucial
to capture the rise of the shock cooling curve at high cadence to effectively
constrain models and obtain reliable progenitor properties.

Precise high cadence observations are also crucial for understanding the
progenitors of Type Ia Supernovae (SNe Ia). Although these supernovae are
known to come from the thermonuclear detonation of C/O white dwarfs in binary
systems (e.g., Hoyle & Fowler, 1960; Woosley et al., 1986; Nomoto et al.,
1984; Hoeflich et al., 1996; Hillebrandt & Niemeyer, 2000; Bloom et al., 2012;
Maoz et al., 2014), and play a key role in understanding the evolution of the
Universe as distance indicators (e.g., Riess et al., 1998; Perlmutter et al.,
1999; Betoule et al., 2014; Scolnic et al., 2018; Abbott et al., 2019), the
exact progenitor systems are unknown. This introduces a systematic uncertainty
in the standardization of SN Ia (e.g., Foley et al., 2010; Polin et al.,
2019). Clues to the progenitor systems are expected to be found within a few
days of explosion in the SN Ia light curves. Nominally, SN Ia are expected to
rise according to the fireball model in which luminosity increases
proportional to a power law with an index $\sim 2$ ($L\propto t^{2}$; e.g.,
Arnett, 1982; Riess et al., 1998; Olling et al., 2015; Nugent et al., 2011;
Hayden et al., 2010; Miller et al., 2020; Wang et al., 2021). However,
different progenitor models predict deviations from the fireball model (e.g.,
Piro, 2012; Firth et al., 2015), which can sometimes be seen as excess flux at
early times. Kepler/K2 saw such evidence of early excess flux in SN 2018oh
(Dimitriadis et al., 2019; Li et al., 2019; Shappee et al., 2019), however,
there was no evidence of excess flux in 5 other SN Ia; in fact, SN 2018agk was
shown to perfectly follow the fireball model (Olling et al., 2015; Wang et
al., 2021).

In recent years, the number of rapid-evolving transients (RETs111Other
acronyms used for RETs include fast-evolving luminous transients (FELTs) or
fast blue optical transients (FBOTs).), objects which rise to maximum
brightness in $\lesssim$10 days and exponential decline in $\lesssim$30 days
after rest-frame peak, have been increasing with samples such as those from
Pan-STARRS1 (Drout et al., 2014) and the Dark Energy Survey (Pursiainen et
al., 2018), among others (e.g., Arcavi et al., 2016; Perley et al., 2020).
Transients like AT 2018cow (e.g., Prentice et al., 2018; Ho et al., 2019;
Margutti et al., 2019; Perley et al., 2019) and ZTF18abvkwla (e.g., Coppejans
et al., 2020; Ho et al., 2020) have been observed at multiple wavelengths.
Additionally, KSN 2015K has been the only RET observed at extremely high
cadence Rest et al. (2018). While these unique events provided valuable
insights into the nature of RETs, more high-cadence observations of the early
light curves are key for understanding their explosion mechanism and
progenitors.

Furthermore, distant supernovae can be gravitationally lensed and magnified by
a foreground galaxy, providing an opportunity to measure the time delay
between light paths and constrain the Hubble constant. These gravitationally
lensed SNe can be observed by TESS. Holwerda et al. (2021) estimated the
chances of observing SNe Ia and CCSNe being very low (0.6 and 1.3 per cent per
year, respectively, and 2 and 4 percent at the ecliptic poles), but not null
and highlighted the need for timely processing of TESS imaging.

Alongside providing new insights into SNe, consistent high cadence
observations also offer a new parameter space to search for new transients.
Ridden-Harper et al. (2020) details a program to search the background pixels
of the Kepler/K2 mission to identify previously unknown transients observed in
high cadence, such as the WZ Sge type dwarf nova presented in Ridden-Harper et
al. (2019). Such a program could also be possible with TESS which could
provide us with a new window into a previously unexplored time domain.

These are all science cases in which TESS could be a powerful tool for
understanding transients. Some of these science cases are already being
explored with the 4 years of data available. Fausnaugh et al. (2019) presented
an analysis of 18 bright SN Ia observed by TESS and found no significant
deviation from the fireball model at early times, however, they did observe
slower rises than expected. A closer analysis of a SN 2018fhw, a bright SN Ia
observed by TESS, also does not show any indication of early features in the
light curve (Vallely et al., 2019). Similarly, a study of bright CCSNe
observed by TESS found no indication of a shock breakout at early times,
suggesting the phenomena may be rare (Vallely et al., 2021). Furthermore, TESS
provided a comprehensive view of TDE ASASSN-19tb, showing its flux scales as
$\propto t^{2}$ (Holoien et al., 2019). Similarly, TESS observed an outburst
of the repeating TDE ASASSN-14ko, showing it had a smooth powerlaw rise (Payne
et al., 2021). Finally, Smith et al. (2021) presents the first TESS light
curve of a long GRB, in the detection of GRB 191016A.

Although TESS has great potential for transient science, challenges with data
reduction can present a significant hurdle. There are three components to TESS
data that must be addressed before the data can be used, which are:

  * •

Image alignment,

  * •

Scattered light background,

  * •

Instrument calibration.

The first two components are key to extracting reliable TESS light curves,
while the final component is crucial for comparisons to supplementary data and
model fitting. Currently, there are several successful reduction pipelines for
TESS FFIs (such as eleanor;Feinstein et al. 2019), difference imaging
pipelines (such as the DIA pipeline; Oelkers & Stassun 2018), the CDIPs
pipeline; Bouma et al. 2019), those that make use of the ISIS package (Alard &
Lupton, 1998; Alard, 2000) (such as Vallely et al. 2019, Fausnaugh et al.
2019, Vallely et al. 2021), and the LINEAR pipeline (Woods et al., 2021).
However, these methods have limitations, particularly in addressing the highly
variable background scattered light, and flux calibration. We examine these
limitations in section 3, and section 5. While eleanor is pip
installable222https://adina.feinste.in/eleanor/, the other methods require
local installs of complex reduction pipelines, making TESS data reduction
challenging. With TESSreduce, we provide another open-source user-friendly
python package that addresses all three challenges in dealing with TESS data,
without the need for high profile difference imaging pipelines.

In this paper, we present the TESSreduce pipeline for TESS data analysis,
alongside light curves of selected transients. As seen in Figure 1 even in
cases of extreme background TESSreduce can recover transient signals. We
highlight the data products used by TESSreduce in section 2; the background
determination method in section 3; image alignment in section 4; absolute
photometric calibration of TESS photometry in section 5; and finally,
transient light curves reduced by our method/code are presented in section 7.

Our code is open source and can be accessed on
Github333https://github.com/CheerfulUser/TESSreduce or pip installed. The
TESSreduce docs can be found
online444https://tessreduce.readthedocs.io/en/latest/. TESSreduce has already
been used to enable analysis of the gamma ray burst GRB 191016A (Smith et al.,
2021), and the peculiar comet C/2014 UN271 (Bernardinelli-Bernstein; Ridden-
Harper et al., 2021).

##  2 Data

To produce reliable light curves from TESS data, TESSreduce leverages data
from across numerous instruments. This data is used in background
determination and instrument photometric calibration. Here we discuss all data
products used in TESSreduce.

###  2.1 TESS

Figure 1: TESS light curves of the rise of SN 2020cdj. Left: Raw TESS light
curve, this is dominated by background scattered light which cause the spikes
in the light curve around 58870 and 58885 MJD. As a comparison the scatter
light background peaks with a brightness of over 6000 counts, while SN 2020cdj
peaks at $\sim 20$ counts. Right: Reduced and flux calibrated TESS light curve
created by TESSreduce, alongside public ZTF $g$ and $r$ observations. With the
correct reduction, TESS is capable of reaching sensitivities comparable to
state-of-the-art ground based survey telescopes, with higher cadence.

TESS data is characterized by low spatial resolution (21″ per pixel), but high
temporal resolution. The observing campaigns, known as sectors, last for $\sim
28$ days, with a mid-sector data gap at $\sim 14$ days. As seen in Figure 2,
regions toward the poles can have multiple sectors of overlap due to the
strip-like nature of the TESS field-of-view, extending the TESS coverage to a
maximum of a year at the poles.

Figure 2: Schematic of TESS sectors adapted from Ricker et al. (2015) Fig. 7.

The three primary data products are the Full Frame Images (FFIs), Target Pixel
Files (TPFs), which cover small regions of the detector at higher cadence, and
SPOC pipeline lightcurves. The data formats for the FFIs and TPFs are also
different, where the FFIs are individual images, while the TPFs are data cubes
made from time series of images. In the primary mission, which consists of
data from sectors 1–26, FFIs were recorded at a 30 minute cadence, while the
targeted TPFs had a 2 minute cadence. For the extended mission, which will
cover sectors 27–onwards, the cadence was increased to 10 minutes for FFIs and
20s for TPFs.

TESSreduce was built using the lightkurve package as a foundation, therefore
it utilizes the TPF data format (Lightkurve Collaboration et al., 2018).
Although FFIs are not directly compatible with TESSreduce, TPF cutouts can
readily be created from the FFIs using the TESScut tool (Brasseur et al.,
2019). In general, we use comparably large $90\times 90$ pixel cutouts for
TESSreduce, to generate reliable determinations of the complex background,
since point sources are nominally $3\times 3$ pixels in size.

###  2.2 Pan-STARRS (PS1)

To supplement the TESS data, we make extensive use of the (PS1) $grizy$
photometry from the 1.8 m Pan-STARRS 1 telescope (PS1) (Tonry et al., 2012).
PS1 covers the Northern sky to a declination of $-30^{\circ}$ and limiting
magnitudes of 23.3, 23.2, 23.1, 22.3, 21.4 mag, for the $grizy$ filters,
respectively. Sources brighter than $\sim 14$ mag reach saturation in PS1 so
are not included in the source catalogs, such as the DR1 catalog we use here
(Chambers et al., 2016).

Alongside source masking, we use PS1 data for photometric calibration of TESS.
The total PS1 system is superbly calibrated and consistent, with $<1\%$
variability across the detector (Schlafly et al., 2012). Furthermore, to
achieve precise cosmological measurements, the PS1 photometric system has been
well calibrated with numerous probes. As described in Scolnic et al. (2015),
Supercal calibration achieved a relative calibration to better than $\sim 5$
mmag with Calspec sources. Narayan et al. (2019) extends the Calspec catalog
with faint DA white dwarfs which have hydrogen-dominated atmospheres, and also
finds the PS1 system is consistent to mmag levels of precision. Due to the
well calibrated nature of PS1 photometry and wide wavelength coverage, we
primarily use PS1 photometry for photometric calibration.

We obtain the PS1 data from Vizier table II/349/ps1 with astroquery (Ginsburg
et al., 2017). This high resolution and multi-band data is crucial for both
generating a source mask, and calibrating the TESS photometry.

###  2.3 SkyMapper

To complement the PS1 photometry, and fill in the Southern sky, we use $griz$
photometry from the 1.3 m SkyMapper telescope (Keller et al., 2007). We use
the DR1 catalog presented by Wolf et al. (2018), which is complete to $\sim
18^{\rm th}$ mag, with a saturation limit of $\sim 9^{\rm th}$ mag in all
filters. Even in this early data release, SkyMapper provides an excellent
complement to PS1 where photometry between the two systems is consistent to
within an RMS scatter of 2%.

As with the PS1 DR1 source catalog, we access the SkyMapper DR1 catalog with
astroquery and Vizier table II/358/smss.

###  2.4 Gaia

We rely on Gaia data to supplement the PS1 and SkyMapper data, particularly
for saturated sources. Gaia has produced an all sky catalog of sources with a
limiting magnitude of 22 and a saturation magnitude of $\sim 3$ (Gaia
Collaboration et al., 2016, 2018; Arenou et al., 2018). We access the Gaia DR2
catalog I/345/gaia2 through Vizier, with astroquery. Although the Gaia G
filter magnitudes can be a close approximation to TESS magnitudes, as shown in
Stassun et al. (2019), we elect to only use Gaia data in the creation of
source masks, since we can achieve more reliable TESS magnitudes from PS1 and
SkyMapper photometry.

###  2.5 Calspec

To construct a photometric mapping from PS1 magnitudes to TESS magnitudes and
an extinction coefficient for TESS, we rely on the well calibrated spectra
within the Calspec
library555https://www.stsci.edu/hst/instrumentation/reference-data-for-
calibration-and-tools/astronomical-catalogs/calspec (Bohlin et al., 2014,
2020). In this application of the catalog, we restrict ourselves to the use of
only the gold-standard Calspec sources with Hubble STIS coverage, and drop the
series of sources associated with NGC 6681 as we find that they significantly
deviate from the canonical stellar locus.

###  2.6 ZTF photometry

For transients, we use the public ZTF photometry to compare against the
calibrated TESS light curves. Although we do not directly use these light
curves in the TESSreduce reduction, they are a useful tool for verifying the
integrity of the TESSreduce light curve and identifying host flux. An example
of this comparison can be seen in Fig 1. To gather the ZTF light curves we use
the Open Supernova Catalog (OSC, Guillochon et al., 2017) application
programming interface (API) to identify the ZTF-specific transient name, which
can then be used jointly with the Automatic Learning for the Rapid
Classification of Events (ALeRCE, Förster et al., 2021) API to download public
ZTF $g$ and $r$ band photometry.

##  3 Background determination

The greatest challenge with TESS data is in accurately determining and
removing the background caused by scattered Earth and Moon light. Due to the
close 28 day orbit TESS has between the Earth and Moon, it is prone to
suffering from significant levels of background from scattered light. In
Figure 1, we show the raw lightcurve for SN 2020cdj (left) which is dominated
by the scattered light background, peaking at over 6000 counts, in contrast SN
2020cdj peaks at $\sim 20$ counts. Such scenarios where the background signal
is $10-100$ times brighter than the target are common. This background is
highly variable, both spatially and temporally, which is usually repeated for
the two 14 day sector segments. To compound the background challenges, the low
resolution images lead to source blending, often leaving few true sky pixels
from which the background can be determined. Furthermore, the background is
comprised of two distinct aspects, a smooth and continuous background, and a
discrete vertical background caused by electrical straps behind the CCDs.

Different image reduction pipelines account for the background with different
methods. For example both the DIA and CDIPS pipelines rely on median smoothing
the background with a $32\times 32$ pixel and a $48\times 48$ pixel grid,
respectively. This method will biased the background to higher values,
especially in crowded fields. Furthermore, the background structure varies on
smaller distance scales, meaning these large bins will miss background
structure. As the two image-reduction pipelines are described, they also do
not account for the strap artifacts, which will lead to poor background
subtractions for sources that fall in the strap columns. The LINEAR pipeline,
however, does not list a background determination and subtraction method.

The ISIS-based difference imaging pipelines such as those used in Vallely et
al. (2019) and Fausnaugh et al. (2019) determine the background after the
reference image is subtracted. After subtraction, the background is then
calculated in a similar manner to the DIA and CDIPS pipelines by calculating
the median background from $30\times 30$ pixel regions. While this method
significantly reduces the risk of sources biasing the background, it will
still be biased by the cores of bright objects that do not fully subtract out.
Likewise, the enhanced strap background is not accounted for in these
pipelines. Vallely et al. (2021) improves upon the background subtraction by
decomposing the 2D background into 1D strips. First they calculate and
subtract the vertical component of the 1D background by median filtering
individual columns of the subtracted image over 30 rows. The column background
is then subtracted from the difference image, limiting the effects of the
strap background, before the same process is applied to the rows. Although
this method can produce a close approximation of the complex TESS background,
it has some limitations. Mainly, the straps in this method are treated as an
additive component, however, they are a multiplicative component, arising from
the straps scattering light back into the CCD, effectively enhancing the
quantum efficiency (QE) for strap columns (Vanderspek et al., 2018).
Furthermore, like with the other methods, imperfections in the difference
image will bias the background, particularly around bright and variable
sources.

With TESSreduce, we address the shortcomings in background determination of
other difference imaging pipelines by masking sources and addressing the
discrete strap background according to the physical origin.

###  3.1 Source/Image masking

A key aspect in determining the TESS background is to first identify all
sources and key features within a TESS image. To create an accurate source
mask we use both the PS1 DR1 and Gaia DR2 source catalogs to identify all
sources within an image, to a depth of 19th mag in PS1 $i$. To generate the
preliminary source mask, we separate sources into magnitude bins, which have
individual mask aperture sizes. For sources with $i>14$ we use simple square
apertures, however, for sources with $i<14$, we use the Gaia G band and
construct a 2-component mask, comprised of a central square mask and a
secondary cross mask, to cover diffraction/bleeding columns. With these masks
we identify and isolate all known sources.

Although the preliminary mask covers most known sources, extended sources,
such as nearby galaxies, often are not fully contained within the preliminary
mask. To correct this, TESSreduce constructs a reference image by selecting an
image where the background is low and well behaved/uniform. We took images
with total summed flux in the lowest 5th percentile to be the low background
images. We then apply the preliminary source mask and cut all pixels brighter
than $2\sigma$ above the median. This strict limit is chosen to minimize the
number of pixels contaminated by sources in the background sample. All clipped
pixels are added in to the source mask. This captures larger diffuse sources
in the mask.

With the source mask, we now construct a bit mask identifying all features in
an image. We assign distinct values to unsaturated sources, saturated sources,
and strap columns, including four adjacent columns on either side. This mask
allows us to readily distinguish between background, and source pixels,
alongside columns that are influenced by straps.

In crowded fields, the default choices we make to construct the mask can leave
few pixels remaining to estimate the background. For all masks we check the
mask coverage fraction by taking the ratio of masked pixels, to total pixels.
If the total source mask covers $>90\%$ of the image, we weaken the catalog
mask requirements to a limiting magnitude of $i=16$ and reduce the default
mask aperture by half. Although this compromise makes enough pixels available
to determine the background, it will now includes sources, thus reducing the
background quality. In the general reduction process, the effect of unmasked
objects is reduced as the final background is calculated for difference
images, where most of the flux is removed for non-variable sources.

###  3.2 Smooth background determination

Determining a reliable smooth background for the TESS images is key in
TESSreduce, as it is also used in determining the discrete strap backgrounds.
Determination of the smooth background follows on simply from the masking
process. For each image we mask out all pixels with non-zero bits in the bit
mask, which includes the strap columns. We then linearly interpolate the
background over the missing pixels with the scipy.griddata algorithm. Since
the linear interpolation method of griddata is unable to extrapolate, we fill
any edge regions that require extrapolation using the “nearest” method.
Finally, we smooth the background using a 2D Gaussian filter with $\sigma=1$
pixel. An example of this background is shown in Figure 3.

###  3.3 Strap background determination

As mentioned previously, the discrete background is caused by electrical
straps behind the CCD scattering light back into the CCD. The scattering is
colour dependent and effectively acts to enhance the QE of columns backed by
straps and their neighbors. We isolate the straps through the bit mask and
omit them from the smooth background determination. To correct for the straps,
we calculate their QE enhancement by comparing the strap background to the
calculated smooth background.

To calculate the apparent QE for strap columns, we use the bitmask to mask all
sources and columns not associated with straps. We then divide the masked
image by the previously calculated smooth background for each image. Although
the enhancement is colour dependent and exhibits variation along an entire FFI
strap column, for small cutouts, such as those used in TESSreduce, there is
little variation, so we take the enhanced QE for a column to be the median of
all sky pixels. Generally, the enhancement is small at around 2%, peaking at
$\sim 6\%$ in regions suffering from extreme levels of scattered light.
Finally, we multiply the smooth background by the calculated QE to obtain a
background that encapsulates both the smooth and discrete components which is
then subtracted from the raw images.

Figure 3: Example background subtraction for a $90\times 90$ pixel cutout of
the TESS FFI centered on SN 2020fqv. This region features multiple strap
features, highly variable background, and numerous complex sources. Left: Raw
TESS image at a time of moderate background flux. Middle left: Smooth
background component determined by TESSreduce by interpolating over masked
sources and strap columns. Middle right: Smooth background, plus the effective
quantum efficiency amplification produced by electrical straps running behind
the CCD. Right: Background subtracted TESS image, some background residuals
still remain on the right side of the image since those columns coincide with
straps and were masked when calculating the smooth background. The colour
scale for the first 3 images spans 8000 to 9000 counts, while the colour scale
for the subtracted image spans 0 to 50 counts.

##  4 Image alignment

Although TESS is largely stable, due to the large pixel size, small changes in
pointing throughout a sector, caused either by instrument drift or
relativistic aberration effects, can lead to significant trends in a light
curve. These effects are particularly present for transients in crowded
fields, or within an extended nearby galaxy. To calculate the relative shifts
of each image to a reference we use the DAOStarFinder function in the
photutils package (Bradley et al., 2020). This method locates all centroids in
an image and provides their fractional pixel position. We then calculate the
$x,y$ pixel offset for each of the sources in every image, relative to the
reference. Although the changes in apparent TESS pointing will be a
combination of spacecraft roll around the boresight, jitter, and relativistic
effects, on small scales such as used in TESSreduce, it is sufficient to treat
it as a simple linear shift.

Although we now have offsets for each image, they contain significant scatter.
Therefore, aligning images with these offsets will introduce significant
scatter to the light curves. To limit the scatter introduced by aligning
images, we smooth the shifts with a Savitzky–Golay filter with a window size
of 51 images and a third order polynomial. We use these smoothed $x,y$ pixel
offsets to align each image to the reference using the shift algorithm from
the scipy ndimage shift package.

Ideally, we would shift the images before calculating and subtracting the
background, however, we found that high background levels can skew the offsets
to incorrect values. To mitigate this, we take the iterative approach of first
determine and subtract the background from the raw images, calculate the image
offsets, and then restart the reduction, thus time aligning the images
according to the previous offsets before calculating the background. Although
this iterative approach increases the computation time for each reduction, it
ensures we have reliable shifts that are not influenced by the variably TESS
background.

Generally, we find that the TESS alignment shifts by only a few percent across
each sector. As seen in Figure 4, the the offset pattern is quite variable and
can behave differently for the two orbits in a sector.

Figure 4: TESS pointing shifts for SN 2020cdj in sector 21, camera 4, CCD 3.
While these shifts are small, only ever a fraction of a pixel, they have a
significant effect on light curves, substantially changing their shapes. These
shifts were found using the photutils DAOStarFinder algorithm and smoothed
with a Savitzky–Golay filter.

###  4.1 Kernel matching

An alternative to shifting images, is to align them through convolving with
Delta kernels. This approach is used by the ISIS based pipelines (e.g.
Fausnaugh et al., 2019), and accounts for both relative shifts between images,
and any changes in the point spread function (PSF). For ground based
telescopes, variable atmospheric conditions lead to large differences in the
point spread function (PSF) between subsequent observations that must be
corrected through the process of kernel matching. For TESS, there is minimal
change in the instrumental PSF and sampled pixel response function (PRF).
While accounting for the subtle changes in the PRF in TESS data would also
improve light curve quality, accurately determining differences in PRFs
between TESS images with the small cutouts used by TESSreduce is challenging.
In Appendix A, we compare the image alignment method used in TESSreduce to a
locally determined Delta kernel shift and find that the image alignment method
produces more reliable results.

##  5 Photometric calibration

While all TESS FFIs available on the Mikulski Archive for Space Telescopes
(MAST666https://archive.stsci.edu/) are calibrated, they are not calibrated to
astrophysical flux units, rather, to counts in terms of $e^{-}/s$ (electrons
per second). To make comparisons of TESS light curves to other data or models,
we must have a reliable way of calibrating the TESS photometry such that we
have a zeropoint that converts TESS counts to astrophysical units.

Other pipelines, such as the LINEAR-TESS pipeline, calibrate a TESS photometry
to Gaia photometry (Woods et al., 2021). Using non-variable stellar sources,
they match TESS instrumental magnitudes to Gaia G magnitudes to calculate a
zeropoint of $21$. While the TESS and Gaia G filters share some similarities,
G extends to much shorter wavelengths than TESS, making it unreliable to
directly compare the two systems (see Figure 13 for a comparison).

Alternatively, the DIA pipeline calculates zeropoints by comparing
instrumental magnitudes to TESS magnitudes for all stars presented in the TESS
Input Catalog (TIC). This method derives a zeropoint of 4.825, which is
substantially lower than zeropoints derived via other methods. This difference
is likely due to re-scaling in the reduction process.

Through tests in the commissioning phase, Vanderspek et al. (2018) derives an
average zeropoint across the detectors of $z_{p}=20.44\pm 0.5$. While the
average zeropoint is a good estimate, it is highly uncertain, so for reliable
flux conversions we must calculate the zeropoint to higher precision.
Furthermore, the zeropoint will also be dependent on the choice of reduction,
so, for consistent flux-calibrated TESS light curves, we have developed a
method for TESSreduce to perform in-situ calibration from field stars.

While broadband filters such as that of TESS can be challenging to calibrate,
we utilize the calibration method developed in Ridden-Harper et al. (prep)
which calibrates Kepler/K2 broadband photometry to a sub-percent level. This
method uses the Calspec spectral library alongside the well calibrated PS1 DR1
photometry to predict magnitudes in broadband filters. We adapt this process
to calibrate TESS photometry through the process described in the following
section.

###  5.1 Mapping PS1 & SkyMapper to TESS magnitudes

Following Ridden-Harper et al. (prep), we assume that the TESS filter can be
represented as a linear combination of PS1 or SkyMapper filters in flux space
with a linear color correction term in magnitude space. As seen in Figure 5,
the TESS filter extends from $5802.57$ to $11171.45$ Å, which covers the PS1
$rizy$ filters, and, for the color correction, we take the difference between
$g$ and $i$. The large wavelength difference between $g$ and $i$, gives us a
good baseline for identifying any colour terms.

To determine the contributions from each of the PS1 filters, we use synthetic
photometry on the Calspec spectral library. With the filter definitions of the
PS1 and TESS filters, obtained from the Spanish Virtual
Observatory777http://svo2.cab.inta-csic.es/theory/fps/ (SVO; Rodrigo et al.,
2012; Rodrigo & Solano, 2020), we calculate the synthetic magnitude of each
Calspec source in all filters. We minimize the magnitude difference between
the composite TESS magnitude produced by the PS1 filters and the TESS
magnitude across all sources. This gives us the following relation in flux
space for a zeropoint of 25, to match the PS1 image zeropoints:

$\displaystyle
f_{tess}^{PS1}\approx(0.256f_{r}^{PS1}+0.276f_{i}^{PS1}+0.358f_{z}^{PS1}+0.112f_{y}^{PS1})$
$\displaystyle\times\left(\frac{f_{g}^{PS1}}{f_{i}^{PS1}}\right)^{0.001}.$ (1)

Using the same method we can construct an approximation of the TESS filter
with the SkyMapper $griz$ filters to get the following:

$\displaystyle
f_{tess}^{SM}\approx(0.258f_{r}^{SM}+0.353f_{i}^{SM}+0.394f_{z}^{SM})\left(\frac{f_{g}^{SM}}{f_{i}^{SM}}\right)^{-0.002}.$
(2)

Both of these relations provide an excellent approximation for the TESS
filter. As seen in Figure 6, the residuals are consistent with zero at the
mmag level. These relations are weakly dependent on colour, so, although it
was constructed using stellar sources between $-0.5<(g-r)<0.8$, it is reliable
for other stellar sources, though the error will grow.

With these relations we can confidently predict the expected TESS magnitude of
a well behaved stellar source using PS1 & SkyMapper DR1 photometry. This forms
the basis of our calibration method.

Figure 5: Comparisons of the TESS filter overlaid on the Calspec spectra for
HD 2811 alongside the PS1 $grizy$ (top) and the SkyMapper $griz$ (bottom)
filters. It is clear that the PS1 $rizy$ and SM $riz$ completely overlap TESS,
so we can approximate the TESS filter with a combination of PS1 or SM filters.

Figure 6: Residuals of the synthetic and composite TESS magnitudes created
from Calspec sources, shown with the median and errors represented by the
$80^{th}$ and $16^{th}$ percentiles. Both the composite constructions of the
TESS filter with PS1 $grizy$ (top) and SkyMapper $griz$ (bottom) produce
reliable approximations for stellar sources to the mmag level.

###  5.2 Dust extinction

Figure 7: Extinction vector coefficients, $R$, for the PS1 $grizy$ and $TESS$
filters. For larger color ranges the relation becomes non-linear as seen in
Tonry et al. (2012), however, the color range of $-0.5<g-r<0.8$ is sufficient
for the calibration used in TESSreduce. The equations for each fit alongside
the 1$\sigma$ error.

For accurate photometric calibration, we must also account for how dust
extinction impacts TESS photometry. While dust extinction effects an entire
spectrum, the cumulative effect on photometry is that the observed magnitude,
$m_{obs}$, will be changed according to:

$\displaystyle m_{obs}=m_{int}+E(B-V)R_{x},$ (3)

where $m_{int}$ is the intrinsic magnitude, $E(B-V)$ is the ($B$-$V$) colour
excess, and $R_{x}$ total-to-selective extinction in the $x$ filter. While
$R_{x}$ is known for the PS1 filters, we must define it for TESS and the
SkyMapper $griz$ filters. To do this, we follow the derivation used in Tonry
et al. (2012) and adapted in Ridden-Harper et al. (prep) to use synthetic
photometry to determine $R_{x}$.

We derive $R_{x}$ by comparing synthetic magnitudes of normal and reddened
Calspec spectra. We redden the Calspec spectra by applying an extinction of
$E(B-V)=0.01$, with $R_{V}=3.1$ using the Fitzpatrick (1999) dust law through
the extinction package (Barbary, 2016). Next, we calculate the synthetic
magnitude of the reddened Calspec sources in the TESS, PS1 $grizy$, and SM
$griz$ filters. The difference between the normal and reddened magnitudes
gives us the extinction vector coefficient simply by rearranging Equation 3.
As seen in Figure 7 (and Figure 14), $R_{x}$ varies with colour, but is well
described by a straight line. For each filter we fit $R_{x}$ by minimizing the
$\chi^{2}$ with the scipy minimize algorithm. Here we show the TESS $R_{x}$
alongside the SM $griz$ vectors and the PS1 $grizy$ vectors:

$\displaystyle R^{PS1}_{g}=3.624-0.142(g-r)_{\rm int},$ $\displaystyle
R^{PS1}_{r}=2.589-0.053(g-r)_{\rm int},$ $\displaystyle
R^{PS1}_{i}=1.911-0.02(g-r)_{\rm int},$ $\displaystyle
R^{PS1}_{z}=1.502-0.007(g-r)_{\rm int},$ $\displaystyle
R^{PS1}_{y}=1.254-0.005(g-r)_{\rm int},$ $\displaystyle
R^{SM}_{g}=3.435-0.172(g-r)_{\rm int},$ $\displaystyle
R^{SM}_{r}=2.638-0.077(g-r)_{\rm int},$ $\displaystyle
R^{SM}_{i}=1.819-0.02(g-r)_{\rm int},$ $\displaystyle
R^{SM}_{z}=1.383-0.017(g-r)_{\rm int},$ $\displaystyle
R_{tess}=1.902-0.179(g-r)_{\rm int},$ (4)

where $(g-r)_{\rm int}$ is the intrinsic color. With these color vectors we
can both determine and account for extinction within a field anywhere on the
sky.

Since the extinction for each field is different, we must calculate it for
each cutout. We calculate the extinction using stellar locus regression (SLR)
with PS1 and SM photometry. For stars that lie on the stellar locus,
extinctions act by shifting the stellar locus colors according to the
extinction vector coefficients. In TESSreduce, we follow Tonry et al. (2012)
and construct a PS1 and SM canonical stellar loci from synthetic photometry of
the Calspec sources. In $r-i$ and $g-r$ space we then de-redden the observed
PS1/SM magnitudes according to Equation 3. We fit the extinction by minimizing
the distance of all sources to the canonical stellar locus. We limit the
influence of non-stellar/peculiar sources by performing a 3$\sigma$ cut on the
data and refit the extinction.

Since we use all PS1/SM DR1 catalog sources within the TESS image, the stellar
locus is well sampled in all fields. Example fits for dust extinction are
shown in Figure 8. The extinction derived from SLR can then be incorporated
into the construction of the composite TESS magnitudes using the above
extinction vectors to minimize the impact dust extinction has on instrument
calibration.

Figure 8: Stellar Locus Regression (SLR) for stars in the region surrounding
two SN 2020cdj (Top) and SN 2020yzo (Bottom). To calculate $E(B-V)$ we shift
the observed stellar locus according to the coefficients shown in Equation 4
to de-redden sources until they match the model stellar locus. Since SN
2020cdj is in the North we use PS1 photometry, and SM photometry for the
Southern SN 2020yzo.

###  5.3 In-situ zeropoint determination

With the conversion from PS1/SM to TESS magnitudes defined and a method for
accounting for dust extinction, we are able to calculate a precise TESS
zeropoint across the entire sky. To calculate the zeropoint, we only use
stellar sources that satisfy the following strict criteria:

  * •

$-0.5<(g-r)<1$,

  * •

$14<i<17$,

  * •

Isolated.

We make a cut on the source color to exclude red sources for which we have few
Calspec sources. The color and magnitude conditions are determined using the
PS1/SkyMapper DR1 photometry, however, we use the TESS images to determine if
the source is isolated. For each source we apply an annulus aperture, with an
inner and outer radius of 6 and 7 pixels, respectively, to the reference image
and sum all pixels. We calculate the magnitude of annulus aperture using a
default zeropoint of 20.44 and require the annulus magnitude to be at lease 1
magnitude fainter than the TESS magnitude we predict from PS1/SM photometry.
If the annulus magnitude does not meet this condition we count the source as
crowded and neglect it from the TESS photometric calibration. This provides an
easy check to determine if the source is crowded by other nearby bright
sources, that might be ignored by a simple distance measure. An alternative
method would be to use source catalogs to identify separation, however, this
offers its own challenges with adopting a variable separation distance check
for sources based on their magnitudes and will struggle to account for the
contamination of large extended sources, like galaxies. Our calibration method
assumes that the majority of sources within the magnitude range of $14<i<17$
are well contained in a $3\times 3$ pixel aperture, which holds for stellar
sources. Sources that pass this selection are then used in determining the
zeropoint.

With a selection of high quality sources we can reliably determine the TESS
photometric zeropoint. First, we calculate the TESS instrumental magnitude for
all sources via $m_{inst}=-2.5log(C)$, where $C$ is the measured TESS counts.
We then assert that this instrumental magnitude equals the composite TESS
magnitudes constructed from PS1 photometry plus a zeropoint. From this
assertion the zeropoint is found simply as:

$\displaystyle zp=m_{com}+2.5log(C).$ (5)

With this simple equation we can calculate a data driven zeropoint for each
image in the sector. This time series of zeropoints can then be used directly
to provide a post reduction correction to the light curve, or all zeropoints
can be averaged to achieve a high precision zeropoint. In many cases, such as
seen in Figure 9, the zeropoint converges to percent precision.

Generally, we find that the average TESS zeropoint of 20.44 from Vanderspek et
al. (2018) is lower than the zeropoints derived by TESSreduce. While we have
yet to fully explore the nature of the TESS zeropoint, we are confident that
this method produces accurate zeropoints. Ridden-Harper et al. (prep) shows
that this calibration method is consistent with two independent flux
calibration methods for the Kepler broadband filter.

This powerful method allows us to produce reliable flux calibrations for TESS
light curves wherever PS1 or SM photometry is available. In future work, we
will explore how the TESS zeropoint varies between detectors across the entire
focal plane.

Figure 9: Zeropoint diagnostics for the region containing SN 2020cdj, which
achieves a very well defined value. In both figures the black dashed line is
the median, while the black dotted lines are the $16^{th}$ and $80^{th}$
percentiles. These values are also shown on the left panel. Left: Cumulative
distribution of all zeropoint measurements across a sector. Right: Zeropoints
through time for all images in a sector. Generally we find the TESSreduce
zeropoints are well constrained and are larger than the theoretical zeropoint
of 20.44. Therefore, using the theoretical zeropoint will overestimate the
brightness of objects according to TESS. We calculate this zeropoint by
comparing $3\times 3$ pixel aperture photometry of isolated stars with TESS
composite magnitudes derived from PS1 observations. This data driven zeropoint
can be precise and offers a post processing correction to systematics in the
light curves by letting the zeropoint vary with time.

##  6 Reduction pipeline

We developed TESSreduce to be a user-friendly and reliable reduction pipeline
to allow anyone to use TESS data. We have streamlined TESSreduce such that a
user with no knowledge of the intricacies of TESS systematics could extract
light curves. Here we will present the main reduction methods and elaborate on
the pipeline structure.

Due to the sector observing plan, it is often not clear if TESS observed a
given transient. To make it easy to check if observations exist for a certain
target, we have included functions to check if a target was covered by TESS.
For transients with catalog names, the sn_lookup function can be used. This
function utilizes the OSC API to retrieve objects’ coordinates and key times,
such as discovery (disc) and maximum (max) epochs. We then check to see what
sectors the retrieved coordinates were observed by TESS with tess-point (Burke
et al., 2020), and then check to see if the selected time is covered by a TESS
sector, and if not what the time difference is. An example output table output
by the above command is shown in Table 1.

Alternatively, if the object is not in a transient catalog, then the
spacetime_lookup function can be used. For this instance, we compare input
coordinates and time in MJD to tess-point and the sector time list. The output
of both of our observation checking functions can be directly input into
TESSreduce to download and reduce overlapping data. We give an example of the
reduction process using the search functions as inputs in Appendix D.

Generally, TESSreduce can take the following inputs to act on:

  * •

direct input of a TPF,

  * •

RA, Dec. and sector,

  * •

output from the TESSreduce observation lookup functions.

Unless a TPF is directly provided TESSreduce will query TESScut through
Lightkurve functions to obtain the relevant TPF. TESScut restricts the total
size for any downloaded TPF to be $<100$ MB.

In each case, TESSreduce will extract the relevant information needed for data
reduction. Unless the user sets reduce=False in the class, then the data will
automatically be reduced via the difference image pathway, flux calibrated and
aperture photometry performed with a $3\times 3$ pixel square aperture.

Individual steps of the reduction can be disabled. Such steps include image
alignment, photometric calibration, and difference imaging. Any combination of
these options can be enabled or disabled, however, the default option of all
enabled produces the best result. In the complete reduction the process is as
follows:

  * •

Obtain reference image

  * •

Generate an image mask

  * •

Calculate and subtract background

  * •

Calculate spatial shifts for each image, relative to the reference†

  * •

Reset flux to the raw TESS images

  * •

Align images according to the calculated shifts

  * •

Subtract reference image

  * •

Recalculate and subtract background

  * •

Calibrate photometry with field stars†

  * •

Calculate target light curve with aperture photometry†

Key steps in the reduction, marked by $\dagger$, will produce diagnostic plots
if plotting is enabled. These diagnostic plots include Figure 4, Figure 8,
Figure 9 and the final reduction in Figure 10. The final reduction figure
shows the target light curve alongside the local sky light curve on the left
and an example difference image on the right for the frame that contains the
highest flux. These plots are a great quick check for the reduction quality.

Following the reduction of TESS data with TESSreduce, there are additional
functions to aid in the analysis. For example, there are functions to easily
convert from TESS counts to magnitudes or flux. When converting to flux, users
can chose between the following flux units: Jy, mJy, cgs. The TESS zeropoint
is tracked to allow for easy shifts.

For transients that span an entire TESS sector, the reference image will
always include the transient flux, leading to an overall offset in the light
curve, as seen in Figure 1. Therefore, deriving an accurate host subtraction
can be challenging and is one of the limitations of TESSreduce. However,
future work will focus on predicting a TESS scene from ground based data to
construct accurate, host-subtracted images.

Alongside the TESS light curve, TESSreduce also has a simple aggregate for
light curves from other telescopes. Within ground we collect supplementary
light curves from public databases. We access the public ZTF $g$ and $r$ light
curves through the ALeRCE API. This data can easily be compared to the TESS
light curve by using the plotter function. This comparison can provide key
insights into the nature of objects observed by TESS and as a way to verify
the TESS light curve.

For studies of stellar sources, Lightkurve offers key tools in light curve
analysis. To make use of all Lightkurve functions, the TESSreduce light curve
can be converted to the relevant Lightkurve format with a single function that
carries the flux/counts units.

Examples of the analysis steps outlined here can be found on Github for a
SN888https://github.com/CheerfulUser/TESSreduce/blob/master/SN_Example.ipynb
and a variable
star999https://github.com/CheerfulUser/TESSreduce/blob/master/Var_example.ipynb.

Figure 10: Reduction quick look figure produced by the TESSreduce pipeline for
SN 2020yzo, a spectroscopically classified SN II. Left: light curve for SN
2020yzo calculated with aperture photometry and the average sky background.
Right: Difference image of the $90\times 90$ pixel field containing the SN.

##  7 Example light curves

Since TESSreduce is a general forced photometry pipeline, the methods are
applicable to all objects. To demonstrate the versatility of this pipeline, we
show a selection of light curves from a variety of objects in Figure 11. In
the top panel, we show the light curve of GRB 191016a, a bright GRB afterglow
observed by TESS, which was presented in Smith et al. (2021). While such
events are relatively rare, Smith et al. (2021) predicts that TESS should
observe $1-2$ such events each year. TESSreduce is an ideal tool to rapidly
check analyze short and unique transients in TESS data.

Longer duration events, such as dwarf novae, and novae outbursts are also
readily accessible with TESSreduce. Figure 11 (middle) shows a super-outburst
from the SU UMa type dwarf nova SDSS J122740.83+513925.0 in 2019 that was
observed by TESS. From this light curve both the super-hump period and orbital
period can be identified as $P_{1}=0.06464$ d and $P_{orb}=0.06295$ d
respectively. These values are consistent with those presented in Kato et al.
(2012) from the 2007 ($P_{1}=0.064604$ d, $P_{orb}=0.062950$ d) and 2011
($P_{1}=0.064883$ d, $P_{orb}=0.062950$ d) superoutbursts, and may indicate
evolution of the system.

As has been seen already, TESSreduce is capable of supernovae reduction.
Figure 11 (bottom) shows the rise of SN 2020adw, a type Ia supernova,
alongside the public ZTF data. The close comparison to ZTF photometry
showcases the flux calibration method used in TESSreduce, which is also seen
in Figure 1 for SN 2020cdj. From this example, it is also clear that under
ideal circumstances, e.g., well behaved background and minimal crowding, TESS
can provide unparalleled high precision, high cadence light curves for
supernovae at early times, with a detection limit surpassing that of ZTF. Such
data could provide valuable insights into the nature of supernovae.

The examples shown here are just a limited suit of test cases, numerous
targets can already be reduced with the current TESSreduce functions, however,
we welcome community engagement to help build additional functionality to meet
other science goals.

Figure 11: A selection of light curves reduced with and calibrated TESSreduce.
Top: A bright optical afterglow of GRB 191016A, while rare, TESS is expected
to observe 1-2 events each year (Smith et al., 2021). Middle: A super-outburst
of SDSS J122740.83+513925.0, a SU UMa type dwarf nova in 2019, from this data
system parameters such as superhump period can be well constrained. Bottom:
The rise of the type Ia supernova SN 2020adw, alongside the public ZTF data
(Dahiwale & Fremling, 2020). These examples are a tiny fraction of objects
that have been observed by TESS and can be readily reduced with TESSreduce.

##  8 Conclusions

TESS presents an incredibly valuable data set to study the time evolution of
transients and many other time varying phenomena. The high cadence imaging can
capture key moments that could provide essential clues into the progenitors of
supernovae, the nature of fast transients, such as GRBs, RETs, and flare
stars, and offers the exciting possibility of searching for new transients in
the short time domain. Challenges with data reduction generates an entry
barrier to the use of TESS data. These challenges stem primarily from the
highly variable scattered Earth/Moon light background, apparent telescope
motion and flux calibration. Here we have presented the TESSreduce package
which allows for easy TESS data reduction, accounting for the key challenges
with TESS data.

Unlike the other reduction pipelines TESSreduce leverages data from other
observatories. Using the PS1, SkyMapper, and Gaia photometric catalogs, with
accurate and complete photometric catalogs to the depth of TESS, allow us to a
priori construct source masks and estimate the TESS magnitudes of targets.
This approach minimizes biases that arise from including sources in the
background, that other difference imaging methods will encounter. Furthermore,
our approach to accounting for effect of straps is physically motivated,
unlike methods used in existing pipelines.

While TESS can provide precise relative photometry, it must be calibrated to
physical flux to compare against theoretical models and other observations.
Variations of CCD detectors means that a single zeropoint is insufficient to
characterize all TESS data. With ground based $grizy$ photometry we can
reliably predict TESS magnitudes to determine the zeropoint locally based on
field stars. To have robust estimated magnitudes, we account for dust
extinction, and constrain how extinction impacts the TESS filter. With this
novel calibration method, TESSreduce can provide precise zeropoints that agree
well with independently calibrated data.

To reduce complexities in TESS data analysis, we include a number of functions
in TESSreduce that make identifying and using TESS easier. These functions
include observation lookup functions and a way to directly compare to ground
based public ZTF data. These functions make checking for data and comparing
against independent data as simple as a single Python command.

We demonstrate the versatility of TESSreduce by examining a GRB optical
afterglow, dwarf nova superoutburst, and supernovae. These examples only show
a fraction of the variety of variable objects that have been observed by TESS,
and can be reduced with TESSreduce. We have developed TESSreduce to make
reducing TESS data simple, and easy for anyone to use without needing pre-
existing knowledge of TESS data collection and systematic. As TESSreduce is an
open source package, we encourage users to report issues and lodge pull
requests to help improve the capabilities of TESSreduce and the quality of
data reduction.

## Acknowledgments

Software:
numpy (van der Walt et al., 2011), matplotlib (Barrett et al., 2005), pandas
(Reback et al., 2021), scipy (Virtanen et al., 2020),

This research made use of Lightkurve, a Python package for Kepler and TESS
data analysis (Lightkurve Collaboration, 2018). This work has made use of data
from the European Space Agency (ESA) mission Gaia
(https://www.cosmos.esa.int/gaia), processed by the Gaia Data Processing and
Analysis Consortium (DPAC,
https://www.cosmos.esa.int/web/gaia/dpac/consortium). Funding for the DPAC has
been provided by national institutions, in particular the institutions
participating in the Gaia Multilateral Agreement. This research has made use
of the SVO Filter Profile Service (http://svo2.cab.inta-csic.es/theory/fps/)
supported from the Spanish MINECO through grant AYA2017-84089. The material is
based upon work supported by NASA under award number 80GSFC21M0002. TMB was
funded by the CONICYT PFCHA / DOCTORADOBECAS CHILE/2017-72180113.

## Data Availability

All data we make use of is publicly available via MAST, Vizier, ALeRCE, and
the Open Supernova Catalog. This data can be easily retrieved through routines
built into TESSreduce.

## References

  * Abbott et al. (2019) Abbott T. M. C., et al., 2019, ApJ, 872, L30
  * Alard (2000) Alard C., 2000, A&AS, 144, 363
  * Alard & Lupton (1998) Alard C., Lupton R. H., 1998, The Astrophysical Journal, 503, 325
  * Arcavi et al. (2016) Arcavi I., et al., 2016, ApJ, 819, 35
  * Arenou et al. (2018) Arenou F., et al., 2018, A&A, 616, A17
  * Armstrong et al. (2021) Armstrong P., et al., 2021, Monthly Notices of the Royal Astronomical Society
  * Arnett (1982) Arnett W. D., 1982, ApJ, 253, 785
  * Barbary (2016) Barbary K., 2016, Extinction V0.3.0, doi:10.5281/zenodo.804967
  * Barrett et al. (2005) Barrett P., Hunter J., Miller J. T., Hsu J. C., Greenfield P., 2005, in Shopbell P., Britton M., Ebert R., eds, Astronomical Society of the Pacific Conference Series Vol. 347, Astronomical Data Analysis Software and Systems XIV. p. 91
  * Betoule et al. (2014) Betoule M., et al., 2014, A&A, 568, A22
  * Bloom et al. (2012) Bloom J. S., et al., 2012, ApJ, 744, L17
  * Bohlin et al. (2014) Bohlin R. C., Gordon K. D., Tremblay P. E., 2014, PASP, 126, 711
  * Bohlin et al. (2020) Bohlin R. C., Hubeny I., Rauch T., 2020, AJ, 160, 21
  * Bouma et al. (2019) Bouma L. G., Hartman J. D., Bhatti W., Winn J. N., Bakos G. Á., 2019, ApJS, 245, 13
  * Bradley et al. (2020) Bradley L., et al., 2020, astropy/photutils: 1.0.0, doi:10.5281/zenodo.4044744, https://doi.org/10.5281/zenodo.4044744
  * Brasseur et al. (2019) Brasseur C. E., Phillip C., Fleming S. W., Mullally S. E., White R. L., 2019, Astrocut: Tools for creating cutouts of TESS images (ascl:1905.007)
  * Burke et al. (2020) Burke C. J., et al., 2020, TESS-Point: High precision TESS pointing tool, Astrophysics Source Code Library (ascl:2003.001)
  * Chambers et al. (2016) Chambers K. C., et al., 2016, arXiv e-prints, p. arXiv:1612.05560
  * Coppejans et al. (2020) Coppejans D. L., et al., 2020, ApJ, 895, L23
  * Dahiwale & Fremling (2020) Dahiwale A., Fremling C., 2020, Transient Name Server Classification Report, 2020-412, 1
  * Dimitriadis et al. (2019) Dimitriadis G., et al., 2019, ApJ, 870, L1
  * Drout et al. (2014) Drout M. R., et al., 2014, ApJ, 794, 23
  * Fausnaugh et al. (2019) Fausnaugh M. M., et al., 2019, arXiv e-prints, p. arXiv:1904.02171
  * Feinstein et al. (2019) Feinstein A. D., et al., 2019, PASP, 131, 094502
  * Firth et al. (2015) Firth R. E., et al., 2015, MNRAS, 446, 3895
  * Fitzpatrick (1999) Fitzpatrick E. L., 1999, PASP, 111, 63
  * Foley et al. (2010) Foley R. J., Brown P. J., Rest A., Challis P. J., Kirshner R. P., Wood-Vasey W. M., 2010, ApJ, 708, L61
  * Förster et al. (2021) Förster F., et al., 2021, AJ, 161, 242
  * Gaia Collaboration et al. (2016) Gaia Collaboration et al., 2016, A&A, 595, A1
  * Gaia Collaboration et al. (2018) Gaia Collaboration et al., 2018, A&A, 616, A1
  * Garnavich et al. (2016) Garnavich P. M., Tucker B. E., Rest A., Shaya E. J., Olling R. P., Kasen D., Villar A., 2016, ApJ, 820, 23
  * Ginsburg et al. (2017) Ginsburg A., et al., 2017, Astroquery: Access to online data resources (ascl:1708.004)
  * Guillochon et al. (2017) Guillochon J., Parrent J., Kelley L. Z., Margutti R., 2017, ApJ, 835, 64
  * Hayden et al. (2010) Hayden B. T., et al., 2010, ApJ, 712, 350
  * Hillebrandt & Niemeyer (2000) Hillebrandt W., Niemeyer J. C., 2000, ARA&A, 38, 191
  * Ho et al. (2019) Ho A. Y. Q., et al., 2019, ApJ, 871, 73
  * Ho et al. (2020) Ho A. Y. Q., et al., 2020, ApJ, 895, 49
  * Hoeflich et al. (1996) Hoeflich P., Khokhlov A., Wheeler J. C., Phillips M. M., Suntzeff N. B., Hamuy M., 1996, The Astrophysical Journal, 472, L81
  * Holoien et al. (2019) Holoien T. W. S., et al., 2019, ApJ, 883, 111
  * Holwerda et al. (2021) Holwerda B. W., Knabel S., Steele R. C., Strolger L., Kielkopf J., Jacques A., Roemer W., 2021, MNRAS,
  * Hoyle & Fowler (1960) Hoyle F., Fowler W. A., 1960, ApJ, 132, 565
  * Kato et al. (2012) Kato T., et al., 2012, Publications of the Astronomical Society of Japan, 64
  * Keller et al. (2007) Keller S. C., et al., 2007, Publ. Astron. Soc. Australia, 24, 1
  * Li et al. (2019) Li W., et al., 2019, ApJ, 870, 12
  * Lightkurve Collaboration et al. (2018) Lightkurve Collaboration et al., 2018, Lightkurve: Kepler and TESS time series analysis in Python, Astrophysics Source Code Library (ascl:1812.013)
  * Maoz et al. (2014) Maoz D., Mannucci F., Nelemans G., 2014, ARA&A, 52, 107
  * Margutti et al. (2019) Margutti R., et al., 2019, ApJ, 872, 18
  * Miller et al. (2008) Miller J. P., Pennypacker C. R., White G. L., 2008, PASP, 120, 449
  * Miller et al. (2020) Miller A. A., et al., 2020, ApJ, 902, 47
  * Narayan et al. (2019) Narayan G., et al., 2019, ApJS, 241, 20
  * Nomoto et al. (1984) Nomoto K., Thielemann F. K., Yokoi K., 1984, ApJ, 286, 644
  * Nugent et al. (2011) Nugent P. E., et al., 2011, Nature, 480, 344
  * Oelkers & Stassun (2018) Oelkers R. J., Stassun K. G., 2018, AJ, 156, 132
  * Olling et al. (2015) Olling R. P., et al., 2015, Nature, 521, 332
  * Payne et al. (2021) Payne A. V., et al., 2021, ApJ, 910, 125
  * Perley et al. (2019) Perley D. A., et al., 2019, MNRAS, 484, 1031
  * Perley et al. (2020) Perley D. A., et al., 2020, ApJ, 904, 35
  * Perlmutter et al. (1999) Perlmutter S., et al., 1999, ApJ, 517, 565
  * Piro (2012) Piro A. L., 2012, ApJ, 759, 83
  * Polin et al. (2019) Polin A., Nugent P., Kasen D., 2019, ApJ, 873, 84
  * Prentice et al. (2018) Prentice S. J., et al., 2018, ApJ, 865, L3
  * Pursiainen et al. (2018) Pursiainen M., et al., 2018, MNRAS, 481, 894
  * Reback et al. (2021) Reback J., et al., 2021, pandas-dev/pandas: Pandas 1.3.0, doi:10.5281/zenodo.3509134
  * Rest et al. (2018) Rest A., et al., 2018, Nature Astronomy, 2, 307
  * Ricker et al. (2015) Ricker G. R., et al., 2015, Journal of Astronomical Telescopes, Instruments, and Systems, 1, 014003
  * Ridden-Harper et al. (2019) Ridden-Harper R., et al., 2019, MNRAS, 490, 5551
  * Ridden-Harper et al. (2020) Ridden-Harper R., Tucker B. E., Gully-Santiago M., Barentsen G., Rest A., Garnavich P., Shaya E., 2020, MNRAS, 498, 33
  * Ridden-Harper et al. (2021) Ridden-Harper R., Bannister M. T., Kokotanekova R., 2021, Research Notes of the AAS, 5, 161
  * Ridden-Harper et al. (prep) Ridden-Harper R., Rest A., Wang Q., Ashley Villar G. D., in prep.
  * Riess et al. (1998) Riess A. G., et al., 1998, The Astronomical Journal, 116, 1009
  * Rodrigo & Solano (2020) Rodrigo C., Solano E., 2020, in Contributions to the XIV.0 Scientific Meeting (virtual) of the Spanish Astronomical Society. p. 182
  * Rodrigo et al. (2012) Rodrigo C., Solano E., Bayo A., 2012, SVO Filter Profile Service Version 1.0, IVOA Working Draft 15 October 2012, doi:10.5479/ADS/bib/2012ivoa.rept.1015R
  * Schlafly et al. (2012) Schlafly E. F., et al., 2012, ApJ, 756, 158
  * Scolnic et al. (2015) Scolnic D., et al., 2015, ApJ, 815, 117
  * Scolnic et al. (2018) Scolnic D. M., et al., 2018, ApJ, 859, 101
  * Shappee et al. (2019) Shappee B. J., et al., 2019, ApJ, 870, 13
  * Smith et al. (2021) Smith K. L., et al., 2021, The Astrophysical Journal, 911, 43
  * Stassun et al. (2019) Stassun K. G., et al., 2019, AJ, 158, 138
  * Tonry et al. (2012) Tonry J. L., et al., 2012, ApJ, 750, 99
  * Vallely et al. (2019) Vallely P. J., et al., 2019, MNRAS, 487, 2372
  * Vallely et al. (2021) Vallely P. J., Kochanek C. S., Stanek K. Z., Fausnaugh M., Shappee B. J., 2021, MNRAS, 500, 5639
  * Vanderspek et al. (2018) Vanderspek R., Doty J., Fausnaugh M., Villaseñor J., Jenkins J., Berta-Thompson Z., Burke C., Ricker G., 2018, Technical report, TESS Instrument Handbook. Kavli Institute for Astrophysics and Space Science, Massachusetts Institute of Technology.
  * Virtanen et al. (2020) Virtanen P., et al., 2020, Nature Methods, 17, 261
  * Wang et al. (2021) Wang Q., et al., 2021, arXiv e-prints, p. arXiv:2108.13607
  * Wolf et al. (2018) Wolf C., et al., 2018, Publ. Astron. Soc. Australia, 35, e010
  * Woods et al. (2021) Woods D. F., et al., 2021, PASP, 133, 014503
  * Woosley et al. (1986) Woosley S. E., Taam R. E., Weaver T. A., 1986, ApJ, 301, 601
  * van der Walt et al. (2011) van der Walt S., Colbert S. C., Varoquaux G., 2011, Computing in Science and Engineering, 13, 22

##  Appendix A Image alignment vs. Delta kernels

One key difference between TESSreduce and other difference imaging pipelines
is that TESSreduce does not perform kernel matching. While necessary for
ground based telescopes which suffer from large PSF variations between
observations, TESS has a relatively stable PSF, and therefore PRF. Other
pipelines such as ISIS based pipelines and the DIA pipeline use kernel
matching with Delta kernels, otherwise known as discrete kernels, to correct
for image alignment and any small changes in the PRF. As described in Miller
et al. (2008) a Delta kernel, $K$, is constructed from an orthogonal basis of
vectors $K_{n}$ as follows:

$\displaystyle K=\sum_{n=1}^{N}a_{n}K_{n},$ (6)

where $a_{n}$ is the vector coefficient. In principle any given TESS image
should be related to another image through a convolution with an appropriate
Delta kernel.

Normally the coefficients to the basis which constructs the Delta kernel are
derived by simultaneously fitting to a collection of isolated stars across the
detector, however, with the relatively small cutout used by TESSreduce we
instead fit the coefficients by minimising the difference between two images.
Following a similar process to how we derive the image shifts, we first
calculate and subtract the background from every image. With these background
subtracted images we then use the scipy minimize algorithm to minimize the
absolute difference in counts between a given image and a reference image
convolved with a $7\times 7$ pixel kernel using the scipy fftconvolve
algorithm. To avoid edge effects we ignore the boundary up to 7 pixels in the
minimization. This process yields a time series of Delta kernels that when
convolved with the reference image give the best fit to the data. To generate
a difference image, we subtract the convolved reference image from each frame,
with which we then calculate and subtract the background.

With this process we now have a kernel matched difference image that we can
compare to the image alignment method. As seen in Figure 12 we test the two
methods on a TESS FFI cutout centered on SN 2020fqv. In this field there are
numerous stellar sources, and a large central galaxy, which contains SN
2020fqv (Left). We find that the image alignment method produces more reliable
subtractions (Middle) than the kernel matching method (Right). Furthermore,
the kernel matching method uses significantly more compute time ($\gtrsim
5\times$) than the image alignment method. From this analysis we conclude that
image alignment is the best method for TESSreduce.

Figure 12: Comparison of subtraction methods for a $90\times 90$ pixel FFI
cutout centered on SN 2020fqv. This is a good test case since the host galaxy
is resolved in TESS, so correct alignment is crucial. Left: Background
subtracted image. Middle: Difference image created by the TESSreduce image
alignment, all sources are well subtracted and the SN is clearly visible.
Right: Difference image created by kernel matching, while many sources are
subtracted the kernel is not well defined from this data set, leaving
significant residuals around the SN. Clearly for cutouts such as those used by
TESSreduce, image shifting is the better approach. All images are on the same
colour scale which spans $-10$ to $+10$ counts.

##  Appendix B Comparing TESS to Gaia G

While Gaia G does cover similar wavelengths to TESS, it extends to notably
shorter wavelengths. The difference can be sen in Figure 13. This large
difference will introduce a strong color dependency in the mapping form Gaia
to TESS magnitudes. By using PS1 and SM color photometry to reconstruct the
TESS filter, we can achieve a much closer approximation of the true TESS
magnitude and account for any residual color terms.

Figure 13: The Gaia $G$ and TESS filters overlaid on the Calspec spectra for
HD 2811. While Gaia $G$ overlaps with most of the TESS filter, it also extends
to much shorter wavelengths, making it unreliable for calibrating TESS
photometry against.

##  Appendix C SkyMapper dust extinction vector coefficients

Following the process described in subsection 5.2 we construct the color
dependent extinction vector coefficients for the SkyMapper $griz$ filters. The
fits to the data can be seen in Figure 14.

Figure 14: Extinction vector coefficients, $R$, for the SkyMapper $griz$
filters. The construction of these coefficients follows the same process used
for the PS1 and TESS filters. The equations for each fit alongside the
1$\sigma$ error.

##  Appendix D Example reduction

In this section we have an example reduction for SN 2020cdj, as seen in Figure
1. To check that a target has been observed by TESS, the sn_lookup function
can be used to provide a quick check. This function produces a table as shown
in Table 1, and the output of this function can be used as an input for
TESSreduce.

Table 1: Example of the table output by sn_lookup() for discovery time of SN 2020cdj. Sectors before 17 and after 25 are excluded here for brevity. Sector | Covers | Time difference
---|---|---
|  | (days)
17 | False | -98
18 | False | -73
20 | False | -18
21 | True | 0
22 | False | 10
23 | False | 39
24 | False | 68
25 | False | 95

        import tessreduce as tr
        obs = tr.sn_lookup(’sn2020cdj’)
        tess = tr.tessreduce(obs_list=obs)
        tess.to_flux()
        tess.plotter(ground=True)

With these few lines of code TESSreduce will download the TESS data, reduce
and calibrate the data, then plot it alongside the public ZTF light curves.
The final plotter command will produce a figure similar to the right panel of
Figure 1.

If the object is not a transient listed on the OSC, then overlapping
observation can be found by using the spacetime_lookup() function. This
function takes arguments of R.A. Dec. and time in MJD. If a TPF is already
downloaded, the TPF can be input directly as tr.tessreduce(tpf=FILE).

Following the reduction, difference imaged lightcurves can be produced at any
position in the image with tess.diff_lc(), where the inputs are the $x$, and
$y$ pixel positions of the aperture center. To analyse the lightcurve using
the extensive tools made available with the Lightkurve package, then the
output lightcurve can be converted the a LightCurve object with
tess.to_lightkurve().

Further information can be found in the
docs101010https://tessreduce.readthedocs.io/en/latest/, and example reductions
for a
supernova111111https://github.com/CheerfulUser/TESSreduce/blob/master/SN_Example.ipynb
and a variable
star121212https://github.com/CheerfulUser/TESSreduce/blob/master/Var_example.ipynb
can be found on the Github.