Changes in / [7e74ed5:150fb81] in sasmodels
- Location:
- sasmodels
- Files:
-
- 2 added
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/compare.py
r8c65a33 rfe25eda 1063 1063 # Evaluate preset parameter expressions 1064 1064 context = MATH.copy() 1065 context['np'] = np 1065 1066 context.update(pars) 1066 1067 context.update((k,v) for k,v in presets.items() if isinstance(v, float)) -
sasmodels/details.py
r6dc78e4 rccd5f01 230 230 npars = kernel.info.parameters.npars 231 231 nvalues = kernel.info.parameters.nvalues 232 scalars = [ v[0][0] for vin pairs]232 scalars = [(v[0] if len(v) else np.NaN) for v, w in pairs] 233 233 values, weights = zip(*pairs[2:npars+2]) if npars else ((),()) 234 234 length = np.array([len(w) for w in weights]) -
sasmodels/kernel_header.c
r218cdbc rb7e8b94 148 148 inline double sinc(double x) { return x==0 ? 1.0 : sin(x)/x; } 149 149 150 #if 0 150 #if 1 151 //think cos(theta) should be sin(theta) in new coords, RKH 11Jan2017 151 152 #define ORIENT_SYMMETRIC(qx, qy, theta, phi, q, sn, cn) do { \ 152 153 SINCOS(phi*M_PI_180, sn, cn); \ 153 154 q = sqrt(qx*qx + qy*qy); \ 154 cn = (q==0. ? 1.0 : (cn*qx + sn*qy)/q * cos(theta*M_PI_180)); \155 cn = (q==0. ? 1.0 : (cn*qx + sn*qy)/q * sin(theta*M_PI_180)); \ 155 156 sn = sqrt(1 - cn*cn); \ 156 157 } while (0) -
sasmodels/models/barbell.py
r0d6e865 rfcb33e4 20 20 .. math:: 21 21 22 I(q) = \frac{\Delta \rho^2}{V} \left<A^2(q )\right>22 I(q) = \frac{\Delta \rho^2}{V} \left<A^2(q,\alpha).sin(\alpha)\right> 23 23 24 where the amplitude $A(q )$ is given as24 where the amplitude $A(q,\alpha)$ with the rod axis at angle $\alpha$ to $q$ is given as 25 25 26 26 .. math:: 27 27 28 28 A(q) =&\ \pi r^2L 29 \frac{\sin\left(\tfrac12 qL\cos\ theta\right)}30 {\tfrac12 qL\cos\ theta}31 \frac{2 J_1(qr\sin\ theta)}{qr\sin\theta} \\29 \frac{\sin\left(\tfrac12 qL\cos\alpha\right)} 30 {\tfrac12 qL\cos\alpha} 31 \frac{2 J_1(qr\sin\alpha)}{qr\sin\alpha} \\ 32 32 &\ + 4 \pi R^3 \int_{-h/R}^1 dt 33 \cos\left[ q\cos\ theta33 \cos\left[ q\cos\alpha 34 34 \left(Rt + h + {\tfrac12} L\right)\right] 35 35 \times (1-t^2) 36 \frac{J_1\left[qR\sin\ theta \left(1-t^2\right)^{1/2}\right]}37 {qR\sin\ theta \left(1-t^2\right)^{1/2}}36 \frac{J_1\left[qR\sin\alpha \left(1-t^2\right)^{1/2}\right]} 37 {qR\sin\alpha \left(1-t^2\right)^{1/2}} 38 38 39 39 The $\left<\ldots\right>$ brackets denote an average of the structure over 40 all orientations. $\left<A^2(q )\right>$ is then the form factor, $P(q)$.40 all orientations. $\left<A^2(q,\alpha)\right>$ is then the form factor, $P(q)$. 41 41 The scale factor is equivalent to the volume fraction of cylinders, each of 42 42 volume, $V$. Contrast $\Delta\rho$ is the difference of scattering length … … 85 85 * **Author:** NIST IGOR/DANSE **Date:** pre 2010 86 86 * **Last Modified by:** Paul Butler **Date:** March 20, 2016 87 * **Last Reviewed by:** Paul Butler **Date:** March 20, 201687 * **Last Reviewed by:** Richard Heenan **Date:** January 4, 2017 88 88 """ 89 89 from numpy import inf -
sasmodels/models/capped_cylinder.py
r0d6e865 rfcb33e4 21 21 .. math:: 22 22 23 I(q) = \frac{\Delta \rho^2}{V} \left<A^2(q )\right>23 I(q) = \frac{\Delta \rho^2}{V} \left<A^2(q,\alpha).sin(\alpha)\right> 24 24 25 where the amplitude $A(q )$ is given as25 where the amplitude $A(q,\alpha)$ with the rod axis at angle $\alpha$ to $q$ is given as 26 26 27 27 .. math:: 28 28 29 29 A(q) =&\ \pi r^2L 30 \frac{\sin\left(\tfrac12 qL\cos\ theta\right)}31 {\tfrac12 qL\cos\ theta}32 \frac{2 J_1(qr\sin\ theta)}{qr\sin\theta} \\30 \frac{\sin\left(\tfrac12 qL\cos\alpha\right)} 31 {\tfrac12 qL\cos\alpha} 32 \frac{2 J_1(qr\sin\alpha)}{qr\sin\alpha} \\ 33 33 &\ + 4 \pi R^3 \int_{-h/R}^1 dt 34 \cos\left[ q\cos\ theta34 \cos\left[ q\cos\alpha 35 35 \left(Rt + h + {\tfrac12} L\right)\right] 36 36 \times (1-t^2) 37 \frac{J_1\left[qR\sin\ theta \left(1-t^2\right)^{1/2}\right]}38 {qR\sin\ theta \left(1-t^2\right)^{1/2}}37 \frac{J_1\left[qR\sin\alpha \left(1-t^2\right)^{1/2}\right]} 38 {qR\sin\alpha \left(1-t^2\right)^{1/2}} 39 39 40 40 The $\left<\ldots\right>$ brackets denote an average of the structure over … … 88 88 * **Author:** NIST IGOR/DANSE **Date:** pre 2010 89 89 * **Last Modified by:** Paul Butler **Date:** September 30, 2016 90 * **Last Reviewed by:** Richard Heenan **Date:** March 19, 2016 90 * **Last Reviewed by:** Richard Heenan **Date:** January 4, 2017 91 91 92 """ 92 93 from numpy import inf -
sasmodels/models/core_shell_bicelle.py
rb829b16 rfcb33e4 41 41 42 42 I(Q,\alpha) = \frac{\text{scale}}{V_t} \cdot 43 F(Q,\alpha)^2 + \text{background}43 F(Q,\alpha)^2.sin(\alpha) + \text{background} 44 44 45 45 where … … 85 85 * **Author:** NIST IGOR/DANSE **Date:** pre 2010 86 86 * **Last Modified by:** Paul Butler **Date:** September 30, 2016 87 * **Last Reviewed by:** Richard Heenan **Date:** October 5, 201687 * **Last Reviewed by:** Richard Heenan **Date:** January 4, 2017 88 88 """ 89 89 -
sasmodels/models/core_shell_cylinder.py
r755ecc2 rfcb33e4 9 9 .. math:: 10 10 11 I(q,\alpha) = \frac{\text{scale}}{V_s} F^2(q ) + \text{background}11 I(q,\alpha) = \frac{\text{scale}}{V_s} F^2(q,\alpha).sin(\alpha) + \text{background} 12 12 13 13 where … … 15 15 .. math:: 16 16 17 F(q ) = &\ (\rho_c - \rho_s) V_c17 F(q,\alpha) = &\ (\rho_c - \rho_s) V_c 18 18 \frac{\sin \left( q \tfrac12 L\cos\alpha \right)} 19 19 {q \tfrac12 L\cos\alpha} -
sasmodels/models/core_shell_ellipsoid.py
r73e08ae rb7e8b94 162 162 163 163 q = 0.1 164 phi = pi/6 165 qx = q*cos(phi) 166 qy = q*sin(phi) 167 # After redefinition of angles find new reasonable values for unit test 168 #tests = [ 169 # # Accuracy tests based on content in test/utest_coreshellellipsoidXTmodel.py 170 # [{'radius_equat_core': 200.0, 171 # 'x_core': 0.1, 172 # 'thick_shell': 50.0, 173 # 'x_polar_shell': 0.2, 174 # 'sld_core': 2.0, 175 # 'sld_shell': 1.0, 176 # 'sld_solvent': 6.3, 177 # 'background': 0.001, 178 # 'scale': 1.0, 179 # }, 1.0, 0.00189402], 164 # tests had in old coords theta=0, phi=0; new coords theta=90, phi=0 165 qx = q*cos(pi/6.0) 166 qy = q*sin(pi/6.0) 167 phi = 0.0 168 # 11Jan2017 RKH sorted tests after redefinition of angles 169 tests = [ 170 # Accuracy tests based on content in test/utest_coreshellellipsoidXTmodel.py 171 [{'radius_equat_core': 200.0, 172 'x_core': 0.1, 173 'thick_shell': 50.0, 174 'x_polar_shell': 0.2, 175 'sld_core': 2.0, 176 'sld_shell': 1.0, 177 'sld_solvent': 6.3, 178 'background': 0.001, 179 'scale': 1.0, 180 }, 1.0, 0.00189402], 180 181 181 182 # Additional tests with larger range of parameters 182 # [{'background': 0.01}, 0.1, 11.6915], 183 184 # [{'radius_equat_core': 20.0, 185 # 'x_core': 200.0, 186 # 'thick_shell': 54.0, 187 # 'x_polar_shell': 3.0, 188 # 'sld_core': 20.0, 189 # 'sld_shell': 10.0, 190 # 'sld_solvent': 6.0, 191 # 'background': 0.0, 192 # 'scale': 1.0, 193 # }, 0.01, 8688.53], 194 195 # [{'background': 0.001}, (0.4, 0.5), 0.00690673], 196 197 # [{'radius_equat_core': 20.0, 198 # 'x_core': 200.0, 199 # 'thick_shell': 54.0, 200 # 'x_polar_shell': 3.0, 201 # 'sld_core': 20.0, 202 # 'sld_shell': 10.0, 203 # 'sld_solvent': 6.0, 204 # 'background': 0.01, 205 # 'scale': 0.01, 206 # }, (qx, qy), 0.0100002], 207 # ] 183 [{'background': 0.01}, 0.1, 11.6915], 184 185 [{'radius_equat_core': 20.0, 186 'x_core': 200.0, 187 'thick_shell': 54.0, 188 'x_polar_shell': 3.0, 189 'sld_core': 20.0, 190 'sld_shell': 10.0, 191 'sld_solvent': 6.0, 192 'background': 0.0, 193 'scale': 1.0, 194 }, 0.01, 8688.53], 195 # why does it need theta setting here, not globally above? 196 [{'background': 0.001, 'theta':90.0}, (0.4, 0.5), 0.00690673], 197 198 [{'radius_equat_core': 20.0, 199 'x_core': 200.0, 200 'thick_shell': 54.0, 201 'x_polar_shell': 3.0, 202 'sld_core': 20.0, 203 'sld_shell': 10.0, 204 'sld_solvent': 6.0, 205 'background': 0.01, 206 'scale': 0.01, 207 'theta': 90.0, 208 }, (qx, qy), 0.01000025], 209 ] -
sasmodels/models/cylinder.py
r4cdd0cc rb7e8b94 2 2 # Note: model title and parameter table are inserted automatically 3 3 r""" 4 The form factor is normalized by the particle volume V = \piR^2L. 4 5 5 For information about polarised and magnetic scattering, see 6 6 the :ref:`magnetism` documentation. … … 14 14 .. math:: 15 15 16 P(q,\alpha) = \frac{\text{scale}}{V} F^2(q,\alpha) + \text{background}16 P(q,\alpha) = \frac{\text{scale}}{V} F^2(q,\alpha).sin(\alpha) + \text{background} 17 17 18 18 where … … 25 25 \frac{J_1 \left(q R \sin \alpha\right)}{q R \sin \alpha} 26 26 27 and $\alpha$ is the angle between the axis of the cylinder and $\vec q$, $V $27 and $\alpha$ is the angle between the axis of the cylinder and $\vec q$, $V =\pi R^2L$ 28 28 is the volume of the cylinder, $L$ is the length of the cylinder, $R$ is the 29 29 radius of the cylinder, and $\Delta\rho$ (contrast) is the scattering length … … 35 35 .. math:: 36 36 37 F^2(q)=\int_{0}^{\pi/2}{F^2(q,\ theta)\sin(\theta)d\theta}37 F^2(q)=\int_{0}^{\pi/2}{F^2(q,\alpha)\sin(\alpha)d\alpha}=\int_{0}^{1}{F^2(q,u)du} 38 38 39 39 40 To provide easy access to the orientation of the cylinder, we define the 41 axis of the cylinder using two angles $\theta$ and $\phi$. Those angles 40 Numerical integration is simplified by a change of variable to $u = cos(\alpha)$ with 41 $sin(\alpha)=\sqrt{1-u^2}$. 42 43 The output of the 1D scattering intensity function for randomly oriented 44 cylinders is thus given by 45 46 .. math:: 47 48 P(q) = \frac{\text{scale}}{V} 49 \int_0^{\pi/2} F^2(q,\alpha) \sin \alpha\ d\alpha + \text{background} 50 51 52 NB: The 2nd virial coefficient of the cylinder is calculated based on the 53 radius and length values, and used as the effective radius for $S(q)$ 54 when $P(q) \cdot S(q)$ is applied. 55 56 For oriented cylinders, we define the direction of the 57 axis of the cylinder using two angles $\theta$ (note this is not the 58 same as the scattering angle used in q) and $\phi$. Those angles 42 59 are defined in :numref:`cylinder-angle-definition` . 43 60 … … 48 65 Definition of the angles for oriented cylinders. 49 66 50 51 NB: The 2nd virial coefficient of the cylinder is calculated based on the 52 radius and length values, and used as the effective radius for $S(q)$ 53 when $P(q) \cdot S(q)$ is applied. 54 55 The output of the 1D scattering intensity function for randomly oriented 56 cylinders is then given by 57 58 .. math:: 59 60 P(q) = \frac{\text{scale}}{V} 61 \int_0^{\pi/2} F^2(q,\alpha) \sin \alpha\ d\alpha + \text{background} 62 63 The $\theta$ and $\phi$ parameters are not used for the 1D output. 67 The $\theta$ and $\phi$ parameters only appear in the model when fitting 2d data. 64 68 65 69 Validation … … 74 78 75 79 P(q) = \int_0^{\pi/2} d\phi 76 \int_0^\pi p(\ alpha) P_0(q,\alpha) \sin \alpha\ d\alpha80 \int_0^\pi p(\theta) P_0(q,\theta) \sin \theta\ d\theta 77 81 78 82 79 83 where $p(\theta,\phi) = 1$ is the probability distribution for the orientation 80 and $P_0(q,\ alpha)$ is the scattering intensity for the fully oriented84 and $P_0(q,\theta)$ is the scattering intensity for the fully oriented 81 85 system, and then comparing to the 1D result. 82 86 … … 145 149 146 150 qx, qy = 0.2 * np.cos(2.5), 0.2 * np.sin(2.5) 147 # After redefinition of angles, find new tests values 148 #tests = [[{}, 0.2, 0.042761386790780453], 149 # [{}, [0.2], [0.042761386790780453]], 150 # [{'theta':10.0, 'phi':10.0}, (qx, qy), 0.03514647218513852], 151 # [{'theta':10.0, 'phi':10.0}, [(qx, qy)], [0.03514647218513852]], 152 # ] 151 # After redefinition of angles, find new tests values. Was 10 10 in old coords 152 tests = [[{}, 0.2, 0.042761386790780453], 153 [{}, [0.2], [0.042761386790780453]], 154 # new coords 155 [{'theta':80.1534480601659, 'phi':10.1510817110481}, (qx, qy), 0.03514647218513852], 156 [{'theta':80.1534480601659, 'phi':10.1510817110481}, [(qx, qy)], [0.03514647218513852]], 157 # old coords [{'theta':10.0, 'phi':10.0}, (qx, qy), 0.03514647218513852], 158 # [{'theta':10.0, 'phi':10.0}, [(qx, qy)], [0.03514647218513852]], 159 ] 153 160 del qx, qy # not necessary to delete, but cleaner 154 161 # ADDED by: RKH ON: 18Mar2016 renamed sld's etc -
sasmodels/models/elliptical_cylinder.py
ra807206 rfcb33e4 20 20 21 21 I(\vec q)=\frac{1}{V_\text{cyl}}\int{d\psi}\int{d\phi}\int{ 22 p(\theta,\phi,\psi)F^2(\vec q,\alpha,\psi)\sin(\ theta)d\theta}22 p(\theta,\phi,\psi)F^2(\vec q,\alpha,\psi)\sin(\alpha)d\alpha} 23 23 24 24 with the functions … … 26 26 .. math:: 27 27 28 F( \vecq,\alpha,\psi) = 2\frac{J_1(a)\sin(b)}{ab}28 F(q,\alpha,\psi) = 2\frac{J_1(a)\sin(b)}{ab} 29 29 30 30 where … … 32 32 .. math:: 33 33 34 a &= \vec q\sin(\alpha)\left[ 35 r^2_\text{major}\sin^2(\psi)+r^2_\text{minor}\cos(\psi) \right]^{1/2} 34 a = qr'\sin(\alpha) 35 36 b = q\frac{L}{2}\cos(\alpha) 37 38 r'=\frac{r_{minor}}{\sqrt{2}}\sqrt{(1+\nu^{2}) + (1-\nu^{2})cos(\psi)} 36 39 37 b &= \vec q\frac{L}{2}\cos(\alpha)38 40 39 and the angle $\ Psi$ is defined as the orientation of the major axis of the41 and the angle $\psi$ is defined as the orientation of the major axis of the 40 42 ellipse with respect to the vector $\vec q$. The angle $\alpha$ is the angle 41 43 between the axis of the cylinder and $\vec q$. … … 95 97 96 98 L A Feigin and D I Svergun, *Structure Analysis by Small-Angle X-Ray and 97 Neutron Scattering*, Plenum, New York, (1987) 99 Neutron Scattering*, Plenum, New York, (1987) [see table 3.4] 100 101 Authorship and Verification 102 ---------------------------- 103 104 * **Author:** 105 * **Last Modified by:** 106 * **Last Reviewed by:** Richard Heenan - corrected equation in docs **Date:** December 21, 2016 107 98 108 """ 99 109 -
sasmodels/models/lib/polevl.c
r0278e3f r447e9aa 28 28 * N 0 29 29 * 30 * The function p1evl() assumes that coef[N]= 1.0 and is30 * The function p1evl() assumes that C_N = 1.0 and is 31 31 * omitted from the array. Its calling arguments are 32 32 * otherwise the same as polevl(). -
sasmodels/models/lib/sas_J0.c
r1596de3 rc8902ac 55 55 #if FLOAT_SIZE>4 56 56 //Cephes double precission 57 double j0(double x);57 double cephes_j0(double x); 58 58 59 59 constant double PPJ0[8] = { … … 147 147 }; 148 148 149 double j0(double x)149 double cephes_j0(double x) 150 150 { 151 151 double w, z, p, q, xn; … … 186 186 #else 187 187 //Cephes single precission 188 float j0f(float x);188 float cephes_j0f(float x); 189 189 190 190 constant float MOJ0[8] = { … … 221 221 }; 222 222 223 float j0f(float x)223 float cephes_j0f(float x) 224 224 { 225 225 float xx, w, z, p, q, xn; … … 257 257 258 258 #if FLOAT_SIZE>4 259 #define sas_J0 j0259 #define sas_J0 cephes_j0 260 260 #else 261 #define sas_J0 j0f261 #define sas_J0 cephes_j0f 262 262 #endif -
sasmodels/models/lib/sas_J1.c
r1596de3 rc8902ac 42 42 #if FLOAT_SIZE>4 43 43 //Cephes double pression function 44 double j1(double x);44 double cephes_j1(double x); 45 45 46 46 constant double RPJ1[8] = { … … 106 106 0.0 }; 107 107 108 double j1(double x)108 double cephes_j1(double x) 109 109 { 110 110 … … 144 144 #else 145 145 //Single precission version of cephes 146 float j1f(float x);146 float cephes_j1f(float x); 147 147 148 148 constant float JPJ1[8] = { … … 179 179 }; 180 180 181 float j1f(float x)181 float cephes_j1f(float x) 182 182 { 183 183 … … 211 211 212 212 #if FLOAT_SIZE>4 213 #define sas_J1 j1213 #define sas_J1 cephes_j1 214 214 #else 215 #define sas_J1 j1f215 #define sas_J1 cephes_j1f 216 216 #endif 217 217 -
sasmodels/models/lib/sas_JN.c
r1596de3 rc8902ac 50 50 #if FLOAT_SIZE > 4 51 51 52 double jn( int n, double x );53 double jn( int n, double x ) {52 double cephes_jn( int n, double x ); 53 double cephes_jn( int n, double x ) { 54 54 55 55 // PAK: seems to be machine epsilon/2 … … 75 75 76 76 if( n == 0 ) 77 return( sign * j0(x) );77 return( sign * cephes_j0(x) ); 78 78 if( n == 1 ) 79 return( sign * j1(x) );79 return( sign * cephes_j1(x) ); 80 80 if( n == 2 ) 81 return( sign * (2.0 * j1(x) / x -j0(x)) );81 return( sign * (2.0 * cephes_j1(x) / x - cephes_j0(x)) ); 82 82 83 83 if( x < MACHEP ) … … 112 112 113 113 if( fabs(pk) > fabs(pkm1) ) 114 ans = j1(x)/pk;114 ans = cephes_j1(x)/pk; 115 115 else 116 ans = j0(x)/pkm1;116 ans = cephes_j0(x)/pkm1; 117 117 118 118 return( sign * ans ); … … 121 121 #else 122 122 123 float jnf(int n, float x);124 float jnf(int n, float x)123 float cephes_jnf(int n, float x); 124 float cephes_jnf(int n, float x) 125 125 { 126 126 // PAK: seems to be machine epsilon/2 … … 146 146 147 147 if( n == 0 ) 148 return( sign * j0f(x) );148 return( sign * cephes_j0f(x) ); 149 149 if( n == 1 ) 150 return( sign * j1f(x) );150 return( sign * cephes_j1f(x) ); 151 151 if( n == 2 ) 152 return( sign * (2.0 * j1f(x) / x -j0f(x)) );152 return( sign * (2.0 * cephes_j1f(x) / x - cephes_j0f(x)) ); 153 153 154 154 if( x < MACHEP ) … … 189 189 190 190 if( r > ans ) /* if( fabs(pk) > fabs(pkm1) ) */ 191 ans = sign * j1f(x)/pk;191 ans = sign * cephes_j1f(x)/pk; 192 192 else 193 ans = sign * j0f(x)/pkm1;193 ans = sign * cephes_j0f(x)/pkm1; 194 194 return( ans ); 195 195 } … … 197 197 198 198 #if FLOAT_SIZE>4 199 #define sas_JN jn199 #define sas_JN cephes_jn 200 200 #else 201 #define sas_JN jnf201 #define sas_JN cephes_jnf 202 202 #endif -
sasmodels/models/stacked_disks.py
r07300ea rb7e8b94 148 148 sld_layer=0.0, 149 149 sld_solvent=5.0, 150 theta= 0,150 theta=90, 151 151 phi=0) 152 #After redefinition to spherical coordinates find new reasonable test values 153 #tests = [ 154 # # Accuracy tests based on content in test/utest_extra_models.py. 155 # # Added 2 tests with n_stacked = 5 using SasView 3.1.2 - PDB 156 # [{'thick_core': 10.0, 157 # 'thick_layer': 15.0, 158 # 'radius': 3000.0, 159 # 'n_stacking': 1.0, 160 # 'sigma_d': 0.0, 161 # 'sld_core': 4.0, 162 # 'sld_layer': -0.4, 163 # 'solvent_sd': 5.0, 164 # 'theta': 0.0, 165 # 'phi': 0.0, 166 # 'scale': 0.01, 167 # 'background': 0.001, 168 # }, 0.001, 5075.12], 169 170 # [{'thick_core': 10.0, 171 # 'thick_layer': 15.0, 172 # 'radius': 3000.0, 173 # 'n_stacking': 5.0, 174 # 'sigma_d': 0.0, 175 # 'sld_core': 4.0, 176 # 'sld_layer': -0.4, 177 # 'solvent_sd': 5.0, 178 # 'theta': 0.0, 179 # 'phi': 0.0, 180 # 'scale': 0.01, 181 # 'background': 0.001, 182 # }, 0.001, 5065.12793824], 183 184 # [{'thick_core': 10.0, 185 # 'thick_layer': 15.0, 186 # 'radius': 3000.0, 187 # 'n_stacking': 5.0, 188 # 'sigma_d': 0.0, 189 # 'sld_core': 4.0, 190 # 'sld_layer': -0.4, 191 # 'solvent_sd': 5.0, 192 # 'theta': 0.0, 193 # 'phi': 0.0, 194 # 'scale': 0.01, 195 # 'background': 0.001, 196 # }, 0.164, 0.0127673597265], 197 198 # [{'thick_core': 10.0, 199 # 'thick_layer': 15.0, 200 # 'radius': 3000.0, 201 # 'n_stacking': 1.0, 202 # 'sigma_d': 0.0, 203 # 'sld_core': 4.0, 204 # 'sld_layer': -0.4, 205 # 'solvent_sd': 5.0, 206 # 'theta': 0.0, 207 # 'phi': 0.0, 208 # 'scale': 0.01, 209 # 'background': 0.001, 210 # }, [0.001, 90.0], [5075.12, 0.001]], 211 212 # [{'thick_core': 10.0, 213 # 'thick_layer': 15.0, 214 # 'radius': 3000.0, 215 # 'n_stacking': 1.0, 216 # 'sigma_d': 0.0, 217 # 'sld_core': 4.0, 218 # 'sld_layer': -0.4, 219 # 'solvent_sd': 5.0, 220 # 'theta': 0.0, 221 # 'phi': 0.0, 222 # 'scale': 0.01, 223 # 'background': 0.001, 224 # }, ([0.4, 0.5]), [0.00105074, 0.00121761]], 225 226 # [{'thick_core': 10.0, 227 # 'thick_layer': 15.0, 228 # 'radius': 3000.0, 229 # 'n_stacking': 1.0, 230 # 'sigma_d': 0.0, 231 # 'sld_core': 4.0, 232 # 'sld_layer': -0.4, 233 # 'solvent_sd': 5.0, 234 # 'theta': 0.0, 235 # 'phi': 0.0, 236 # 'scale': 0.01, 237 # 'background': 0.001, 238 # }, ([1.3, 1.57]), [0.0010039, 0.0010038]], 239 # ] 240 # 21Mar2016 RKH notes that unit tests all have n_stacking=1, ought to test other values 241 152 # After redefinition of spherical coordinates - 153 # tests had in old coords theta=0, phi=0; new coords theta=90, phi=0 154 # but should not matter here as so far all the tests are 1D not 2D 155 tests = [ 156 # Accuracy tests based on content in test/utest_extra_models.py. 157 # Added 2 tests with n_stacked = 5 using SasView 3.1.2 - PDB; for which alas q=0.001 values seem closer to n_stacked=1 not 5, changed assuming my 4.1 code OK, RKH 158 [{'thick_core': 10.0, 159 'thick_layer': 15.0, 160 'radius': 3000.0, 161 'n_stacking': 1.0, 162 'sigma_d': 0.0, 163 'sld_core': 4.0, 164 'sld_layer': -0.4, 165 'solvent_sd': 5.0, 166 'theta': 90.0, 167 'phi': 0.0, 168 'scale': 0.01, 169 'background': 0.001, 170 }, 0.001, 5075.12], 171 [{'thick_core': 10.0, 172 'thick_layer': 15.0, 173 'radius': 3000.0, 174 'n_stacking': 5, 175 'sigma_d': 0.0, 176 'sld_core': 4.0, 177 'sld_layer': -0.4, 178 'solvent_sd': 5.0, 179 'theta': 90.0, 180 'phi': 0.0, 181 'scale': 0.01, 182 'background': 0.001, 183 # }, 0.001, 5065.12793824], n_stacking=1 not 5 ? slight change in value here 11jan2017, check other cpu types 184 # }, 0.001, 5075.11570493], 185 }, 0.001, 25325.635693], 186 [{'thick_core': 10.0, 187 'thick_layer': 15.0, 188 'radius': 3000.0, 189 'n_stacking': 5, 190 'sigma_d': 0.0, 191 'sld_core': 4.0, 192 'sld_layer': -0.4, 193 'solvent_sd': 5.0, 194 'theta': 90.0, 195 'phi': 0.0, 196 'scale': 0.01, 197 'background': 0.001, 198 # }, 0.164, 0.0127673597265], n_stacking=1 not 5 ? slight change in value here 11jan2017, check other cpu types 199 # }, 0.164, 0.01480812968], 200 }, 0.164, 0.0598367986509], 201 202 [{'thick_core': 10.0, 203 'thick_layer': 15.0, 204 'radius': 3000.0, 205 'n_stacking': 1.0, 206 'sigma_d': 0.0, 207 'sld_core': 4.0, 208 'sld_layer': -0.4, 209 'solvent_sd': 5.0, 210 'theta': 90.0, 211 'phi': 0.0, 212 'scale': 0.01, 213 'background': 0.001, 214 # second test here was at q=90, changed it to q=5, note I(q) is then just value of flat background 215 }, [0.001, 5.0], [5075.12, 0.001]], 216 217 [{'thick_core': 10.0, 218 'thick_layer': 15.0, 219 'radius': 3000.0, 220 'n_stacking': 1.0, 221 'sigma_d': 0.0, 222 'sld_core': 4.0, 223 'sld_layer': -0.4, 224 'solvent_sd': 5.0, 225 'theta': 90.0, 226 'phi': 0.0, 227 'scale': 0.01, 228 'background': 0.001, 229 }, ([0.4, 0.5]), [0.00105074, 0.00121761]], 230 231 [{'thick_core': 10.0, 232 'thick_layer': 15.0, 233 'radius': 3000.0, 234 'n_stacking': 1.0, 235 'sigma_d': 0.0, 236 'sld_core': 4.0, 237 'sld_layer': -0.4, 238 'solvent_sd': 5.0, 239 'theta': 90.0, 240 'phi': 0.0, 241 'scale': 0.01, 242 'background': 0.001, 243 }, ([1.3, 1.57]), [0.0010039, 0.0010038]], 244 ] 245 # 11Jan2017 RKH checking unit test agai, note they are all 1D, no 2D 246 -
sasmodels/resolution2d.py
r40a87fa r7e94989 64 64 # just need q_calc and weights 65 65 self.data = data 66 self.index = index 67 68 self.qx_data = data.qx_data[ index]69 self.qy_data = data.qy_data[ index]70 self.q_data = data.q_data[ index]66 self.index = index if index is not None else slice(None) 67 68 self.qx_data = data.qx_data[self.index] 69 self.qy_data = data.qy_data[self.index] 70 self.q_data = data.q_data[self.index] 71 71 72 72 dqx = getattr(data, 'dqx_data', None) … … 74 74 if dqx is not None and dqy is not None: 75 75 # Here dqx and dqy mean dq_parr and dq_perp 76 self.dqx_data = dqx[ index]77 self.dqy_data = dqy[ index]76 self.dqx_data = dqx[self.index] 77 self.dqy_data = dqy[self.index] 78 78 ## Remove singular points if exists 79 79 self.dqx_data[self.dqx_data < SIGMA_ZERO] = SIGMA_ZERO … … 126 126 # The angle (phi) of the original q point 127 127 q_phi = np.arctan(q_phi).repeat(nbins)\ 128 .reshape( nq, nbins).transpose().flatten()128 .reshape([nq, nbins]).transpose().flatten() 129 129 ## Find Gaussian weight for each dq bins: The weight depends only 130 130 # on r-direction (The integration may not need) -
sasmodels/sasview_model.py
r8977226 r64614ad 583 583 % type(qdist)) 584 584 585 def get_composition_models(self): 586 """ 587 Returns usable models that compose this model 588 """ 589 s_model = None 590 p_model = None 591 if hasattr(self._model_info, "composition") \ 592 and self._model_info.composition is not None: 593 p_model = _make_model_from_info(self._model_info.composition[1][0])() 594 s_model = _make_model_from_info(self._model_info.composition[1][1])() 595 return p_model, s_model 596 585 597 def calculate_Iq(self, qx, qy=None): 586 598 # type: (Sequence[float], Optional[Sequence[float]]) -> np.ndarray
Note: See TracChangeset
for help on using the changeset viewer.