Changeset b9578fc in sasmodels


Ignore:
Timestamp:
Oct 27, 2017 8:54:21 AM (2 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:
a9bc435
Parents:
f39d4a3
Message:

alternative handling of phi point density: scale phi

File:
1 edited

Legend:

Unmodified
Added
Removed
  • explore/jitter.py

    r36b3154 rb9578fc  
    1515import numpy as np 
    1616from numpy import pi, cos, sin, sqrt, exp, degrees, radians 
     17 
     18SCALED_PHI = True 
    1719 
    1820def draw_beam(ax, view=(0, 0)): 
     
    177179        raise ValueError("expected dist to be 'gaussian' or 'rectangle'") 
    178180 
     181    if SCALED_PHI: 
     182        scale_phi = lambda dtheta, dphi: ( 
     183            dphi/abs(cos(radians(dtheta))) if dtheta != 90 
     184            else 0 if dphi == 0 
     185            else 4*pi) 
     186        w = np.outer(weights, weights) 
     187    else: 
     188        scale_phi = lambda dtheta, dphe: dphi 
     189        w = np.outer(weights*cos(radians(dtheta*t)), weights) 
     190 
    179191    # mesh in theta, phi formed by rotating z 
    180192    z = np.matrix([[0], [0], [radius]]) 
    181     points = np.hstack([Rx(phi_i)*Ry(theta_i)*z 
     193    points = np.hstack([Rx(scale_phi(theta_i, phi_j))*Ry(theta_i)*z 
    182194                        for theta_i in dtheta*t 
    183                         for phi_i in dphi*t]) 
     195                        for phi_j in dphi*t]) 
     196    # select just the active points (i.e., those with phi < 180 
     197    active = np.array([abs(scale_phi(theta_i, phi_j)) < 180 
     198                       for theta_i in dtheta*t 
     199                       for phi_j in dphi*t]) 
     200    points = points[:, active] 
     201    w = w.flatten()[active] 
     202 
    184203    # rotate relative to beam 
    185204    points = orient_relative_to_beam(view, points) 
    186205 
    187     w = np.outer(weights*cos(radians(dtheta*t)), weights) 
    188  
    189206    x, y, z = [np.array(v).flatten() for v in points] 
    190     ax.scatter(x, y, z, c=w.flatten(), marker='o', vmin=0., vmax=1.) 
     207    ax.scatter(x, y, z, c=w, marker='o', vmin=0., vmax=1.) 
    191208 
    192209def draw_labels(ax, view, jitter, text): 
Note: See TracChangeset for help on using the changeset viewer.