DataObjects.SsMatrixData#

DataObjects.SsMatrixData.py

class SsMatrixData(iv, jv, M, E, moment=None, baseline_method='linear')#

Bases: object

A class to represent a SAXS/UV matrix data object. It contains a 2D matrix M where M[i,j] is the intensity value at the i-th value of the first variable (iv) and the j-th value of the second variable (jv).

iv#

The values of the first variable (e.g., scattering angle or q).

Type:

array-like

jv#

The values of the second variable (e.g., time or wavelength).

Type:

array-like

M#

The 2D matrix of intensity values.

Type:

2D array-like

data#

Human-readable alias for M — the core intensity matrix.

Type:

2D array-like (property)

E#

The 2D matrix of error values. It can be None if errors are not available

Type:

2D array-like or None

moment#

The moment of the data along the iv axis. It can be None if not computed.

Type:

Moment or None

baseline_method#

The method used for baseline correction. Default is ‘linear’.

Type:

str

Initialize the SsMatrixData object.

property data#

The 2D intensity matrix (alias for M, following numpy/pandas/xarray convention).

property q_values#

Row-axis values (alias for iv), typically scattering vector q.

property frame_indices#

Column-axis values (alias for jv), typically frame numbers.

copy(slices=None)#

Return a copy of the SsMatrixData object.

Parameters:

slices (tuple of slices, optional) – The slices to apply to the iv, jv, and M attributes.

get_icurve(pickat)#

get an i-curve from the matrix data.

Parameters:

pickat (float) – Specifies the value to pick an i-curve. The i-curve will be made from ssd.M[i,:] where ssd.iv[i] is the largest value that is less than or equal to pickat.

Examples

>>> curve = md.get_icurve(0.1)
get_jcurve(j)#

Returns a j-curve from the matrix data.

Parameters:

j (int) – Specifies the index to pick a j-curve. The j-curve will be made from ssd.xrM[:,j].

Examples

>>> curve = md.get_jcurve(150)
get_recognition_curve()#

Return the elution curve used for peak detection and buffer-frame classification. The base implementation always returns the sum over all rows (M.sum(axis=0)). XrData overrides this to honour the 'elution_recognition' global option.

Returns:

The recognition elution curve.

Return type:

Curve

get_moment()#

Get the moment of the matrix data along the iv axis.

Returns:

moment – The moment object representing the moment along the iv axis.

Return type:

EghMoment

set_baseline_method(method)#

Set the baseline method for this data object.

get_baseline_method()#

Get the baseline method for this data object.

get_baseline2d(**kwargs)#

Get the 2D baseline for the matrix data using the specified method.

Parameters:
  • method (str, optional) – Baseline method to use. If given, overrides the instance’s baseline_method for this call only. Valid values are 'buffit', 'linear', 'uvdiff', 'integral'.

  • method_kwargs (dict, optional) – Additional keyword arguments to pass to the baseline fitting method.

  • debug (bool, optional) – If True, enable debug mode.

Returns:

baseline – The 2D baseline array with the same shape as self.M.

Return type:

ndarray

get_snr_weights()#

Per-q-row signal-to-noise ratio weights.

Returns:

weights – w_i = mean(I_i) / sigma_noise_i, clipped to >= 0.

Return type:

ndarray, shape (n_q,)

get_positive_ratio(baseline, weighting='snr')#

Fraction of non-negative residual elements, optionally SNR-weighted.

Parameters:
  • baseline (ndarray) – 2D baseline array with the same shape as self.M.

  • weighting ({'snr', 'uniform'}) – ‘snr’ (default) weights each q-row by its SNR so that informative low-q rows dominate over noisy high-q rows.

Returns:

positive_ratio

Return type:

float

get_bpo_ideal(weighting='snr')#

Get the dataset-relative ideal positive_ratio for baseline evaluation.

With weighting='snr' (default), computes per-q-row noisiness, looks up per-row ideal from the BPO table, and aggregates with SNR weights. With weighting='uniform', uses the original single global noisiness.

Parameters:

weighting ({'snr', 'uniform'})

Returns:

bpo_ideal – The expected positive_ratio in [0, 1].

Return type:

float

get_ideal_positive_ratio(weighting='snr')#

Expected positive_ratio for a perfect baseline, given this dataset’s noise and peak geometry.

Alias for get_bpo_ideal() with a self-documenting name.

evaluate_baseline(baseline, weighting='snr')#

Evaluate baseline quality in a single call.

Parameters:
  • baseline (ndarray) – 2D baseline array with the same shape as self.M.

  • weighting ({'snr', 'uniform'})

Returns:

result – Namedtuple with fields positive_ratio, ideal, delta.

Return type:

BaselineEvaluation