Documentation for PerturbationMatrix3D
Class to handle 3D perturbation matrices in PSFMachine
Parameters:
Name | Type | Description | Default |
---|---|---|---|
time |
np.ndarray |
Array of time values |
required |
dx |
np.ndarray |
Pixel positions in x separation from source center |
required |
dy |
np.ndaray |
Pixel positions in y separation from source center |
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' |
nknots |
int |
Number of knots for the cartesian spline |
required |
radius |
float |
Radius out to which to calculate the cartesian spline |
required |
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 |
required |
bin_method |
str |
How to bin the data under the hood. Default is by mean binning. |
'by' |
focus_exptime |
float |
Time for the exponent for focus change, if used |
required |
degree |
int |
Polynomial degree used to build the row/column cartesian design matrix |
required |
knot_spacing_type |
str |
Type of spacing bewtwen knots used for cartesian design matrix, options are {"linear", "sqrt"} |
required |
fit(self, flux, flux_err=None, pixel_mask=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 x npixels. |
required |
flux_err |
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 x npixels. |
None |
pixel_mask |
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]]] |
Pixel mask to apply. Values that are |
None |
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 |
pca(self, y, ncomponents=3, 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 |
n_components |
int |
Number of components to take |
required |
smooth_time_scale |
float |
Amount to smooth the components, using a spline in time. If 0, the components will not be smoothed. |
0 |
plot_model(self, time_index=0)
Plot perturbation model
Parameters:
Name | Type | Description | Default |
---|---|---|---|
time_index |
int |
Time index to plot the perturbed model |
0 |