Scope Math

Mathematical functions for simulating light curves.

scope.scopemath.Gauss2D(x, y, amp, x0, y0, sx, sy, rho)

A two-dimensional gaussian with arbitrary covariance.

class scope.scopemath.GaussInt(a, b, c)

Returns the definite integral of x^n * exp(-ax^2 + bx + c) from 0 to 1.

scope.scopemath.PLD(fpix, ferr, trninds, t, aperture)

Perform first order PLD on a light curve

flux :

detrended light curve

rawflux :

raw light curve

scope.scopemath.PSF(A, psf_args, ccd_args, xpos, ypos)

Computes a stellar Point Spread Function (PSF) from given parameters.

psf_argsdict

dictionary of PSF parameters

ccd_argsdict

dictionary of CCD parameters

xposarraylike

array of PSF motion in x around detector relative to (x_0, y_0)

yposarraylike

array of PSF motion in y around detector relative to (x_0, y_0)

scope.scopemath.PixelFlux(cx, cy, amp, x0, y0, sx, sy, rho, fast=True, **kwargs)

The flux in a given pixel of the detector, calculated from the integral of the convolution of a 2D gaussian with a polynomial.

cx:

The intra-pixel variability polynomial coefficients along the x axis, expressed as a list from 0th to 3rd order.

cy:

The intra-pixel variability polynomial coefficients along the y axis, expressed as a list from 0th to 3rd order.

amp:

The amplitude of the normalized gaussian (the integral of the gaussian over the entire xy plane is equal to this value).

x0:

The x position of the center of the gaussian relative to the left pixel edge.

y0:

The y position of the center of the gaussian relative to the bottom pixel edge.

sx:

The standard deviation of the gaussian in the x direction (before rotation).

sy:

The standard deviation of the gaussian in the y direction (before rotation).

rho:

The correlation coefficient between x and y, a value between -1 and 1. See en.wikipedia.org/wiki/Pearson_correlation_coefficient. If this is 0, x and y are uncorrelated (zero rotation).

fast:

If True, analytically integrates the function along the x axis and numerically integrates it along the y axis. This can greatly speed things up, with no loss of accuracy. If False, numerically integrates in both dimensions (not recommended).

scope.scopemath.PolyGaussIntegrand1D(y, cx, cy, amp, x0, y0, sx, sy, rho)

This is the product of the 2D Gaussian PSF, a polynomial in y, and a polynomial in x, analytically integrated along x. The integral along y is not analytic and must be done numerically. However, the analytical integration along the first dimension speeds up the entire calculation by a factor of ~20.

scope.scopemath.PolyGaussIntegrand2D(x, y, cx, cy, amp, x0, y0, sx, sy, rho)

This is straight up the product of the 2D Gaussian PSF, a polynomial in y, and a polynomial in x, at a given location on the pixel. Integrating this in 2D across the entire pixel yields the total flux in that pixel.

scope.scopemath.Polynomial(x, coeffs)

Returns a polynomial with coefficients coeffs evaluated at x.

scope.scopemath.TestIntegration()

Compares the fast and slow ways of computing the flux. Reports the time each method took and the difference in the flux between the two methods.