Skip to content

Documentation for PerturbationMatrix

Class to handle perturbation matrices in PSFMachine

Parameters:

Name Type Description Default
time np.ndarray

Array of time values

required
other_vectors list or np.ndarray

Other detrending vectors (e.g. centroids)

required
poly_order int

Polynomial order to use for detrending, default 3

'3'
focus bool

Whether to correct focus using a simple exponent model

required
segments bool

Whether to fit portions of data where there is a significant time break as separate segments

required
resolution int

How many cadences to bin down via bin_method

required
bin_method str

How to bin the data under the hood. Default is by mean binning. Options are 'downsample' and 'bin'

'by'
focus_exptime float

Time for the exponent for focus change, if used

required

bin_func(self, var, **kwargs)

Bins down an input variable to the same time resolution as self

Parameters:

Name Type Description Default
var npt.ArrayLike

Array of values with at least 1 dimension. The first dimension must be the same shape as self.time

required

Returns:

Type Description
object

An object function according to self.bin_method

fit(self, flux, flux_err=None)

Fits flux to find the best fit model weights. Optionally will include flux errors.

Sets the self.weights attribute with best fit weights.

Parameters:

Name Type Description Default
flux Union[numpy.__array_like._SupportsArray[numpy.dtype], numpy.__nested_sequence._NestedSequence[numpy.__array_like._SupportsArray[numpy.dtype]], bool, int, float, complex, str, bytes, numpy.__nested_sequence._NestedSequence[Union[bool, int, float, complex, str, bytes]]]

Array of flux values. Should have shape ntimes.

required
flux Union[numpy.__array_like._SupportsArray[numpy.dtype], numpy.__nested_sequence._NestedSequence[numpy.__array_like._SupportsArray[numpy.dtype]], bool, int, float, complex, str, bytes, numpy.__nested_sequence._NestedSequence[Union[bool, int, float, complex, str, bytes]]]

Optional flux errors. Should have shape ntimes.

required

Returns:

Type Description
npt.ArrayLike

Array with computed weights

model(self, time_indices=None)

Returns the best fit model at given time_indices.

Parameters:

Name Type Description Default
time_indices Optional[list]

Optionally pass a list of integers. Model will be evaluated at those indices.

None

Returns:

Type Description
npt.ArrayLike

Array of values with the same shape as the flux used in self.fit

pca(self, y, ncomponents=5, smooth_time_scale=0)

Adds the first ncomponents principal components of y to the design

matrix. y is smoothen with a spline function and scale smooth_time_scale.

Parameters:

Name Type Description Default
y np.ndarray

Input flux array to take PCA of.

required
ncomponents int

Number of principal components to use

5
smooth_time_scale float

Amount to smooth the components, using a spline in time. If 0, the components will not be smoothed.

0

plot(self)

Plot basis vectors