Changeset a0ebc96 in sasmodels
- Timestamp:
- Apr 11, 2017 2:24:40 AM (8 years ago)
- Branches:
- master, core_shell_microgels, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
- Children:
- 535fee6
- Parents:
- 8678a34 (diff), e645373 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - Files:
-
- 1 added
- 1 deleted
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/models/barbell.py
r0b56f38 r9802ab3 68 68 The 2D scattering intensity is calculated similar to the 2D cylinder model. 69 69 70 .. figure:: img/cylinder_angle_definition. jpg70 .. figure:: img/cylinder_angle_definition.png 71 71 72 72 Definition of the angles for oriented 2D barbells. … … 108 108 ["radius", "Ang", 20, [0, inf], "volume", "Cylindrical bar radius"], 109 109 ["length", "Ang", 400, [0, inf], "volume", "Cylinder bar length"], 110 ["theta", "degrees", 60, [- inf, inf], "orientation", "In planeangle"],111 ["phi", "degrees", 60, [- inf, inf], "orientation", "Out of plane angle"],110 ["theta", "degrees", 60, [-360, 360], "orientation", "Barbell axis to beam angle"], 111 ["phi", "degrees", 60, [-360, 360], "orientation", "Rotation about beam"], 112 112 ] 113 113 # pylint: enable=bad-whitespace, line-too-long -
sasmodels/models/bcc_paracrystal.py
r1f65db5 r69e1afc 123 123 ["sld", "1e-6/Ang^2", 4, [-inf, inf], "sld", "Particle scattering length density"], 124 124 ["sld_solvent", "1e-6/Ang^2", 1, [-inf, inf], "sld", "Solvent scattering length density"], 125 ["theta", "degrees", 60, [- inf, inf], "orientation", "In planeangle"],126 ["phi", "degrees", 60, [- inf, inf], "orientation", "Out of plane angle"],127 ["psi", "degrees", 60, [- inf, inf], "orientation", "Out of plane angle"]125 ["theta", "degrees", 60, [-360, 360], "orientation", "c axis to beam angle"], 126 ["phi", "degrees", 60, [-360, 360], "orientation", "rotation about beam"], 127 ["psi", "degrees", 60, [-360, 360], "orientation", "rotation about c axis"] 128 128 ] 129 129 # pylint: enable=bad-whitespace, line-too-long … … 148 148 [{ }, 149 149 [0.001, q, 0.215268], [1.46601394721, 2.85851284174, 0.00866710287078]], 150 ] 150 [{'theta':20.0,'phi':30,'psi':40.0},(-0.017,0.035),2082.20264399 ], 151 [{'theta':20.0,'phi':30,'psi':40.0},(-0.081,0.011),0.436323144781 ] 152 ] -
sasmodels/models/capped_cylinder.py
r0b56f38 r9802ab3 71 71 The 2D scattering intensity is calculated similar to the 2D cylinder model. 72 72 73 .. figure:: img/cylinder_angle_definition. jpg73 .. figure:: img/cylinder_angle_definition.png 74 74 75 75 Definition of the angles for oriented 2D cylinders. … … 129 129 ["radius_cap", "Ang", 20, [0, inf], "volume", "Cap radius"], 130 130 ["length", "Ang", 400, [0, inf], "volume", "Cylinder length"], 131 ["theta", "degrees", 60, [- inf, inf], "orientation", "inclinationangle"],132 ["phi", "degrees", 60, [- inf, inf], "orientation", "deflection angle"],131 ["theta", "degrees", 60, [-360, 360], "orientation", "cylinder axis to beam angle"], 132 ["phi", "degrees", 60, [-360, 360], "orientation", "rotation about beam"], 133 133 ] 134 134 # pylint: enable=bad-whitespace, line-too-long -
sasmodels/models/core_shell_bicelle.py
r0b56f38 r9802ab3 47 47 .. math:: 48 48 49 49 \begin{align} 50 50 F(Q,\alpha) = &\bigg[ 51 51 (\rho_c - \rho_f) V_c \frac{2J_1(QRsin \alpha)}{QRsin\alpha}\frac{sin(QLcos\alpha/2)}{Q(L/2)cos\alpha} \\ … … 63 63 cylinders is then given by integrating over all possible $\theta$ and $\phi$. 64 64 65 The *theta* and *phi* parameters are not used for the 1D output. 65 For oriented bicelles the *theta*, and *phi* orientation parameters will appear when fitting 2D data, 66 see the :ref:`cylinder` model for further information. 66 67 Our implementation of the scattering kernel and the 1D scattering intensity 67 68 use the c-library from NIST. 68 69 69 .. figure:: img/cylinder_angle_definition. jpg70 .. figure:: img/cylinder_angle_definition.png 70 71 71 Definition of the angles for the oriented core shell bicelle tmodel. 72 Definition of the angles for the oriented core shell bicelle model, 73 note that the cylinder axis of the bicelle starts along the beam direction 74 when $\theta = \phi = 0$. 72 75 73 76 … … 135 138 ["sld_rim", "1e-6/Ang^2", 4, [-inf, inf], "sld", "Cylinder rim scattering length density"], 136 139 ["sld_solvent", "1e-6/Ang^2", 1, [-inf, inf], "sld", "Solvent scattering length density"], 137 ["theta", "degrees", 90, [- inf, inf], "orientation", "In planeangle"],138 ["phi", "degrees", 0, [- inf, inf], "orientation", "Out of plane angle"],140 ["theta", "degrees", 90, [-360, 360], "orientation", "cylinder axis to beam angle"], 141 ["phi", "degrees", 0, [-360, 360], "orientation", "rotation about beam"] 139 142 ] 140 143 … … 160 163 qy = q*sin(pi/6.0) 161 164 tests = [[{}, 0.05, 7.4883545957], 162 [{'theta':80., 'phi':10.}, (qx, qy), 2.81048892474 ] ,165 [{'theta':80., 'phi':10.}, (qx, qy), 2.81048892474 ] 163 166 ] 164 167 del qx, qy # not necessary to delete, but cleaner -
sasmodels/models/core_shell_bicelle_elliptical.c
r44e8a93 rdedcf34 24 24 double si1,si2,be1,be2; 25 25 // core_shell_bicelle_elliptical, RKH Dec 2016, based on elliptical_cylinder and core_shell_bicelle 26 // tested against limiting cases of cylinder, elliptical_cylinder and core_shell_bicelle26 // tested against limiting cases of cylinder, elliptical_cylinder, stacked_discs, and core_shell_bicelle 27 27 // const double uplim = M_PI_4; 28 28 const double halfheight = 0.5*length; … … 34 34 35 35 const double r_major = r_minor * x_core; 36 const double r A = 0.5*(square(r_major) + square(r_minor));37 const double r B = 0.5*(square(r_major) - square(r_minor));36 const double r2A = 0.5*(square(r_major) + square(r_minor)); 37 const double r2B = 0.5*(square(r_major) - square(r_minor)); 38 38 const double dr1 = (rhoc-rhoh) *M_PI*r_minor*r_major*(2.0*halfheight);; 39 39 const double dr2 = (rhor-rhosolv)*M_PI*(r_minor+thick_rim)*(r_major+thick_rim)*2.0*(halfheight+thick_face); … … 60 60 //const double beta = ( Gauss76Z[j]*(vbj-vaj) + vaj + vbj )/2.0; 61 61 const double beta = ( Gauss76Z[j] +1.0)*M_PI_2; 62 const double rr = sqrt(r A - rB*cos(beta));62 const double rr = sqrt(r2A - r2B*cos(beta)); 63 63 double besarg1 = q*rr*sin_alpha; 64 64 double besarg2 = q*(rr+thick_rim)*sin_alpha; -
sasmodels/models/core_shell_bicelle_elliptical.py
r16a8c63 r9802ab3 76 76 bicelles is then given by integrating over all possible $\alpha$ and $\psi$. 77 77 78 For oriented bicell les the *theta*, *phi* and *psi* orientation parameters onlyappear when fitting 2D data,78 For oriented bicelles the *theta*, *phi* and *psi* orientation parameters will appear when fitting 2D data, 79 79 see the :ref:`elliptical-cylinder` model for further information. 80 80 … … 119 119 ["radius", "Ang", 30, [0, inf], "volume", "Cylinder core radius"], 120 120 ["x_core", "None", 3, [0, inf], "volume", "axial ratio of core, X = r_polar/r_equatorial"], 121 ["thick_rim", "Ang", 8, [0, inf], "volume", "Rim shell thickness"],122 ["thick_face", "Ang", 14, [0, inf], "volume", "Cylinder face thickness"],123 ["length", "Ang", 50, [0, inf], "volume", "Cylinder length"],121 ["thick_rim", "Ang", 8, [0, inf], "volume", "Rim shell thickness"], 122 ["thick_face", "Ang", 14, [0, inf], "volume", "Cylinder face thickness"], 123 ["length", "Ang", 50, [0, inf], "volume", "Cylinder length"], 124 124 ["sld_core", "1e-6/Ang^2", 4, [-inf, inf], "sld", "Cylinder core scattering length density"], 125 125 ["sld_face", "1e-6/Ang^2", 7, [-inf, inf], "sld", "Cylinder face scattering length density"], 126 126 ["sld_rim", "1e-6/Ang^2", 1, [-inf, inf], "sld", "Cylinder rim scattering length density"], 127 127 ["sld_solvent", "1e-6/Ang^2", 6, [-inf, inf], "sld", "Solvent scattering length density"], 128 ["theta", "degrees", 90, [-360, 360], "orientation", "In planeangle"],129 ["phi", "degrees", 0, [-360, 360], "orientation", "Out of plane angle"],130 ["psi", "degrees", 0, [-360, 360], "orientation", "Major axis angle relative to Q"],128 ["theta", "degrees", 90.0, [-360, 360], "orientation", "cylinder axis to beam angle"], 129 ["phi", "degrees", 0, [-360, 360], "orientation", "rotation about beam"], 130 ["psi", "degrees", 0, [-360, 360], "orientation", "rotation about cylinder axis"] 131 131 ] 132 132 -
sasmodels/models/core_shell_cylinder.py
r0b56f38 r9b79f29 117 117 ["length", "Ang", 400, [0, inf], "volume", 118 118 "Cylinder length"], 119 ["theta", "degrees", 60, [- inf, inf], "orientation",120 " In planeangle"],121 ["phi", "degrees", 60, [-inf, inf], "orientation",122 " Out of plane angle"],119 ["theta", "degrees", 60, [-360, 360], "orientation", 120 "cylinder axis to beam angle"], 121 ["phi", "degrees", 60, [-360, 360], "orientation", 122 "rotation about beam"], 123 123 ] 124 124 -
sasmodels/models/core_shell_ellipsoid.py
rdaeef4c r9802ab3 77 77 F^2(q)=\int_{0}^{\pi/2}{F^2(q,\alpha)\sin(\alpha)d\alpha} 78 78 79 For oriented ellipsoids the *theta*, *phi* and *psi* orientation parameters will appear when fitting 2D data, 80 see the :ref:`elliptical-cylinder` model for further information. 79 81 80 82 References … … 132 134 ["sld_shell", "1e-6/Ang^2", 1, [-inf, inf], "sld", "Shell scattering length density"], 133 135 ["sld_solvent", "1e-6/Ang^2", 6.3, [-inf, inf], "sld", "Solvent scattering length density"], 134 ["theta", "degrees", 0, [- inf, inf], "orientation", "Oblate orientation wrt incoming beam"],135 ["phi", "degrees", 0, [- inf, inf], "orientation", "Oblate orientation in the plane of the detector"],136 ["theta", "degrees", 0, [-360, 360], "orientation", "elipsoid axis to beam angle"], 137 ["phi", "degrees", 0, [-360, 360], "orientation", "rotation about beam"], 136 138 ] 137 139 # pylint: enable=bad-whitespace, line-too-long -
sasmodels/models/core_shell_parallelepiped.py
r1f65db5 r9b79f29 153 153 ["thick_rim_c", "Ang", 10, [0, inf], "volume", 154 154 "Thickness of C rim"], 155 ["theta", "degrees", 0, [- inf, inf], "orientation",156 " In planeangle"],157 ["phi", "degrees", 0, [- inf, inf], "orientation",158 " Out of plane angle"],159 ["psi", "degrees", 0, [- inf, inf], "orientation",160 " Rotation angle around its own c axis against q plane"],155 ["theta", "degrees", 0, [-360, 360], "orientation", 156 "c axis to beam angle"], 157 ["phi", "degrees", 0, [-360, 360], "orientation", 158 "rotation about beam"], 159 ["psi", "degrees", 0, [-360, 360], "orientation", 160 "rotation about c axis"], 161 161 ] 162 162 -
sasmodels/models/cylinder.py
r3fd0499 r9802ab3 61 61 .. _cylinder-angle-definition: 62 62 63 .. figure:: img/cylinder_angle_definition. jpg63 .. figure:: img/cylinder_angle_definition.png 64 64 65 Definition of the angles for oriented cylinders. 65 Definition of the $\theta$ and $\phi$ orientation angles for a cylinder relative 66 to the beam line coordinates, plus an indication of their orientation distributions 67 which are described as rotations about each of the perpendicular axes $\delta_1$ and $\delta_2$ 68 in the frame of the cylinder itself, which when $\theta = \phi = 0$ are parallel to the $Y$ and $X$ axes. 66 69 67 70 .. figure:: img/cylinder_angle_projection.png … … 69 72 Examples for oriented cylinders. 70 73 71 The $\theta$ and $\phi$ parameters only appear in the model when fitting 2d data. 74 The $\theta$ and $\phi$ parameters to orient the cylinder only appear in the model when fitting 2d data. 75 On introducing "Orientational Distribution" in the angles, "distribution of theta" and "distribution of phi" parameters will 76 appear. These are actually rotations about the axes $\delta_1$ and $\delta_2$ of the cylinder, which when $\theta = \phi = 0$ are parallel 77 to the $Y$ and $X$ axes of the instrument respectively. Some experimentation may be required to understand the 2d patterns fully. 78 (Earlier implementations had numerical integration issues in some circumstances when orientation distributions passed through 90 degrees, such 79 situations, with very broad distributions, should still be approached with care.) 72 80 73 81 Validation … … 127 135 ["length", "Ang", 400, [0, inf], "volume", 128 136 "Cylinder length"], 129 ["theta", "degrees", 60, [- inf, inf], "orientation",130 " latitude"],131 ["phi", "degrees", 60, [-inf, inf], "orientation",132 " longitude"],137 ["theta", "degrees", 60, [-360, 360], "orientation", 138 "cylinder axis to beam angle"], 139 ["phi", "degrees", 60, [-360, 360], "orientation", 140 "rotation about beam"], 133 141 ] 134 142 -
sasmodels/models/ellipsoid.py
r0b56f38 r9b79f29 151 151 ["radius_equatorial", "Ang", 400, [0, inf], "volume", 152 152 "Equatorial radius"], 153 ["theta", "degrees", 60, [- inf, inf], "orientation",154 " In planeangle"],155 ["phi", "degrees", 60, [- inf, inf], "orientation",156 " Out of plane angle"],153 ["theta", "degrees", 60, [-360, 360], "orientation", 154 "ellipsoid axis to beam angle"], 155 ["phi", "degrees", 60, [-360, 360], "orientation", 156 "rotation about beam"], 157 157 ] 158 158 -
sasmodels/models/elliptical_cylinder.py
r16a8c63 r9802ab3 57 57 define the axis of the cylinder using two angles $\theta$, $\phi$ and $\Psi$ 58 58 (see :ref:`cylinder orientation <cylinder-angle-definition>`). The angle 59 $\Psi$ is the rotational angle around its own long_c axis against the $q$ plane. 60 For example, $\Psi = 0$ when the $r_\text{minor}$ axis is parallel to the 61 $x$ axis of the detector. 59 $\Psi$ is the rotational angle around its own long_c axis. 62 60 63 61 All angle parameters are valid and given only for 2D calculation; ie, an … … 66 64 .. figure:: img/elliptical_cylinder_angle_definition.png 67 65 68 Definition of angles for oriented elliptical cylinder, where axis_ratio >1,69 and angle $\Psi$ is a rotation around the axis of the cylinder.66 Definition of angles for oriented elliptical cylinder, where axis_ratio is drawn >1, 67 and angle $\Psi$ is now a rotation around the axis of the cylinder. 70 68 71 69 .. figure:: img/elliptical_cylinder_angle_projection.png … … 73 71 Examples of the angles for oriented elliptical cylinders against the 74 72 detector plane, with $\Psi$ = 0. 73 74 The $\theta$ and $\phi$ parameters to orient the cylinder only appear in the model when fitting 2d data. 75 On introducing "Orientational Distribution" in the angles, "distribution of theta" and "distribution of phi" parameters will 76 appear. These are actually rotations about the axes $\delta_1$ and $\delta_2$ of the cylinder, the $b$ and $a$ axes of the 77 cylinder cross section. (When $\theta = \phi = 0$ these are parallel to the $Y$ and $X$ axes of the instrument.) 78 The third orientation distribution, in $\psi$, is about the $c$ axis of the particle. Some experimentation may be required to 79 understand the 2d patterns fully. (Earlier implementations had numerical integration issues in some circumstances when orientation 80 distributions passed through 90 degrees, such situations, with very broad distributions, should still be approached with care.) 75 81 76 82 NB: The 2nd virial coefficient of the cylinder is calculated based on the … … 126 132 ["sld", "1e-6/Ang^2", 4.0, [-inf, inf], "sld", "Cylinder scattering length density"], 127 133 ["sld_solvent", "1e-6/Ang^2", 1.0, [-inf, inf], "sld", "Solvent scattering length density"], 128 ["theta", "degrees", 90.0, [-360, 360], "orientation", " In planeangle"],129 ["phi", "degrees", 0, [-360, 360], "orientation", " Out of plane angle"],130 ["psi", "degrees", 0, [-360, 360], "orientation", " Major axis angle relative to Q"]]134 ["theta", "degrees", 90.0, [-360, 360], "orientation", "cylinder axis to beam angle"], 135 ["phi", "degrees", 0, [-360, 360], "orientation", "rotation about beam"], 136 ["psi", "degrees", 0, [-360, 360], "orientation", "rotation about cylinder axis"]] 131 137 132 138 # pylint: enable=bad-whitespace, line-too-long -
sasmodels/models/fcc_paracrystal.py
r1f65db5 r69e1afc 111 111 ["sld", "1e-6/Ang^2", 4, [-inf, inf], "sld", "Particle scattering length density"], 112 112 ["sld_solvent", "1e-6/Ang^2", 1, [-inf, inf], "sld", "Solvent scattering length density"], 113 ["theta", "degrees", 60, [-inf, inf], "orientation", "In planeangle"],114 ["phi", "degrees", 60, [-inf, inf], "orientation", "Out of plane angle"],115 ["psi", "degrees", 60, [-inf, inf], "orientation", "Out of plane angle"]113 ["theta", "degrees", 60, [-360, 360], "orientation", "c axis to beam angle"], 114 ["phi", "degrees", 60, [-360, 360], "orientation", "rotation about beam"], 115 ["psi", "degrees", 60, [-360, 360], "orientation", "rotation about c axis"] 116 116 ] 117 117 # pylint: enable=bad-whitespace, line-too-long … … 129 129 psi_pd=15, psi_pd_n=0, 130 130 ) 131 # april 6 2017, rkh add unit tests, NOT compared with any other calc method, assume correct! 132 # add 2d test later 131 # april 10 2017, rkh add unit tests, NOT compared with any other calc method, assume correct! 133 132 q =4.*pi/220. 134 133 tests = [ 135 134 [{ }, 136 135 [0.001, q, 0.215268], [0.275164706668, 5.7776842567, 0.00958167119232]], 136 [{}, (-0.047,-0.007), 238.103096286], 137 [{}, (0.053,0.063), 0.863609587796 ], 137 138 ] -
sasmodels/models/hollow_cylinder.py
r0b56f38 r9b79f29 82 82 ["sld", "1/Ang^2", 6.3, [-inf, inf], "sld", "Cylinder sld"], 83 83 ["sld_solvent", "1/Ang^2", 1, [-inf, inf], "sld", "Solvent sld"], 84 ["theta", "degrees", 90, [-360, 360], "orientation", " Thetaangle"],85 ["phi", "degrees", 0, [-360, 360], "orientation", " Phi angle"],84 ["theta", "degrees", 90, [-360, 360], "orientation", "Cylinder axis to beam angle"], 85 ["phi", "degrees", 0, [-360, 360], "orientation", "Rotation about beam"], 86 86 ] 87 87 # pylint: enable=bad-whitespace, line-too-long -
sasmodels/models/parallelepiped.py
rafd4692 r9802ab3 9 9 ---------- 10 10 11 |This model calculates the scattering from a rectangular parallelepiped12 |(\:numref:`parallelepiped-image`\).13 |If you need to apply polydispersity, see also :ref:`rectangular-prism`.11 This model calculates the scattering from a rectangular parallelepiped 12 (\:numref:`parallelepiped-image`\). 13 If you need to apply polydispersity, see also :ref:`rectangular-prism`. 14 14 15 15 .. _parallelepiped-image: … … 67 67 68 68 \mu &= qB 69 70 69 71 70 The scattering intensity per unit volume is returned in units of |cm^-1|. … … 113 112 detector plane. 114 113 114 On introducing "Orientational Distribution" in the angles, "distribution of theta" and "distribution of phi" parameters will 115 appear. These are actually rotations about axes $\delta_1$ and $\delta_2$ of the parallelepiped, perpendicular to the $a$ x $c$ and $b$ x $c$ faces. 116 (When $\theta = \phi = 0$ these are parallel to the $Y$ and $X$ axes of the instrument.) The third orientation distribution, in $\psi$, is 117 about the $c$ axis of the particle, perpendicular to the $a$ x $b$ face. Some experimentation may be required to 118 understand the 2d patterns fully. (Earlier implementations had numerical integration issues in some circumstances when orientation 119 distributions passed through 90 degrees, such situations, with very broad distributions, should still be approached with care.) 120 121 115 122 For a given orientation of the parallelepiped, the 2D form factor is 116 123 calculated as … … 168 175 169 176 * **Author:** This model is based on form factor calculations implemented 170 in a c-library provided by the NIST Center for Neutron Research (Kline, 2006).177 in a c-library provided by the NIST Center for Neutron Research (Kline, 2006). 171 178 * **Last Modified by:** Paul Kienzle **Date:** April 05, 2017 172 179 * **Last Reviewed by:** Richard Heenan **Date:** April 06, 2017 … … 205 212 ["length_c", "Ang", 400, [0, inf], "volume", 206 213 "Larger side of the parallelepiped"], 207 ["theta", "degrees", 60, [- inf, inf], "orientation",208 " In planeangle"],209 ["phi", "degrees", 60, [- inf, inf], "orientation",210 " Out of plane angle"],211 ["psi", "degrees", 60, [- inf, inf], "orientation",212 " Rotation angle around its own c axis against q plane"],214 ["theta", "degrees", 60, [-360, 360], "orientation", 215 "c axis to beam angle"], 216 ["phi", "degrees", 60, [-360, 360], "orientation", 217 "rotation about beam"], 218 ["psi", "degrees", 60, [-360, 360], "orientation", 219 "rotation about c axis"], 213 220 ] 214 221 -
sasmodels/models/sc_paracrystal.py
r0881f4e r69e1afc 130 130 ["sld", "1e-6/Ang^2", 3.0, [0.0, inf], "sld", "Sphere scattering length density"], 131 131 ["sld_solvent", "1e-6/Ang^2", 6.3, [0.0, inf], "sld", "Solvent scattering length density"], 132 ["theta", "degrees", 0.0, [-inf, inf], "orientation", "Orientation of the a1 axis w/respect incoming beam"],133 ["phi", "degrees", 0.0, [-inf, inf], "orientation", "Orientation of the a2 in the plane of the detector"],134 ["psi", "degrees", 0.0, [-inf, inf], "orientation", "Orientation of the a3 in the plane of the detector"],132 ["theta", "degrees", 0, [-360, 360], "orientation", "c axis to beam angle"], 133 ["phi", "degrees", 0, [-360, 360], "orientation", "rotation about beam"], 134 ["psi", "degrees", 0, [-360, 360], "orientation", "rotation about c axis"] 135 135 ] 136 136 # pylint: enable=bad-whitespace, line-too-long … … 149 149 150 150 tests = [ 151 # Accuracy tests based on content in test/utest_extra_models.py 151 # Accuracy tests based on content in test/utest_extra_models.py, 2d tests added April 10, 2017 152 152 [{}, 0.001, 10.3048], 153 153 [{}, 0.215268, 0.00814889], 154 [{}, (0.414467), 0.001313289] 154 [{}, (0.414467), 0.001313289], 155 [{'theta':10.0,'phi':20,'psi':30.0},(0.045,-0.035),18.0397138402 ], 156 [{'theta':10.0,'phi':20,'psi':30.0},(0.023,0.045),0.0177333171285 ] 155 157 ] 156 158 -
sasmodels/models/stacked_disks.py
rf3073b0 r9802ab3 77 77 the axis of the cylinder using two angles $\theta$ and $\varphi$. 78 78 79 .. figure:: img/cylinder_angle_definition. jpg79 .. figure:: img/cylinder_angle_definition.png 80 80 81 81 Examples of the angles against the detector plane. … … 131 131 ["sld_layer", "1e-6/Ang^2", 0.0, [-inf, inf], "sld", "Layer scattering length density"], 132 132 ["sld_solvent", "1e-6/Ang^2", 5.0, [-inf, inf], "sld", "Solvent scattering length density"], 133 ["theta", "degrees", 0, [- inf, inf], "orientation", "Orientation of the stacked disk axis w/respect incoming beam"],134 ["phi", "degrees", 0, [- inf, inf], "orientation", "Orientation of the stacked disk in the plane of the detector"],133 ["theta", "degrees", 0, [-360, 360], "orientation", "Orientation of the stacked disk axis w/respect incoming beam"], 134 ["phi", "degrees", 0, [-360, 360], "orientation", "Rotation about beam"], 135 135 ] 136 136 # pylint: enable=bad-whitespace, line-too-long -
sasmodels/models/triaxial_ellipsoid.py
r0881f4e re645373 76 76 of the particle. 77 77 78 The angle $\psi$ is the rotational angle around its own $c$ axis 79 against the $q$ plane. For example, $\psi = 0$ when the 80 $a$ axis is parallel to the $x$ axis of the detector. 78 For oriented ellipsoids the *theta*, *phi* and *psi* orientation parameters will appear when fitting 2D data, 79 see the :ref:`elliptical-cylinder` model for further information. 81 80 82 81 .. _triaxial-ellipsoid-angles: … … 126 125 127 126 description = """ 128 Note: During fitting ensure that the inequality ra<rb<rc is not 129 violated. Otherwise the calculation will 130 not be correct. 127 Note - fitting ensure that the inequality ra<rb<rc is not 128 violated. Otherwise the calculation may not be correct. 131 129 """ 132 130 category = "shape:ellipsoid" … … 143 141 ["radius_polar", "Ang", 10, [0, inf], "volume", 144 142 "Polar radius, Rc"], 145 ["theta", "degrees", 60, [- inf, inf], "orientation",146 " In planeangle"],147 ["phi", "degrees", 60, [- inf, inf], "orientation",148 " Out of plane angle"],149 ["psi", "degrees", 60, [- inf, inf], "orientation",150 " Out of plane angle"],143 ["theta", "degrees", 60, [-360, 360], "orientation", 144 "polar axis to beam angle"], 145 ["phi", "degrees", 60, [-360, 360], "orientation", 146 "rotation about beam"], 147 ["psi", "degrees", 60, [-360, 360], "orientation", 148 "rotation about polar axis"], 151 149 ] 152 150 … … 183 181 # april 6 2017, rkh add unit tests 184 182 # NOT compared with any other calc method, assume correct! 185 # add2d test after pull #890183 # check 2d test after pull #890 186 184 qx = q*cos(pi/6.0) 187 185 qy = q*sin(pi/6.0) 188 186 tests = [[{}, 0.05, 24.8839548033], 189 # [{'theta':80., 'phi':10.}, (qx, qy), 9999.],187 [{'theta':80., 'phi':10.}, (qx, qy), 166.712060266 ], 190 188 ] 191 189 del qx, qy # not necessary to delete, but cleaner -
explore/jitter.py
r85190c2 r8678a34 3 3 dispersity and possible replacement algorithms. 4 4 """ 5 import sys 6 5 7 import mpl_toolkits.mplot3d # Adds projection='3d' option to subplot 6 8 import matplotlib.pyplot as plt 7 9 from matplotlib.widgets import Slider, CheckButtons 8 10 from matplotlib import cm 9 10 11 import numpy as np 11 12 from numpy import pi, cos, sin, sqrt, exp, degrees, radians 12 13 13 def draw_beam(ax ):14 def draw_beam(ax, view=(0, 0)): 14 15 #ax.plot([0,0],[0,0],[1,-1]) 15 16 #ax.scatter([0]*100,[0]*100,np.linspace(1, -1, 100), alpha=0.8) … … 22 23 x = r*np.outer(np.cos(u), np.ones_like(v)) 23 24 y = r*np.outer(np.sin(u), np.ones_like(v)) 24 z = np.outer(np.ones_like(u), v) 25 z = 1.3*np.outer(np.ones_like(u), v) 26 27 theta, phi = view 28 shape = x.shape 29 points = np.matrix([x.flatten(), y.flatten(), z.flatten()]) 30 points = Rz(phi)*Ry(theta)*points 31 x, y, z = [v.reshape(shape) for v in points] 25 32 26 33 ax.plot_surface(x, y, z, rstride=4, cstride=4, color='y', alpha=0.5) 27 34 28 def draw_shimmy(ax, theta, phi, psi, dtheta, dphi, dpsi): 29 size=[0.1, 0.4, 1.0] 30 view=[theta, phi, psi] 31 shimmy=[0,0,0] 32 #draw_shape = draw_parallelepiped 33 draw_shape = draw_ellipsoid 35 def draw_jitter(ax, view, jitter): 36 size = [0.1, 0.4, 1.0] 37 draw_shape = draw_parallelepiped 38 #draw_shape = draw_ellipsoid 34 39 35 40 #np.random.seed(10) … … 64 69 [ 1, 1, 1], 65 70 ] 71 dtheta, dphi, dpsi = jitter 66 72 if dtheta == 0: 67 73 cloud = [v for v in cloud if v[0] == 0] … … 70 76 if dpsi == 0: 71 77 cloud = [v for v in cloud if v[2] == 0] 72 draw_shape(ax, size, view, shimmy, steps=100, alpha=0.8)78 draw_shape(ax, size, view, [0, 0, 0], steps=100, alpha=0.8) 73 79 for point in cloud: 74 shimmy=[dtheta*point[0], dphi*point[1], dpsi*point[2]]75 draw_shape(ax, size, view, shimmy, alpha=0.8)80 delta = [dtheta*point[0], dphi*point[1], dpsi*point[2]] 81 draw_shape(ax, size, view, delta, alpha=0.8) 76 82 for v in 'xyz': 77 83 a, b, c = size … … 80 86 getattr(ax, v+'axis').label.set_text(v) 81 87 82 def draw_ellipsoid(ax, size, view, shimmy, steps=25, alpha=1):88 def draw_ellipsoid(ax, size, view, jitter, steps=25, alpha=1): 83 89 a,b,c = size 84 theta, phi, psi = view85 dtheta, dphi, dpsi = shimmy86 87 90 u = np.linspace(0, 2 * np.pi, steps) 88 91 v = np.linspace(0, np.pi, steps) … … 90 93 y = b*np.outer(np.sin(u), np.sin(v)) 91 94 z = c*np.outer(np.ones_like(u), np.cos(v)) 92 93 shape = x.shape 94 points = np.matrix([x.flatten(),y.flatten(),z.flatten()]) 95 points = Rz(dpsi)*Ry(dtheta)*Rx(dphi)*points 96 points = Rz(phi)*Ry(theta)*Rz(psi)*points 97 x,y,z = [v.reshape(shape) for v in points] 95 x, y, z = transform_xyz(view, jitter, x, y, z) 98 96 99 97 ax.plot_surface(x, y, z, rstride=4, cstride=4, color='w', alpha=alpha) 100 98 101 def draw_parallelepiped(ax, size, view, shimmy, alpha=1): 99 draw_labels(ax, view, jitter, [ 100 ('c+', [ 0, 0, c], [ 1, 0, 0]), 101 ('c-', [ 0, 0,-c], [ 0, 0,-1]), 102 ('a+', [ a, 0, 0], [ 0, 0, 1]), 103 ('a-', [-a, 0, 0], [ 0, 0,-1]), 104 ('b+', [ 0, b, 0], [-1, 0, 0]), 105 ('b-', [ 0,-b, 0], [-1, 0, 0]), 106 ]) 107 108 def draw_parallelepiped(ax, size, view, jitter, steps=None, alpha=1): 102 109 a,b,c = size 103 theta, phi, psi = view104 dtheta, dphi, dpsi = shimmy105 106 110 x = a*np.array([ 1,-1, 1,-1, 1,-1, 1,-1]) 107 111 y = b*np.array([ 1, 1,-1,-1, 1, 1,-1,-1]) … … 118 122 ]) 119 123 120 points = np.matrix([x,y,z]) 121 points = Rz(dpsi)*Ry(dtheta)*Rx(dphi)*points 122 points = Rz(phi)*Ry(theta)*Rz(psi)*points 123 124 x,y,z = [np.array(v).flatten() for v in points] 124 x, y, z = transform_xyz(view, jitter, x, y, z) 125 125 ax.plot_trisurf(x, y, triangles=tri, Z=z, color='w', alpha=alpha) 126 126 127 def draw_sphere(ax, radius=10., steps=100): 128 u = np.linspace(0, 2 * np.pi, steps) 129 v = np.linspace(0, np.pi, steps) 130 131 x = radius * np.outer(np.cos(u), np.sin(v)) 132 y = radius * np.outer(np.sin(u), np.sin(v)) 133 z = radius * np.outer(np.ones(np.size(u)), np.cos(v)) 134 ax.plot_surface(x, y, z, rstride=4, cstride=4, color='w') 135 136 def draw_mesh_new(ax, theta, dtheta, phi, dphi, flow, radius=10., dist='gauss'): 137 theta_center = radians(theta) 138 phi_center = radians(phi) 139 flow_center = radians(flow) 140 dtheta = radians(dtheta) 141 dphi = radians(dphi) 142 143 # 10 point 3-sigma gaussian weights 144 t = np.linspace(-3., 3., 11) 127 draw_labels(ax, view, jitter, [ 128 ('c+', [ 0, 0, c], [ 1, 0, 0]), 129 ('c-', [ 0, 0,-c], [ 0, 0,-1]), 130 ('a+', [ a, 0, 0], [ 0, 0, 1]), 131 ('a-', [-a, 0, 0], [ 0, 0,-1]), 132 ('b+', [ 0, b, 0], [-1, 0, 0]), 133 ('b-', [ 0,-b, 0], [-1, 0, 0]), 134 ]) 135 136 def draw_mesh(ax, view, jitter, radius=1.2, n=11, dist='gauss'): 137 theta, phi, psi = view 138 dtheta, dphi, dpsi = jitter 145 139 if dist == 'gauss': 140 t = np.linspace(-3, 3, n) 146 141 weights = exp(-0.5*t**2) 147 142 elif dist == 'rect': 143 t = np.linspace(0, 1, n) 148 144 weights = np.ones_like(t) 149 145 else: 150 146 raise ValueError("expected dist to be 'gauss' or 'rect'") 151 theta = dtheta*t 152 phi = dphi*t 153 154 x = radius * np.outer(cos(phi), cos(theta)) 155 y = radius * np.outer(sin(phi), cos(theta)) 156 z = radius * np.outer(np.ones_like(phi), sin(theta)) 157 #w = np.outer(weights, weights*abs(cos(dtheta*t))) 158 w = np.outer(weights, weights*abs(cos(theta))) 159 160 x, y, z, w = [v.flatten() for v in (x,y,z,w)] 161 x, y, z = rotate(x, y, z, phi_center, theta_center, flow_center) 162 163 ax.scatter(x, y, z, c=w, marker='o', vmin=0., vmax=1.) 164 165 def rotate(x, y, z, phi, theta, psi): 166 R = Rz(phi)*Ry(theta)*Rz(psi) 167 p = np.vstack([x,y,z]) 168 return R*p 147 148 # mesh in theta, phi formed by rotating z 149 z = np.matrix([[0], [0], [radius]]) 150 points = np.hstack([Rx(phi_i)*Ry(theta_i)*z 151 for theta_i in dtheta*t 152 for phi_i in dphi*t]) 153 # rotate relative to beam 154 points = orient_relative_to_beam(view, points) 155 156 w = np.outer(weights, weights) 157 158 x, y, z = [np.array(v).flatten() for v in points] 159 ax.scatter(x, y, z, c=w.flatten(), marker='o', vmin=0., vmax=1.) 169 160 170 161 def Rx(angle): … … 188 179 [0., 0., 1.]] 189 180 return np.matrix(R) 181 182 def transform_xyz(view, jitter, x, y, z): 183 x, y, z = [np.asarray(v) for v in (x, y, z)] 184 shape = x.shape 185 points = np.matrix([x.flatten(),y.flatten(),z.flatten()]) 186 points = apply_jitter(jitter, points) 187 points = orient_relative_to_beam(view, points) 188 x, y, z = [np.array(v).reshape(shape) for v in points] 189 return x, y, z 190 191 def apply_jitter(jitter, points): 192 dtheta, dphi, dpsi = jitter 193 points = Rz(dpsi)*Ry(dtheta)*Rx(dphi)*points 194 return points 195 196 def orient_relative_to_beam(view, points): 197 theta, phi, psi = view 198 points = Rz(phi)*Ry(theta)*Rz(psi)*points 199 return points 200 201 def draw_labels(ax, view, jitter, text): 202 labels, locations, orientations = zip(*text) 203 px, py, pz = zip(*locations) 204 dx, dy, dz = zip(*orientations) 205 206 px, py, pz = transform_xyz(view, jitter, px, py, pz) 207 dx, dy, dz = transform_xyz(view, jitter, dx, dy, dz) 208 209 for label, p, zdir in zip(labels, zip(px, py, pz), zip(dx, dy, dz)): 210 zdir = np.asarray(zdir).flatten() 211 ax.text(p[0], p[1], p[2], label, zdir=zdir) 212 213 def draw_sphere(ax, radius=10., steps=100): 214 u = np.linspace(0, 2 * np.pi, steps) 215 v = np.linspace(0, np.pi, steps) 216 217 x = radius * np.outer(np.cos(u), np.sin(v)) 218 y = radius * np.outer(np.sin(u), np.sin(v)) 219 z = radius * np.outer(np.ones(np.size(u)), np.cos(v)) 220 ax.plot_surface(x, y, z, rstride=4, cstride=4, color='w') 190 221 191 222 def main(): … … 206 237 207 238 axcolor = 'lightgoldenrodyellow' 239 208 240 axtheta = plt.axes([0.1, 0.15, 0.45, 0.04], axisbg=axcolor) 209 241 axphi = plt.axes([0.1, 0.1, 0.45, 0.04], axisbg=axcolor) … … 212 244 sphi = Slider(axphi, 'Phi', -180, 180, valinit=phi) 213 245 spsi = Slider(axpsi, 'Psi', -180, 180, valinit=psi) 246 214 247 axdtheta = plt.axes([0.75, 0.15, 0.15, 0.04], axisbg=axcolor) 215 248 axdphi = plt.axes([0.75, 0.1, 0.15, 0.04], axisbg=axcolor) … … 217 250 sdtheta = Slider(axdtheta, 'dTheta', 0, 30, valinit=dtheta) 218 251 sdphi = Slider(axdphi, 'dPhi', 0, 30, valinit=dphi) 219 sdpsi = Slider(axdpsi, 'dPsi', 0, 30, valinit=dp hi)252 sdpsi = Slider(axdpsi, 'dPsi', 0, 30, valinit=dpsi) 220 253 221 254 def update(val, axis=None): 222 theta, phi, psi= stheta.val, sphi.val, spsi.val223 dtheta, dphi, dpsi= sdtheta.val, sdphi.val, sdpsi.val255 view = stheta.val, sphi.val, spsi.val 256 jitter = sdtheta.val, sdphi.val, sdpsi.val 224 257 ax.cla() 225 draw_beam(ax) 226 draw_shimmy(ax, theta, phi, psi, dtheta, dphi, dpsi) 227 #if not axis.startswith('d'): 228 # ax.view_init(elev=theta, azim=phi) 258 draw_beam(ax, (0, 0)) 259 if 0: 260 draw_jitter(ax, view, jitter) 261 else: 262 draw_jitter(ax, view, (0,0,0)) 263 draw_mesh(ax, view, jitter) 229 264 plt.gcf().canvas.draw() 230 265
Note: See TracChangeset
for help on using the changeset viewer.