astra.contrib.thecannon.vectorizer.polynomial

A polynomial vectorizer for The Cannon.

Module Contents

Classes

PolynomialVectorizer A vectorizer that models spectral fluxes as combination of polynomial terms.
class astra.contrib.thecannon.vectorizer.polynomial.PolynomialVectorizer(label_names=None, order=None, terms=None, **kwargs)

A vectorizer that models spectral fluxes as combination of polynomial terms. Note that either label_names and order must be provided, or the terms keyword argument needs to be explicitly specified.

Parameters:
  • label_names – [optional] A list of label names that are terms in the label vector.
  • order – [optional] The maximal order for the vectorizer.
  • terms – [optional] A structured list of tuples that defines the full extent of the label vector. Note that terms must be None if label_names or order are provided.
human_readable_label_vector

Return a human-readable form of the label vector.

terms

Return the terms provided for this vectorizer.

label_names

Return the label names that are used in this vectorizer.

get_label_vector(self, labels)

Return the values of the label vector, given the scaled labels.

Parameters:labels – The scaled and offset labels to use to calculate the label vector(s). This can be a ond-dimensional vector of K labels, or a two-dimensional array of N by K labels.
get_label_vector_derivative(self, labels)

Return the derivatives of the label vector with respect to fluxes.

Parameters:labels – The scaled labels to calculate the label vector derivatives. This can be a one-dimensional vector of K labels (using the same order and length provided by self.label_names), or a two-dimensional array of N by K values. The returning array will be of shape (N, D), where D is the number of terms in the label vector description.
get_human_readable_label_vector(self, mul='*', pow='^', bracket=False)

Return a human-readable form of the label vector.

Parameters:
  • mul – [optional] String to use to represent a multiplication operator. For example, if giving LaTeX label definitions one may want to use ‘cdot’ for the mul term.
  • pow – [optional] String to use to represent a power operator.
  • bracket – [optional] Show brackets around each term.
Returns:

A human-readable string representing the label vector.

get_human_readable_label_term(self, term_index, label_names=None, **kwargs)

Return a human-readable form of a single term in the label vector.

Parameters:
  • term_index – The term in the label vector to return.
  • label_names – [optional] The label names to use. For example, these could be LaTeX representations of the label names.
Returns:

A human-readable string representing a single term in the label vector.

__str__(self)

Return str(self).

__repr__(self)

Return repr(self).

__getstate__(self)

Return the state of the vectorizer.

__setstate__(self, state)

Set the state of the vectorizer.

__call__(self, *args, **kwargs)

An alias to the get_label_vector method.