Changeset b1c49601 in sasmodels
 Timestamp:
 Feb 4, 2019 11:22:40 AM (7 months ago)
 Branches:
 master, core_shell_microgels, magnetic_model, ticket1257vesicleproduct, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
 Children:
 9ec9c67
 Parents:
 1511a60c
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

sasmodels/jitter.py
r1511a60c rb1c49601 1 1 #!/usr/bin/env python 2 # * coding: utf8 * 2 3 """ 3 4 Jitter Explorer … … 82 83 #x_cap, y_cap = x[:, 0], y[:, 0] 83 84 #for z_cap in z[:, 0], z[:, 1]: 84 # axes.plot_trisurf(x_cap, y_cap, z_cap, triangles, 85 # axes.plot_trisurf(x_cap, y_cap, z_cap, triangles, 85 86 # color='yellow', alpha=alpha) 86 87 … … 180 181 draw(7, 6) 181 182 182 def draw_parallelepiped(axes, size, view, jitter, steps=None, 183 def draw_parallelepiped(axes, size, view, jitter, steps=None, 183 184 color=(0.6, 1.0, 0.6), alpha=1): 184 185 """Draw a parallelepiped.""" … … 285 286 axes.set_axis_off() 286 287 287 def draw_jitter(axes, view, jitter, dist='gaussian', 288 def draw_jitter(axes, view, jitter, dist='gaussian', 288 289 size=(0.1, 0.4, 1.0), 289 draw_shape=draw_parallelepiped, 290 draw_shape=draw_parallelepiped, 290 291 projection='equirectangular', 291 292 alpha=0.8, … … 420 421 def _weight(theta_i, phi_j, w_i, w_j): 421 422 return w_i*w_j 422 elif projection == 'azimuthal_equidistance': 423 elif projection == 'azimuthal_equidistance': 423 424 # Note that calculates angles for Rz Ry rather than Rx Ry 424 425 def _project(theta_i, phi_j, psi): … … 489 490 Mike Day, Insomniac Games 490 491 https://d3cw3dd2w32x2b.cloudfront.net/wpcontent/uploads/2012/07/eulerangles1.pdf 491 Based on: Shoemakeâs âEuler Angle Conversionâ, Graphics Gems IV, pp. 222229492 Based on: Shoemakeâs "Euler Angle Conversion", Graphics Gems IV, pp. 222229 492 493 """ 493 494 phi = np.arctan2(R[1, 2], R[2, 2]) … … 636 637 637 638 This variant uses quaternions rather than rotation matrices for the 638 computation. It works but it is not used because it doesn't solve 639 any problems. The challenge of mapping theta/phi/psi to SO(3) does 639 computation. It works but it is not used because it doesn't solve 640 any problems. The challenge of mapping theta/phi/psi to SO(3) does 640 641 not disappear by calculating the transform differently. 641 642 """ … … 660 661 return q.rot(points) 661 662 #orient_relative_to_beam = orient_relative_to_beam_quaternion 662 663 663 664 # Simple standalone quaternion class 664 665 import numpy as np … … 705 706 target = [(10+4*np.sqrt(3))/8, (1+2*np.sqrt(3))/8, (143*np.sqrt(3))/8] 706 707 #print(q, q.rot(p)  target) 707 assert max(abs(q.rot(p)  target)) < 1e14 708 assert max(abs(q.rot(p)  target)) < 1e14 708 709 #test_qrot() 709 710 #import sys; sys.exit() … … 922 923 923 924 924 def run(model_name='parallelepiped', size=(10, 40, 100), 925 def run(model_name='parallelepiped', size=(10, 40, 100), 925 926 view=(0, 0, 0), jitter=(0, 0, 0), 926 927 dist='gaussian', mesh=30, … … 954 955 955 956 # set up calculator 956 calculator, size = select_calculator(model_name, n=1 50, size=size)957 calculator, size = select_calculator(model_name, n=100, size=size) 957 958 draw_shape = DRAW_SHAPES.get(model_name, draw_parallelepiped) 958 959 #draw_shape = draw_fcc … … 989 990 axes_phi = plt.axes([0.1, 0.1, 0.45, 0.04], facecolor=axcolor) 990 991 axes_psi = plt.axes([0.1, 0.05, 0.45, 0.04], facecolor=axcolor) 991 stheta = Slider(axes_theta, 'Theta', 90, 90, valinit=0)992 sphi = Slider(axes_phi, 'Phi', 180, 180, valinit=0)993 spsi = Slider(axes_psi, 'Psi', 180, 180, valinit=0)992 stheta = Slider(axes_theta, u'Îž', 90, 90, valinit=0) 993 sphi = Slider(axes_phi, u'Ï', 180, 180, valinit=0) 994 spsi = Slider(axes_psi, u'Ï', 180, 180, valinit=0) 994 995 995 996 axes_dtheta = plt.axes([0.75, 0.15, 0.15, 0.04], facecolor=axcolor) … … 1000 1001 # the maximum width to 90. 1001 1002 dlimit = DIST_LIMITS[dist] 1002 sdtheta = Slider(axes_dtheta, 'dTheta', 0, 2*dlimit, valinit=0)1003 sdphi = Slider(axes_dphi, 'dPhi', 0, 2*dlimit, valinit=0)1004 sdpsi = Slider(axes_dpsi, 'dPsi', 0, 2*dlimit, valinit=0)1003 sdtheta = Slider(axes_dtheta, u'ÎÎž', 0, 2*dlimit, valinit=0) 1004 sdphi = Slider(axes_dphi, u'ÎÏ', 0, 2*dlimit, valinit=0) 1005 sdpsi = Slider(axes_dpsi, u'ÎÏ', 0, 2*dlimit, valinit=0) 1005 1006 1006 1007 ## initial view and jitter … … 1034 1035 ## Move shape and draw scattering 1035 1036 draw_beam(axes, (0, 0)) 1036 draw_jitter(axes, view, jitter, dist=dist, size=size, 1037 draw_jitter(axes, view, jitter, dist=dist, size=size, 1037 1038 draw_shape=draw_shape, projection=projection, views=3) 1038 1039 draw_mesh(axes, view, jitter, dist=dist, n=mesh, projection=projection) … … 1077 1078 kw['color'] = color 1078 1079 1079 def make_vec(*args, flat=False): 1080 if flat: 1081 return [np.asarray(v, 'd').flatten() for v in args] 1082 else: 1083 return [np.asarray(v, 'd') for v in args] 1080 def make_vec(*args): 1081 #return [np.asarray(v, 'd').flatten() for v in args] 1082 return [np.asarray(v, 'd') for v in args] 1084 1083 1085 1084 def make_image(z, kw): … … 1128 1127 facecolors = kw.pop('facecolors', None) 1129 1128 if facecolors is not None: 1130 kw['color'] = facecolors 1129 kw['color'] = facecolors 1131 1130 ipv_fix_color(kw) 1132 1131 x, y, z = make_vec(x, y, z) … … 1157 1156 u = np.array([[0., 1], [0, 1]]) 1158 1157 v = np.array([[0., 0], [1, 1]]) 1159 ipv.plot_mesh(x, y, z, u=u, v=v, texture=image, wireframe=False) 1158 ipv.plot_mesh(x, y, z, u=u, v=v, texture=image, wireframe=False) 1160 1159 def text(self, *args, **kw): 1161 1160 pass … … 1200 1199 ## Move shape and draw scattering 1201 1200 draw_beam(axes, (0, 0)) 1202 draw_jitter(axes, view, jitter, dist=dist, size=size, 1201 draw_jitter(axes, view, jitter, dist=dist, size=size, 1203 1202 draw_shape=draw_shape, projection=projection) 1204 1203 draw_mesh(axes, view, jitter, dist=dist, n=mesh, radius=0.95, projection=projection) 1205 1204 draw_scattering(calculator, axes, view, jitter, dist=dist) 1206 1205 1207 1206 draw_axes(axes, origin=(1, 1, 1.1)) 1208 1207 ipv.style.box_off() … … 1241 1240 readout_format='.1f', 1242 1241 ) 1243 theta = slider( 'Îž', trange, view[0])1244 phi = slider( 'Ï', prange, view[1])1245 psi = slider( 'Ï', prange, view[2])1246 dtheta = slider( 'ÎÎž', dtrange, jitter[0])1247 dphi = slider( 'ÎÏ', dprange, jitter[1])1248 dpsi = slider( 'ÎÏ', dprange, jitter[2])1242 theta = slider(u'Îž', trange, view[0]) 1243 phi = slider(u'Ï', prange, view[1]) 1244 psi = slider(u'Ï', prange, view[2]) 1245 dtheta = slider(u'ÎÎž', dtrange, jitter[0]) 1246 dphi = slider(u'ÎÏ', dprange, jitter[1]) 1247 dpsi = slider(u'ÎÏ', dprange, jitter[2]) 1249 1248 fields = { 1250 1249 'theta': theta, 'phi': phi, 'psi': psi,
Note: See TracChangeset
for help on using the changeset viewer.