Changeset 7e1d090 in sasmodels
- Timestamp:
- Feb 18, 2016 5:23:36 AM (9 years ago)
- Branches:
- master, core_shell_microgels, costrafo411, magnetic_model, release_v0.94, release_v0.95, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
- Children:
- cfc254e
- Parents:
- e66075f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/models/two_power_law.py
rbdb3313 r7e1d090 39 39 .. figure:: img/two_power_law_1d.jpg 40 40 41 1D plot using the default values (w /500 data point).41 1D plot using the default values (with 500 data point). 42 42 43 43 References … … 71 71 # ["name", "units", default, [lower, upper], "type", "description"], 72 72 parameters = [["coefficent_1", "", 1.0, [-inf, inf], "", "coefficent A in low Q region"], 73 ["crossover", "1/Ang", 0.04,[0, inf], "", "crossover location"],74 ["power_1", "", 1.0, [0, inf], "", "power law exponent at low Q"],75 ["power_2", "", 4.0, [0, inf], "", "power law exponent at high Q"],76 73 ["crossover", "1/Ang", 0.04,[0, inf], "", "crossover location"], 74 ["power_1", "", 1.0, [0, inf], "", "power law exponent at low Q"], 75 ["power_2", "", 4.0, [0, inf], "", "power law exponent at high Q"], 76 ] 77 77 # pylint: enable=bad-whitespace, line-too-long 78 78 79 79 80 def Iq(q, … … 82 83 power_1=1.0, 83 84 power_2=4.0, 84 85 ): 85 86 86 87 """ 87 88 :param q: Input q-value (float or [float, float]) 88 :param coef A:Scaling coefficent at low Q89 :param coefficent_1: Scaling coefficent at low Q 89 90 :param crossover: Crossover location 90 91 :param power_1: Exponent of power law function at low Q … … 92 93 :return: Calculated intensity 93 94 """ 94 # pylint: disable=bad-whitespace95 95 96 96 #Two sub vectors are created to treat crossover values 97 q_lower = q[q <=crossover]98 q_upper = q[q >crossover]99 coefficent_2 = coefficent_1*power(crossover, -1.0*power_1)/power(crossover,-1.0*power_2)100 intensity_lower = coefficent_1*power(q_lower, -1.0*power_1)101 intensity_upper = coefficent_2*power(q_upper, -1.0*power_2)102 intensity = concatenate( ( intensity_lower,intensity_upper), axis=0)97 q_lower = q[q <= crossover] 98 q_upper = q[q > crossover] 99 coefficent_2 = coefficent_1*power(crossover, -1.0*power_1)/power(crossover, -1.0*power_2) 100 intensity_lower = coefficent_1*power(q_lower, -1.0*power_1) 101 intensity_upper = coefficent_2*power(q_upper, -1.0*power_2) 102 intensity = concatenate((intensity_lower, intensity_upper), axis=0) 103 103 104 104 return intensity … … 118 118 Iqxy.vectorized = True # Iqxy accepts an array of qx, qy values 119 119 120 demo = dict(scale=1, background=0. 1,120 demo = dict(scale=1, background=0.0, 121 121 coefficent_1=1.0, 122 122 crossover=0.04, … … 126 126 oldname = "TwoPowerLawModel" 127 127 oldpars = dict(coefficent_1='coef_A', 128 129 130 131 128 crossover='qc', 129 power_1='power1', 130 power_2='power2', 131 background='background') 132 132 133 133 tests = [ 134 135 134 # Accuracy tests based on content in test/utest_extra_models.py 136 135 [{'coefficent_1': 1.0, … … 139 138 'power_2': 4.0, 140 139 'background': 0.0, 141 }, 0.001, 1000],140 }, 0.001, 1000], 142 141 143 142 [{'coefficent_1': 1.0, … … 146 145 'power_2': 4.0, 147 146 'background': 0.0, 148 }, 0.150141, 0.125945],147 }, 0.150141, 0.125945], 149 148 150 149 [{'coeffcent_1': 1.0, … … 153 152 'power_2': 4.0, 154 153 'background': 0.0, 155 }, 0.442528, 0.00166884],154 }, 0.442528, 0.00166884], 156 155 157 156 [{'coeffcent_1': 1.0, … … 160 159 'power_2': 4.0, 161 160 'background': 0.0, 162 }, (0.442528, 0.00166884), 0.00166884],161 }, (0.442528, 0.00166884), 0.00166884], 163 162 164 163 ]
Note: See TracChangeset
for help on using the changeset viewer.