functions
TheCannon.expanded_size — Functionexpandeded_size(nlabels; quadratic=true)The length of a label vector of length nlabels after it has been quadratically expanded.
See also: collapsed_size
TheCannon.collapsed_size — Functioncollapsed_size(nelabels; quadratic=true)The length of a label vector corresponding to an expanded label vector of length nelabels.
See also: expanded_size
TheCannon.expand_labels — Functionexpand_labels(labels; quadratic=true)If labels is a Vector, return it's quadratic (or linear) expansion. If labels is a Matrix, return the matrix whose rows are expansions of the rows of labels.
This is the transformation referred to as $\eta$ in Wheeler+ 2020, and as the "vectorizing function" in Casey+ 2016.
TheCannon.standardize_labels — FunctionStandardize the label matrix (nstars x nlabels) to live roughly in [-1, 1] by subtractive the mean and dividing by the scatter. returns (standardized_labels, pivots, scales)
TheCannon.unstandardize_labels — FunctionTransform labels back to their unstandardize form. Returns
labels.*transpose(hcat(scale)) .+ transpose(hcat(pivot))
TheCannon.train — Functiontrain(flux, ivar, labels, mask=nothing, verbose=true, quadratic=true)returns: theta, scatters Run the training step of The Cannon, i.e. calculate coefficients for each pixel.
fluxcontains the spectra for each star in the training set. It should benstars x npixels(row-vectors are spectra)ivarcontains the inverse variance for each pixel in the same shape asfluxlabelscontains the labels for each star. It should benstars x nlabels. It will be expanded into the quadratic label space before training.mask(optional) is anlabels x npixmatrix of booleans specifying which labels are "allowed" to affect the spectrum at each pixel.
returns:
theta: the matrix containing the cannon coefficients. It will ben_expanded_labels x npixscatters: the model scatter at each pixel
TheCannon.infer — Functioninfer(flux, ivar, theta, scatters; quadratic=true, verbose=true)
Run the test step of the cannon. Given theta and scatters (from training), infer stellar parameters.
fluxcontains the spectra for each star for which you want to infer labels
in the training set. It should be nstars x npixels (row-vectors are spectra)
ivarcontains the inverse variance for each pixel in the same shape asfluxtheta: the matrix containing the cannon coefficients. It will ben_expanded_labels x npixscatters: the model scatter at each pixel
If verbose is set to true, gives an update for every 100 stars processed.
TheCannon.quad_coeff_matrix — FunctionGet the quadratic terms of theta as symetric matrices. returns an array of dimensions nlabels x nlabels x npixels
Q = quad_coeff_matrix(theta)
Q[:, :, 1] #quadratic coefficients for first pixel