Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Proportional Constaints

from molass import get_version
assert get_version() >= '0.7.4', "This tutorial requires molass version 0.7.4 or higher."
from molass_data import get_version
assert get_version() >= '0.3.0', "This tutorial requires molass_data version 0.3.0 or higher."
from molass_data import SAMPLE4
from molass.DataObjects import SecSaxsData as SSD
ssd = SSD(SAMPLE4)
trimmed_ssd = ssd.trimmed_copy()
corrected_ssd = trimmed_ssd.corrected_copy()
import numpy as np
import matplotlib.pyplot as plt
from molass.Decompose.Proportional import decompose_proportionally
icurve  = corrected_ssd.xr.get_icurve()
result = decompose_proportionally(icurve, [3,2,1], debug=True)
[0.47908885 0.28660209 0.23430906]
[0.50000694 0.33332614 0.16666691]
<Figure size 1200x500 with 2 Axes>
result
message: Maximum number of function evaluations has been exceeded. success: False status: 1 fun: -4.226653800002927 x: [ 5.477e-02 8.259e+01 7.101e+00 -1.572e-05 2.702e-02 9.666e+01 9.439e+00 3.990e+00 1.152e-02 1.111e+02 1.095e+01 5.995e+00] nit: 1658 nfev: 2400 final_simplex: (array([[ 5.477e-02, 8.259e+01, ..., 1.095e+01, 5.995e+00], [ 5.477e-02, 8.259e+01, ..., 1.095e+01, 5.995e+00], ..., [ 5.477e-02, 8.259e+01, ..., 1.095e+01, 5.995e+00], [ 5.477e-02, 8.259e+01, ..., 1.095e+01, 5.995e+00]], shape=(13, 12)), array([-4.227e+00, -4.227e+00, ..., -4.227e+00, -4.227e+00], shape=(13,)))
rgcurve = corrected_ssd.xr.compute_rgcurve()
Loading...
num_trails = 8
species1_proportions = np.ones(num_trails) * 3
species2_proportions = np.linspace(1, 3, num_trails)
proportions = np.array([species1_proportions, species2_proportions]).T
proportions
array([[3. , 1. ], [3. , 1.28571429], [3. , 1.57142857], [3. , 1.85714286], [3. , 2.14285714], [3. , 2.42857143], [3. , 2.71428571], [3. , 3. ]])
from importlib import reload
import molass.Decompose.VaryUtils
reload(molass.Decompose.VaryUtils)
from molass.Decompose.VaryUtils import _plot_varied_decompositions_impl
_plot_varied_decompositions_impl(icurve, proportions, rgcurve=rgcurve, best=3)
<Figure size 2000x800 with 16 Axes>
<Figure size 640x480 with 2 Axes>
species3_proportions = np.ones(num_trails) * 1
proportions = np.array([species1_proportions, species2_proportions, species3_proportions]).T
proportions
array([[3. , 1. , 1. ], [3. , 1.28571429, 1. ], [3. , 1.57142857, 1. ], [3. , 1.85714286, 1. ], [3. , 2.14285714, 1. ], [3. , 2.42857143, 1. ], [3. , 2.71428571, 1. ], [3. , 3. , 1. ]])
_plot_varied_decompositions_impl(icurve, proportions, rgcurve=rgcurve, best=3)
<Figure size 2000x800 with 16 Axes>
<Figure size 640x480 with 2 Axes>
from molass_data import SAMPLE1
ssd = SSD(SAMPLE1)
trimmed_ssd = ssd.trimmed_copy()
corrected_ssd = trimmed_ssd.corrected_copy()
zeros at the angular ends of error data have been replaced with the adjacent values.
modified_decomposition = corrected_ssd.quick_decomposition(num_components=3, proportions=[0.32, 0.20, 0.48])
plot2 = modified_decomposition.plot_components(title="Modified Decomposition of Sample1 (num_components=3, proportions=[0.32, 0.20, 0.48])")
<Figure size 1600x800 with 8 Axes>