Skip to content

Documentation for ScatteredLightBackground

scatterbrain.background.ScatteredLightBackground

Class for working with TESS data to fit and use scattered background models.

ScatteredLightBackground will automatically set up a reasonable background model for you. If you want to tweak the model, check out the design_matrix API.

__getitem__(self, key) special

Set indexing

__init__(self, sector, camera, ccd, column=None, row=None, sigma_f=None, nknots=50, cutout_size=2048, tstart=None, tstop=None, quality=None, verbose=False, njitter=10000, strap_npoly=2) special

Initialize a ScatteredLightBackground object either for fitting or loading a model.

Parameters:

Name Type Description Default
sector int

Sector number

required
camera int

Camera number

required
ccd int

CCD number

required
column None or xp.ndarray

The column numbers to evaluate the design matrix at. If None, uses all pixels.

None
row None or xp.ndarray

The column numbers to evaluate the design matrix at. If None, uses all pixels.

None
sigma_f xp.ndarray

The weights for each pixel in the design matrix. Default is equal weights.

None
nknots int

Number of knots to for spline matrix

50
cutout_size int

Size of a "cutout" of images to use. Default is 2048. Use a smaller cut out to test functionality

2048

clean(self)

Resets the weights and average frame

fit_model(self, flux_cube, tstart=None, batch_size=50, test_frame=0, mask_asteroids=False)

Fit a model to a flux cube, fitting frames in batches of size batch_size.

This will append to the list properties self.weights_basic, self.weights_full, self.jitter.

Parameters:

Name Type Description Default
flux_cube xp.ndarray

3D array of frames.

required
tstart np.ndarray

Times for each frame. Required if masking asteroids.

None
batch_size int

Number of frames to fit at once.

50
test_frame int

The index of the frame to use as the "reference frame". This reference frame will be used to build masks to set sigma_f. It should be the lowest background frame.

0

from_tess_images(fnames, mask_asteroids=True, batch_size=50, test_frame=None, cutout_size=2048, sector=None, camera=None, ccd=None, verbose=False, quality_bitmask=175, njitter=5000) staticmethod

Creates a ScatteredLightBackground model from filenames

Parameters:

Name Type Description Default
fnames list

List of filenames to compute the background model for

required
batch_size int

Number of files to process in a given batch

50
test_frame None or int

The frame to use as a "test" frame for building masks. If None, a reasonable frame will be chosen.

None

Returns:

Type Description
`scatterbrain.ScatteredLightBackground.ScatteredLightBackground`

ScatteredLightBackground object

load(self, input, dir=None)

Load a model fit to the tess-backrop data directory.

Parameters:

Name Type Description Default
input tuple or string

Either pass a tuple with (sector, camera, ccd) or pass a file name in dir to load

required
dir str

Optional tring with the directory name

None

model(self, time_index=None)

Build a model for a frame with index time_index

save(self, output_dir=None, overwrite=False)

Save a model fit to the scatterbrain data directory.