SEC.Models.SdmEstimator#
SEC.Models.SdmEstimator.py
- class LognormalEnv(N, T, me, mp, N0, t0, mu, sigma)#
Bases:
tupleNamed-tuple form of the lognormal env-params 8-tuple
(N, T, me, mp, N0, t0, mu, sigma).Returned by
estimate_sdm_lognormal_from_monoporeand accepted byoptimize_sdm_lognormal_xr_decompositionas itsenv_paramsargument. Backward-compatible with positional unpacking.Note:
k(gamma shape) is not included here; it lives inmodel_params={'k': ...}of the lognormal optimizer (default 2.0). Accessmeandmpvialn_env.me/ln_env.mpwhen callingsdm_lognormal_model_moments(rg, N, T, N0, t0, k, mu, sigma, me=..., mp=...).- N#
Alias for field number 0
- N0#
Alias for field number 4
- T#
Alias for field number 1
- me#
Alias for field number 2
- mp#
Alias for field number 3
- mu#
Alias for field number 6
- sigma#
Alias for field number 7
- t0#
Alias for field number 5
- estimate_sdm_column_params(decomposition, **kwargs)#
Estimate column parameters from the initial curve and component curves.
N, T, me, mp, N0, t0, poresize
- Parameters:
decomposition (Decomposition) – The decomposition containing the initial curve and component curves.
poresize_bounds ((lo, hi) tuple, optional) – Bounds for the column pore size in Å. Default: (70, 300). Use a narrow window when the column type is known (e.g., (75, 80) for Superdex 200).
N0 (float, optional) – If given, the mobile-phase plate number is fixed to this value and excluded from the optimization. Use when N0 is known from buffer-only runs.
N0_bounds ((lo, hi) tuple, optional) – Bounds for N0 when it is a free parameter. Default: (500, 50000). Ignored if
N0is given.include_M3 (bool, optional) – If True (default), include the third central moment (cube-root skewness) in the matching objective. This is critical for asymmetric peaks; for symmetric peaks it is a near no-op. Set False to reproduce the legacy M1+M2-only behaviour.
M1_weight (float, optional) – Weights for the moment-matching objective. Defaults follow legacy
DispersiveMonopore.guess_params_using_moments: M1=6.0, M2=2.0, M3=2.0.M2_weight (float, optional) – Weights for the moment-matching objective. Defaults follow legacy
DispersiveMonopore.guess_params_using_moments: M1=6.0, M2=2.0, M3=2.0.M3_weight (float, optional) – Weights for the moment-matching objective. Defaults follow legacy
DispersiveMonopore.guess_params_using_moments: M1=6.0, M2=2.0, M3=2.0.debug (bool, optional) – If True, print diagnostics and show a debug plot.
- Returns:
(N, T, me, mp, N0, t0, poresize) – Estimated parameters for the SDM column.
- Return type:
- estimate_sdm_lognormal_column_params(decomposition, **kwargs)#
Estimate column parameters for SDM with lognormal pore distribution.
Runs the mono-pore estimator first, then converts poresize to lognormal parameters (mu, sigma).
- Parameters:
decomposition (Decomposition) – The decomposition containing the initial curve and component curves.
kwargs (dict) – Additional parameters for the estimation process.
- Returns:
(N, T, me, mp, N0, t0, mu, sigma) – Estimated parameters for the SDM column with lognormal pore distribution.
- Return type:
- estimate_sdm_lognormal_from_monopore(mono_ccurves, xr_icurve, **kwargs)#
Estimate lognormal column parameters from converged mono-pore SDM results.
Converts the mono-pore column parameters to lognormal initial guess by: 1. Extracting converged (N, T, x0, tI, N0, k) from the mono-pore result 2. Setting mu = ln(geometric_mean(poresize_stored, 2.5*Rg_max)), sigma=0.3 3. Shifting x0/tI to align the lognormal PDF peak with the data peak 4. (Optional) Refining (t0, k, mu, sigma) by analytical moment matching
against the EGH decomposition. Enabled when
decompositionis given.- Parameters:
mono_ccurves (list of SdmComponentCurve) – Converged mono-pore component curves.
xr_icurve (Curve) – The XR integrated elution curve (data).
decomposition (Decomposition, optional) – EGH decomposition. When provided, the heuristic init is refined by moment matching (see
refine_lognormal_params_by_moments). Recommended for the standard SDM(lognormal) pipeline.debug (bool, optional)
moment_refine (bool, optional) – If False, skip the moment-matching refinement step even when
decompositionis given. Default True.
- Returns:
(N, T, me, mp, N0, t0_adj, mu, sigma) – Estimated parameters for the lognormal SDM optimizer.
- Return type:
- refine_lognormal_params_by_moments(decomposition, N, T, N0, t0, k, mu, sigma, me=1.5, mp=1.5, debug=False)#
Refine SDM lognormal column parameters by analytical moment matching.
Given an initial guess (typically from
estimate_sdm_lognormal_from_monoporewhich uses heuristic poresize geometric mean + sigma=0.3), this function refines (mu, sigma, k, t0) by Nelder-Mead against the per-component (M1, Var) extracted from the EGH decomposition.The upper bound on
muis enforced asln(2 × Rg_max)— the SDM separation criterion. Above this, K_SEC values compress across components and elution curves converge, causing a degenerate Stage-3 decomposition. The L-BFGS-B solver that was used previously could overshoot this bound, accidentally yielding a bad starting point or causing a degenerate collapse; Nelder-Mead with an explicit penalty respects the bound by construction.Uses the fast analytical moment evaluator
molass.SEC.Models.LognormalPore.sdm_lognormal_model_moments()(~50 us/call), so the full refinement costs only a few tens of ms.Only (mu, sigma, k, t0) are refined; (N, T, N0) are held fixed because the mono-pore stage already constrains them well from M1+M2+M3 matching.
- Parameters:
decomposition (Decomposition) – EGH decomposition providing per-component empirical moments.
N (float) – Initial guesses (from
estimate_sdm_lognormal_from_monopore).T (float) – Initial guesses (from
estimate_sdm_lognormal_from_monopore).N0 (float) – Initial guesses (from
estimate_sdm_lognormal_from_monopore).t0 (float) – Initial guesses (from
estimate_sdm_lognormal_from_monopore).k (float) – Initial guesses (from
estimate_sdm_lognormal_from_monopore).mu (float) – Initial guesses (from
estimate_sdm_lognormal_from_monopore).sigma (float) – Initial guesses (from
estimate_sdm_lognormal_from_monopore).me (float, optional) – SEC partition exponents (default 1.5).
mp (float, optional) – SEC partition exponents (default 1.5).
debug (bool, optional) – If True, print per-component moment-matching diagnostics.
- Returns:
(t0, k, mu, sigma) – Refined parameters. Other inputs (N, T, N0) are returned by the caller.
- Return type: