LowRank.Decomposition#
LowRank.LowRankInfo.py
This module contains the class LowRankInfo, which is used to store information about the components of a SecSaxsData, which is mathematically interpreted as a low rank approximation of a matrix.
- class Decomposition(ssd, xr_icurve, xr_ccurves, uv_icurve, uv_ccurves, mapped_curve=None, paired_ranges=None, **kwargs)#
Bases:
object
A class to store the result of decomposition which is a low rank approximation.
The result includes both components of X-ray and UV data and their associated information.
- ssd#
The SecSaxsData object from which the decomposition was performed.
- Type:
- xr_ranks#
The ranks for each component of the X-ray data. If None, default ranks are used.
- Type:
list of int or None
- uv_ranks#
The ranks for each component of the UV data. If None, default ranks are used.
- Type:
list of int or None
- mapping#
The mapping information between the X-ray and UV data.
- Type:
- mapped_curve#
The mapped curve from the X-ray to UV domain. If None, it can be computed when needed.
- Type:
MappedCurve or None
- paired_ranges#
The paired ranges for the X-ray and UV data. If None, it can be computed when needed.
- Type:
list of PairedRange or None
- num_components#
The number of components in the decomposition.
- Type:
int
Initialize the Decomposition object.
- Parameters:
ssd (SecSaxsData) – The SecSaxsData object from which the decomposition was performed.
xr_icurve (Curve) – The i-curve used for the decomposition of the X-ray data.
xr_ccurves (list of Curve) – The component curves for the X-ray data.
uv_icurve (Curve) – The i-curve used for the decomposition of the UV data.
uv_ccurves (list of Curve) – The component curves for the UV data.
mapped_curve (MappedCurve, optional) – The mapped curve from the X-ray to UV domain. If None, it can be computed when needed.
paired_ranges (list of PairedRange, optional) – The paired ranges for the X-ray and UV data. If None, it can be computed when needed.
kwargs (dict, optional) – Additional keyword arguments (not used).
- copy_with_new_components(xr_ccurves, uv_ccurves)#
Create a new Decomposition with new component curves.
- Parameters:
- Returns:
A new Decomposition object with the specified component curves.
- Return type:
- get_num_components()#
Get the number of components.
- Returns:
The number of components in the decomposition.
- Return type:
int
- plot_components(title=None, **kwargs)#
Plot the components.
- Parameters:
title (str, optional) – If specified, add a super title to the plot.
- Returns:
result – A PlotResult object which contains the following attributes.
fig: The matplotlib Figure object.
axes: A list of Axes objects.
- Return type:
- update_xr_ranks(ranks, debug=False)#
Update the ranks for the X-ray data.
Default ranks are one for each component which means that interparticle interactions are not considered. This method allows the user to set different ranks for each component.
- Parameters:
ranks (list of int) – The ranks for each component.
- Return type:
None
- get_xr_matrices(debug=False)#
Get the matrices for the X-ray data.
- Parameters:
debug (bool, optional) – If True, enable debug mode.
- Return type:
tuple of (np.ndarray, np.ndarray, np.ndarray, np.ndarray)
- get_xr_components(debug=False)#
Get the components for the X-ray data.
- Parameters:
debug (bool, optional) – If True, enable debug mode.
- Returns:
The list of XrComponent objects.
- Return type:
list of
XrComponent
- get_guinier_objects()#
Get the list of Guinier objects for the XR components.
- Returns:
The list of Guinier objects for each XR component.
- Return type:
list of Guinier
- get_rgs()#
Get the list of Rg values for the XR components.
- Returns:
The list of Rg values for each XR component.
- Return type:
list of float
- get_uv_matrices(debug=False)#
Get the matrices for the UV data.
- Parameters:
debug (bool, optional) – If True, enable debug mode.
- Returns:
The matrices for the UV data.
- Return type:
tuple of (np.ndarray, np.ndarray, np.ndarray, np.ndarray)
- get_uv_components(debug=False)#
Get the components for the UV data.
- Return type:
List of UvComponent objects.
- get_pairedranges(mapped_curve=None, area_ratio=0.7, concentration_datatype=2, debug=False)#
Get the paired ranges.
- Parameters:
mapped_curve (MappedCurve, optional) – If specified, use this mapped curve instead of computing a new one.
area_ratio (float, optional) – The area ratio for the range computation.
concentration_datatype (int, optional) – The concentration datatype for the range computation.
debug (bool, optional) – If True, enable debug mode.
- Returns:
The list of
PairedRange
objects.- Return type:
list of PairedRange
- get_proportions()#
Get the proportions of the components.
- Returns:
The proportions of the components as a numpy array.
- Return type:
np.ndarray
- compute_scds(debug=False)#
Get the list of SCDs (Score of Concentration Dependence) for the decomposition.
- Returns:
The list of SCD values for each component.
- Return type:
list of float
- get_cd_color_info()#
Get the color information for the concentration dependence.
- Returns:
peak_top_xes (list of float) – The list of peak top x values for each component.
scd_colors (list of str) – The list of colors for each component based on their ranks.
- optimize_with_model(model_name, debug=False)#
Optimize the decomposition with a model.
- Parameters:
model_name (str) –
The name of the model to use for optimization.
Supported models:
debug (bool, optional) – If True, enable debug mode.
- Returns:
result – A new Decomposition object with optimized components.
- Return type: