draco.analysis.svdfilter

A set of tasks for SVD filtering the m-modes.

Functions

svd_em(A, mask[, niter, rank, full_matrices])

Perform an SVD with missing entries using Expectation-Maximisation.

Classes

SVDFilter()

SVD filter the m-modes to remove the most correlated components.

SVDSpectrumEstimator()

Calculate the SVD spectrum of a set of m-modes.

class draco.analysis.svdfilter.SVDFilter[source]

Bases: SingleTask

SVD filter the m-modes to remove the most correlated components.

niter

Number of iterations of EM to perform.

Type:

int

local_threshold

Cut out modes with singular value higher than local_threshold times the largest mode on each m.

Type:

float

global_threshold

Remove modes with singular value higher than global_threshold times the largest mode on any m

Type:

float

Initialize pipeline task.

May be overridden with no arguments. Will be called after any config.Property attributes are set and after ‘input’ and ‘requires’ keys are set up.

process(mmodes)[source]

Filter MModes using an SVD.

Parameters:

mmodes (container.MModes) – MModes to process

Returns:

mmodes

Return type:

container.MModes

class draco.analysis.svdfilter.SVDSpectrumEstimator[source]

Bases: SingleTask

Calculate the SVD spectrum of a set of m-modes.

niter

Number of iterations of EM to perform.

Type:

int

Initialize pipeline task.

May be overridden with no arguments. Will be called after any config.Property attributes are set and after ‘input’ and ‘requires’ keys are set up.

process(mmodes)[source]

Calculate the spectrum.

Parameters:

mmodes (containers.MModes) – MModes to find the spectrum of.

Returns:

spectrum

Return type:

containers.SVDSpectrum

draco.analysis.svdfilter.svd_em(A, mask, niter=5, rank=5, full_matrices=False)[source]

Perform an SVD with missing entries using Expectation-Maximisation.

This assumes that the matrix is well approximated by only a few modes in order fill the missing entries. This is probably not a proper EM scheme, but is not far off.

Parameters:
  • A (np.ndarray) – Matrix to SVD.

  • mask (np.ndarray) – Boolean array of masked values. Missing values are True.

  • niter (int, optional) – Number of iterations to perform.

  • rank (int, optional) – Set the rank of the approximation used to fill the missing values.

  • full_matrices (bool, optional) – Return the full span of eigenvectors and values (see scipy.linalg.svd for a fuller description).

Returns:

u, sig, vh – The singular values and vectors.

Return type:

np.ndarray