DataObjects.XrData#
DataObjects.XrData.py
- class XrData(iv, jv, M, E, **kwargs)#
Bases:
SsMatrixDataXrData class for XR matrix data. Inherits from SsMatrixData and adds XR-specific functionality.
- qv#
The q-values corresponding to the angular axis.
- Type:
array-like
- baseline_method#
Default is
'linear'. Can be overridden by passingbaseline_method=...to the constructor.- Type:
str
Initialize the XrData object.
- Parameters:
iv (array-like) – The q-values corresponding to the angular axis.
jv (array-like) – The values corresponding to the temporal axis.
M (2D array-like) – The 2D matrix of intensity values.
E (2D array-like or None) – The 2D matrix of error values. It can be None if errors are not available
kwargs (dict, optional) – Additional keyword arguments to pass to the SsMatrixData constructor.
- property xr_pickat#
Alias for
pickat— the default q-value for i-curve extraction.
- 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_ipickvalue()#
Get the default pickvalue for i-curves. :returns: The default pickvalue for i-curves. :rtype: float
- get_icurve(pickat=0.02)#
Returns an i-curve from the XR matrix data.
- Parameters:
pickat (float, optional) –
Specifies the value in ssd.qv where to pick an i-curve. The i-curve will be made from self.M[i,:] where the picking index i will be determined to satisfy
self.qv[i-1] <= pickat < self.qv[i]
according to bisect_right. If None, uses self.pickat (default 0.02, or the value set via SSD(xr_pickat=…)).
- Returns:
The extracted i-curve.
- Return type:
Examples
>>> curve = xr.get_icurve()
>>> curve = xr.get_icurve(pickat=0.02)
- get_recognition_curve()#
Return the elution curve used for peak detection and buffer-frame classification, honouring the
'elution_recognition'global option.'icurve'(default) — single row at q≈0.02, same asget_icurve(). High S/N in the Guinier regime; preserves the existing behaviour unchanged.'sum'— sum of the (already-trimmed) matrix over all q-rows. Exposes q-dependent baseline drift that is invisible at q≈0.02 (e.g. MY-type datasets).
- Returns:
The recognition elution curve.
- Return type:
Examples
>>> from molass import set_molass_options >>> set_molass_options(elution_recognition='sum') >>> curve = xr.get_recognition_curve() # now returns M.sum(axis=0) >>> set_molass_options(elution_recognition='icurve') # restore default
- get_usable_qrange()#
Returns a pair of indeces which should be used as a slice for the angular axis to trim away unusable XR data regions.
- Parameters:
None
- Returns:
A pair of indeces (i_start, i_end) to be used as a slice for the angular axis.
- Return type:
(int, int)
Examples
>>> i, j = xr.get_usable_qrange()
- get_ibaseline()#
Returns a baseline i-curve from the XR matrix data.
- Parameters:
pickat (float, optional) – q-value at which to pick the i-curve for baseline fitting. If None, uses self.pickat (default 0.02, or the value set via SSD(xr_pickat=…)).
method (str, optional) – The baseline method to be used. If None, the method set in the object will be used.
kwargs (dict, optional) – Additional keyword arguments to pass to the baseline computation function. These will be merged with the default_kwargs defined above.
debug (bool, optional) – If True, enable debug mode.
- Returns:
baseline – The computed baseline i-curve. This curve can be subtracted from the original i-curve to obtain a background-subtracted curve.
- Return type:
Examples
>>> curve = xr.get_icurve() >>> baseline = xr.get_ibaseline() >>> corrected_curve = curve - baseline
- compute_rgcurve()#
Returns a Rg-curve which is computed using the Molass standard method.
- Parameters:
None
- Return type:
An
RgCurveobject.
- compute_rgcurve_atsas()#
Returns an Rg-curve which is computed using the ATSAS autorg.
- Parameters:
None
- Return type:
An
RgCurveobject.
- detect_peaks()#
Detect peaks in the total XR elution curve using Savitzky-Golay smoothing followed by scipy
find_peaks.The returned list can be passed directly to
ssd.quick_decomposition(xr_peakpositions=peaks).- Parameters:
prominence (float, optional) – Minimum prominence as a fraction of the smoothed curve maximum. Default 0.005 (0.5 %).
distance (int, optional) – Minimum number of frames between adjacent peaks. Default 20.
window_length (int, optional) – Savitzky-Golay filter window length (must be odd). Default 31.
polyorder (int, optional) – Savitzky-Golay filter polynomial order. Default 3.
return_properties (bool, optional) – If True, return a tuple
(peaks, properties)where properties is a dict containing'prominences'and'peak_heights'arrays. Default False (backward-compatible).
- Returns:
list of int – Frame numbers of detected peaks, sorted by frame number. Returned alone when
return_properties=False.tuple of (list of int, dict) –
(peaks, properties)whenreturn_properties=True.
Examples
>>> peaks = ssd.xr.detect_peaks() >>> decomp = ssd.quick_decomposition(xr_peakpositions=peaks)
>>> peaks, props = ssd.xr.detect_peaks(return_properties=True) >>> props['prominences'] # array of peak prominences
- plot_peaks()#
Visualize detected peaks on the total XR elution curve.
- Parameters:
ax (matplotlib Axes, optional) – If provided, plot on this axes. Otherwise create a new figure.
prominence – Forwarded to
detect_peaks().distance – Forwarded to
detect_peaks().window_length – Forwarded to
detect_peaks().polyorder – Forwarded to
detect_peaks().
- Return type:
tuple of (Figure, Axes)
- get_jcurve_array(j=None, peak=None)#
Returns the j-curve array. This method extracts the q, I, and sigq values from the XR data. It uses the first peak in the i-curve to determine the j-curve.
- Parameters:
j (int, optional) – The index of the j-curve to use. If None, the peak argument is used.
peak (int, optional) – This argument is used only if j is None. The index of the peak in the i-curve to use. If None, the first peak is used.
- Returns:
jcurve_array
- Return type:
np.ndarray