GuinierTools.RgCurveUtils#

GuinierTools.RgCurveUtils — re-exports from molass-library canonical location.

The active computation functions live in molass.Guinier.RgCurveUtils. This module exists for backward compatibility and provides rg_deviation_inspect_impl which uses the legacy debug-plot toolkit (plt.Dp()) and therefore stays here.

Canonical usage:

from molass.Guinier.RgCurveUtils import (
    ValidBools, VALID_BASE_QUALITY,
    get_connected_curve_info, convert_to_milder_qualities,
    get_reconstructed_curve, compute_rg_curves, plot_rg_curves,
)
class ValidBools(all_frames, segment)#

Bases: tuple

Create new instance of ValidBools(all_frames, segment)

all_frames#

Alias for field number 0

segment#

Alias for field number 1

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)

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_mask threshold).

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 covers RgProcess.RgCurve, RgProcess.RgCurveProxy, and Bridge.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)) and segment (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,)

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.).

rg_deviation_inspect_impl(gdev, valid_components, rg_params, lrf_rgs)#

Debug inspection plot for GuinierDeviation.compute_deviation().

Uses the legacy plt.Dp() debug-plot context manager, so it must stay in molass-legacy. Called only when compute_deviation(debug=True).