hyperspy.misc.model_tools module

hyperspy.misc.model_tools._calculate_covariance(target_signal, coefficients, component_data, residual=None, lazy=False)

Calculate covariance matrix after having performed Linear Regression.

Parameters:
  • target_signal (array-like, shape (N,) or (M, N)) – The signal array to be fit to.

  • coefficients (array-like, shape C or (M, C)) – The fitted coefficients.

  • component_data (array-like, shape N or (C, N)) – The component data.

  • residual (array-like, shape (0,) or (M,)) – The residual sum of squares, optional. Calculated if None.

  • lazy (bool) – Whether the signal is lazy.

Notes

Explanation of the array shapes in HyperSpy terms: N : flattened signal shape M : flattened navigation shape C : number of components

See https://stats.stackexchange.com/questions/62470 for more info on the algorithm

hyperspy.misc.model_tools._is_iter(val)

Checks if value is a list or tuple.

hyperspy.misc.model_tools._iter_join(val)

Joins values of iterable parameters for the fancy view, unless it equals None, then blank

hyperspy.misc.model_tools._non_iter(val)

Returns formatted string for a value unless it equals None, then blank

class hyperspy.misc.model_tools.current_component_values(component, only_free=False, only_active=False)

Bases: object

Convenience class that makes use of __repr__ methods for nice printing in the notebook of the properties of parameters of a component.

Parameters:
  • component (hyperspy component instance) –

  • only_free (bool, default False) – If True: Only include the free parameters in the view

  • only_active (bool, default False) – If True: Helper for current_model_values. Only include active components in the view. Always shows values if used on an individual component.

class hyperspy.misc.model_tools.current_model_values(model, only_free=False, only_active=False, component_list=None)

Bases: object

Convenience class that makes use of __repr__ methods for nice printing in the notebook of the properties of parameters in components in a model.

Parameters:
  • component (hyperspy component instance) –

  • only_free (bool, default False) – If True: Only include the free parameters in the view

  • only_active (bool, default False) – If True: Only include active parameters in the view