Skip to content

src/core/k2.js ​

text
K2 systematics: the spacecraft rolls about its boresight under solar pressure and the thrusters fire every 6 h to
bring it back, so the star slides along an arc on the detector and the flux follows the pixel response.
Two corrections are offered besides the self-flat-field (photometry.js sffDetrend):
  thrusterFlags  the cadences of a thruster firing, from QUALITY bits 20 and 21 and from jumps of the centroid
                 along the roll arc (Vanderburg & Johnson 2014 drop them before the fit).
  pldCorrect     pixel-level decorrelation as EVEREST (Luger et al. 2016, 2018) and lightkurve's PLDCorrector do it:
                 the fractional pixel fluxes, their products up to `order` (principal components at each order),
                 principal components of the background pixels, and a B-spline in time for the star itself, fitted
                 together by least squares with Gaussian priors on the coefficients and iterative 5σ clipping; the
                 pixel and background parts are removed, the spline (stellar variability, the transits' context) is
                 kept. Transits are masked out of the fit with `cadenceMask`.
No DOM; checked against lightkurve 2.6 in test/k2.test.mjs (reference: test/make_lightkurve_reference.py).

Import: import { … } from './src/core/k2.js' — no DOM, runs in Node and the browser.

thrusterFlags ​

js
function thrusterFlags(time, x, y, quality = null, opts = {})

Flag thruster firings. From QUALITY (bits 1048576 and 524288 when quality is given) and from the centroid: the position along the roll (arclength: the first principal axis of the centroids in windows of windowDays) moves slowly and jumps back when the thrusters fire; a step |Δs − median| larger than sigma robust standard deviations (1.4826 MAD of the steps) marks the cadence after the jump.

  • returns { flags: Uint8Array (1 = firing), fromQuality, fromCentroid, both, steps (Float64Array of Δs) }

arclength ​

js
function arclength(time, x, y, good, windowDays = 6)

Position along the first principal axis of the centroids, window by window (as photometry.js sffDetrend).

pcaColumns ​

js
function pcaColumns(cols, k, opts = {})

Columns (Float64Array each, length n) → their leading k principal components: U (left singular vectors of the centred matrix), as fbpca.pca returns.

splineBasis ​

js
function splineBasis(x, df, degree = 3)

B-spline basis of degree degree with df columns over x (patsy bs(x, df, degree, include_intercept=True), as lightkurve's create_spline_matrix): interior knots at quantiles of x, boundary knots at its ends.

pldCorrect ​

js
function pldCorrect(pix, flux, err, time, opts = {})

Pixel-level decorrelation of a target pixel file's light curve (EVEREST / lightkurve PLDCorrector).

  • param pix array of series of the pixels in the PLD aperture (background-subtracted fluxes), each over the cadences used
  • param flux the aperture flux over the same cadences (sum of the aperture's pixels), err its uncertainty
  • param time times (days)
  • param opts { order = 3 (K2) , ncomp = 16 (principal components per order and of the background), bkg: array of background-pixel series (optional; normalised by their sum as lightkurve does for K2), knots: spline columns (default n / 50), degree = 5 (lightkurve's correct() default), cadenceMask: Uint8Array, 1 = use in the fit (transits 0), sigma = 5, niters = 5, priorScale = 10, restoreTrend = true }
  • returns { corrected, model (pixel + background part, median removed), spline (median removed), coefficients, used: count of cadences in the final fit, clipped, ncols, names }

MIT licensed · Kyle A. Pearson