LowRank.BoundedLrf#
LowRank.BoundedLrf.py
Bounded Low-Rank Factorization (Bounded LRF) for rank-2 components.
Clips B(q) within a physics-motivated envelope derived from the hard-sphere structure factor and redistributes excess to A(q), preserving the row-wise intensity sum A(q)*c1 + B(q)*c2.
Ported from molass_legacy BoundedLrfSolver.py (coerce_bounds + estimate_RgL).
- estimate_KL(qv, aq, bq, Rg, c1)#
Estimate the hard-sphere model parameters K and L.
Stage 1: fit K, L by matching B(q) to -K * phi(2*L*R*q) * A(q) Stage 2: refine L so that the envelope A(q)/(c1*(q*L*R)^2) tightly
covers the data without excessive violations.
- Parameters:
qv (ndarray) – q-vector.
aq (ndarray) – A(q) column from the naïve factorization.
bq (ndarray) – B(q) column from the naïve factorization.
Rg (float) – Radius of gyration from Guinier analysis.
c1 (float) – Peak monomer concentration.
- Returns:
K (float) – Structure factor amplitude (from Stage 1).
L (float) – Bound-tightness parameter (from Stage 2).
R (float) – Sphere-equivalent radius sqrt(5/3) * Rg.
- coerce_bounds(qv, aq, bq, c1, L, R)#
Clip B(q) within the physics-motivated envelope and redistribute the excess to A(q) so that A(q)*c1 + B(q)*c2 is preserved row-wise.
- Parameters:
qv (ndarray) – q-vector.
aq (ndarray) – A(q) column.
bq (ndarray) – B(q) column.
c1 (float) – Peak monomer concentration.
L (float) – Bound-tightness parameter from estimate_KL.
R (float) – Sphere-equivalent radius.
- Returns:
aq_corrected (ndarray) – A(q) after redistribution.
bq_coerced (ndarray) – B(q) after clipping.
bq_bounds (tuple of ndarray) – (-bq_bound, +bq_bound) envelope arrays.
- apply_bounded_lrf(qv, P_full, C_full, ranks, guinier_objects)#
Apply Bounded LRF to every rank-2 component in P_full.
- Parameters:
qv (ndarray) – q-vector.
P_full (ndarray, shape (num_q, total_rank)) – Full spectral factor matrix including B(q) columns.
C_full (ndarray, shape (total_rank, num_frames)) – Full concentration matrix including c^2 rows.
ranks (list of int) – Rank for each component (1 or 2).
guinier_objects (list) – Pre-computed RgEstimator objects (one per component).
- Returns:
P_truncated (ndarray, shape (num_q, num_components)) – Corrected spectral factors (A columns only), ready for downstream use.
info (dict) – Keyed by component index; each value is a dict with diagnostic fields K, L, R, Rg, bq_bounds, bq_original, bq_coerced.