Guinier.RgCurveUtils#
This module contains functions used to calculate a Rg curve, which is maked of Rg values computed from scattering curves.
- compute_rg_curve_from_arrays(D, qv, E, jv=None, progress_cb=None)#
Compute a library-quality RgCurve directly from numpy arrays.
This is the array-level entry point that makes rg_curve computation independent of SSD or SD. It uses the same SimpleGuinier pipeline as
compute_rgcurve_info/XrData.compute_rgcurve, but accepts raw arrays instead of anXrDataobject.This function is used by
BackRunner.run()to compute and export the library rg_curve for LEG-GUI subprocess runs, closing the Guinier_deviation gap between LIB-IN and LEG-GUI without requiring the GUI to construct an SSD.- Parameters:
D (ndarray of shape (n_q, n_frames)) – Corrected XR intensity matrix (e.g. from
ip_xr_D.npy).qv (ndarray of shape (n_q,)) – q-values in Å⁻¹ (e.g. from
ip_xr_qvector.npy).E (ndarray of shape (n_q, n_frames)) – Intensity error matrix (e.g. from
ip_xr_E.npy).jv (ndarray of shape (n_frames,) or None) – Original frame numbers. If None, uses
np.arange(n_frames).progress_cb (callable or None) – Same signature as in
compute_rgcurve_info.
- Returns:
Library
molass.Guinier.RgCurve.RgCurveobject.- Return type:
- compute_rgcurve_info(xrdata, progress_cb=None)#
Computes Rg curve information from XR data. It uses the SimpleGuinier class to compute Rg values for each j-curve in the XR data.
- Parameters:
xrdata (XrData) – The XR data from which to compute the Rg curve information.
progress_cb (callable or None, optional) – Optional callback called after each frame with
(rg_buffer, j)whererg_bufferis a float array of shape(n_frames,)containing the Rg values computed so far (0 for not-yet-computed frames) andjis the 0-based column index of the current frame. The signature matches the legacyProgressCallbackso GUI callers can drive a progress bar and live Rg overlay with no additional adaptation.
- Returns:
rginfo_list – A list of tuples where each tuple contains (index, SimpleGuinier result).
- Return type:
list of tuples
- class ValidBools(all_frames, segment)#
Bases:
tupleCreate new instance of ValidBools(all_frames, segment)
- all_frames#
Alias for field number 0
- segment#
Alias for field number 1
- convert_to_milder_qualities(qualities)#
Raise the quality floor so that low-quality frames still get some weight.
- Maps raw qualities (0–1) to a compressed range (VALID_BASE_QUALITY–1):
out[i] = 0.3 + 0.7 * qualities[i] for qualities[i] > 0.01
Deprecated since version No: longer used for Guinier_deviation weights (see molass-legacy issue #11). Raw qualities are now used directly in
GuinierDeviation. Kept for backward compatibility (e.g.max_maskthreshold).
- get_connected_curve_info(rg_curve, debug=False)#
Extract concatenated x, y, Rg, and quality arrays from a segmented Rg curve.
Works with any object that exposes the segmented Rg interface:
get_curve_segments(),.qualities,.states,.slices,.x. This coversRgProcess.RgCurve,RgProcess.RgCurveProxy, andBridge.LegacyRgCurve.- Returns:
x_ (ndarray) – Concatenated frame positions of all active segments.
y_ (ndarray) – Corresponding elution intensities.
rgv (ndarray) – Corresponding smoothed Rg values.
qualities (ndarray) – Concatenated raw Guinier quality scores (one per active frame).
valid_bools (ValidBools) – Named-tuple with two boolean masks:
all_frames(len = len(rg_curve.x)) andsegment(len = len(qualities)).
- get_reconstructed_curve(size, valid_bools, Cxr, rg_params)#
Reconstruct the weighted-average Rg curve from component elution curves.
- Parameters:
size (int) – Length of the output array (number of active frames in the segment).
valid_bools (ValidBools)
Cxr (ndarray, shape (n_components, n_all_frames))
rg_params (sequence of float)
- Returns:
rrgv
- Return type:
ndarray, shape (size,)
- compute_rg_curves(x, xr_weights, rg_params, xr_cy_list, xr_ty, rg_curve, debug=False)#
Compute observed and reconstructed Rg curves for each active segment.
- Returns:
rg_curves1 (list of (x, rg) tuples — observed Rg from rg_curve.segments)
rg_curves2 (list of (x, rg) tuples — model-reconstructed Rg)
- plot_rg_curves(ax, xrh_params, rg_params, x, xr_cy_list, xr_ty, rg_curve)#
Plot observed and reconstructed Rg curves on ax (a matplotlib Axes).
Used by the legacy model-parameter plot utilities (EghPlotUtils, etc.).
- compute_rgcurve_info_atsas(xrdata)#
Computes Rg curve information from XR data using ATSAS autorg. It uses the AutorgRunner class to compute Rg values for each j-curve in the XR data.