exa.core.util.pca.principal_component_analysis

exa.core.util.pca.principal_component_analysis#

principal_component_analysis(complex_amplitudes, poq_param_name='phase_optimal_quad')#

Use Principal component analysis to compute contrast and the angle of the first principal component (Heinsoo2019).

Can be replaced with sklearn.decomposition.PCA in the future (sklearn library version is approx. 2x faster and more versatile).

Parameters:
  • complex_amplitudes (ndarray) – array of complex numbers to perform principal component analysis on

  • poq_param_name (str) – optional custom parameter name to be used for the phase of the first principal component. By default, will be Parameter("phase_optimal_quad").

Returns:

  • dictionary with parameter name as key and phase optimal quadrature value. This format is needed so it can

    be added to a DataArray

  • resulting real contrast after applying PCA and rotating complex_amplitudes

Return type:

tuple[dict[str, float | ndarray], ndarray]