Changeset b1c49601 in sasmodels


Ignore:
Timestamp:
Feb 4, 2019 11:22:40 AM (6 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, core_shell_microgels, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
9ec9c67
Parents:
1511a60c
Message:

fix python 2.7 utf-8 encoding and fix line endings

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/jitter.py

    r1511a60c rb1c49601  
    11#!/usr/bin/env python 
     2# -*- coding: utf-8 -*- 
    23""" 
    34Jitter Explorer 
     
    8283    #x_cap, y_cap = x[:, 0], y[:, 0] 
    8384    #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, 
    8586    #                      color='yellow', alpha=alpha) 
    8687 
     
    180181    draw(7, 6) 
    181182 
    182 def draw_parallelepiped(axes, size, view, jitter, steps=None,  
     183def draw_parallelepiped(axes, size, view, jitter, steps=None, 
    183184                        color=(0.6, 1.0, 0.6), alpha=1): 
    184185    """Draw a parallelepiped.""" 
     
    285286    axes.set_axis_off() 
    286287 
    287 def draw_jitter(axes, view, jitter, dist='gaussian',  
     288def draw_jitter(axes, view, jitter, dist='gaussian', 
    288289                size=(0.1, 0.4, 1.0), 
    289                 draw_shape=draw_parallelepiped,  
     290                draw_shape=draw_parallelepiped, 
    290291                projection='equirectangular', 
    291292                alpha=0.8, 
     
    420421        def _weight(theta_i, phi_j, w_i, w_j): 
    421422            return w_i*w_j 
    422     elif projection == 'azimuthal_equidistance':  
     423    elif projection == 'azimuthal_equidistance': 
    423424        # Note that calculates angles for Rz Ry rather than Rx Ry 
    424425        def _project(theta_i, phi_j, psi): 
     
    489490    Mike Day, Insomniac Games 
    490491    https://d3cw3dd2w32x2b.cloudfront.net/wp-content/uploads/2012/07/euler-angles1.pdf 
    491     Based on: Shoemake’s “Euler Angle Conversion”, Graphics Gems IV, pp.  222-229 
     492    Based on: Shoemake’s "Euler Angle Conversion", Graphics Gems IV, pp.  222-229 
    492493    """ 
    493494    phi = np.arctan2(R[1, 2], R[2, 2]) 
     
    636637 
    637638    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 
    640641    not disappear by calculating the transform differently. 
    641642    """ 
     
    660661    return q.rot(points) 
    661662#orient_relative_to_beam = orient_relative_to_beam_quaternion 
    662   
     663 
    663664# Simple stand-alone quaternion class 
    664665import numpy as np 
     
    705706    target = [(10+4*np.sqrt(3))/8, (1+2*np.sqrt(3))/8, (14-3*np.sqrt(3))/8] 
    706707    #print(q, q.rot(p) - target) 
    707     assert max(abs(q.rot(p) - target)) < 1e-14  
     708    assert max(abs(q.rot(p) - target)) < 1e-14 
    708709#test_qrot() 
    709710#import sys; sys.exit() 
     
    922923 
    923924 
    924 def run(model_name='parallelepiped', size=(10, 40, 100),  
     925def run(model_name='parallelepiped', size=(10, 40, 100), 
    925926        view=(0, 0, 0), jitter=(0, 0, 0), 
    926927        dist='gaussian', mesh=30, 
     
    954955 
    955956    # set up calculator 
    956     calculator, size = select_calculator(model_name, n=150, size=size) 
     957    calculator, size = select_calculator(model_name, n=100, size=size) 
    957958    draw_shape = DRAW_SHAPES.get(model_name, draw_parallelepiped) 
    958959    #draw_shape = draw_fcc 
     
    989990    axes_phi = plt.axes([0.1, 0.1, 0.45, 0.04], facecolor=axcolor) 
    990991    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) 
    994995 
    995996    axes_dtheta = plt.axes([0.75, 0.15, 0.15, 0.04], facecolor=axcolor) 
     
    10001001    # the maximum width to 90. 
    10011002    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) 
    10051006 
    10061007    ## initial view and jitter 
     
    10341035        ## Move shape and draw scattering 
    10351036        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, 
    10371038                    draw_shape=draw_shape, projection=projection, views=3) 
    10381039        draw_mesh(axes, view, jitter, dist=dist, n=mesh, projection=projection) 
     
    10771078    kw['color'] = color 
    10781079 
    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] 
     1080def make_vec(*args): 
     1081    #return [np.asarray(v, 'd').flatten() for v in args] 
     1082    return [np.asarray(v, 'd') for v in args] 
    10841083 
    10851084def make_image(z, kw): 
     
    11281127            facecolors = kw.pop('facecolors', None) 
    11291128            if facecolors is not None: 
    1130                 kw['color'] = facecolors  
     1129                kw['color'] = facecolors 
    11311130            ipv_fix_color(kw) 
    11321131            x, y, z = make_vec(x, y, z) 
     
    11571156            u = np.array([[0., 1], [0, 1]]) 
    11581157            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) 
    11601159        def text(self, *args, **kw): 
    11611160            pass 
     
    12001199        ## Move shape and draw scattering 
    12011200        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, 
    12031202                    draw_shape=draw_shape, projection=projection) 
    12041203        draw_mesh(axes, view, jitter, dist=dist, n=mesh, radius=0.95, projection=projection) 
    12051204        draw_scattering(calculator, axes, view, jitter, dist=dist) 
    1206      
     1205 
    12071206        draw_axes(axes, origin=(-1, -1, -1.1)) 
    12081207        ipv.style.box_off() 
     
    12411240            readout_format='.1f', 
    12421241            ) 
    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]) 
    12491248    fields = { 
    12501249        'theta': theta, 'phi': phi, 'psi': psi, 
Note: See TracChangeset for help on using the changeset viewer.