Changeset b3703f5 in sasmodels for sasmodels/jitter.py


Ignore:
Timestamp:
Mar 26, 2018 5:50:35 PM (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:
c11d09f, c462169
Parents:
802c412
Message:

lint reduction

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/jitter.py

    r802c412 rb3703f5  
    9999    _draw_crystal(axes, size, view, jitter, atoms=atoms) 
    100100 
    101 def _draw_crystal(axes, size, view, jitter, steps=None, alpha=1, atoms=None): 
     101def _draw_crystal(axes, size, view, jitter, atoms=None): 
    102102    atoms, size = np.asarray(atoms, 'd').T, np.asarray(size, 'd') 
    103103    x, y, z = atoms*size[:, None] 
     
    298298    # TODO: try Kent distribution instead of a gaussian warped by projection 
    299299 
    300     t = np.linspace(-1, 1, n) 
    301     weights = np.ones_like(t) 
     300    dist_x = np.linspace(-1, 1, n) 
     301    weights = np.ones_like(dist_x) 
    302302    if dist == 'gaussian': 
    303         t *= 3 
    304         weights = exp(-0.5*t**2) 
     303        dist_x *= 3 
     304        weights = exp(-0.5*dist_x**2) 
    305305    elif dist == 'rectangle': 
    306306        # Note: uses sasmodels ridiculous definition of rectangle width 
    307         t *= sqrt(3) 
     307        dist_x *= sqrt(3) 
    308308    elif dist == 'uniform': 
    309309        pass 
     
    392392    z = np.matrix([[0], [0], [radius]]) 
    393393    points = np.hstack([_rotate(theta_i, phi_j)*z 
    394                         for theta_i in dtheta*t 
    395                         for phi_j in dphi*t]) 
    396     w = np.array([_weight(theta_i, phi_j, w_i, w_j) 
    397                   for w_i, theta_i in zip(weights, dtheta*t) 
    398                   for w_j, phi_j in zip(weights, dphi*t)]) 
    399     #print(max(w), min(w), min(w[w>0])) 
    400     points = points[:, w > 0] 
    401     w = w[w > 0] 
    402     w /= max(w) 
     394                        for theta_i in dtheta*dist_x 
     395                        for phi_j in dphi*dist_x]) 
     396    dist_w = np.array([_weight(theta_i, phi_j, w_i, w_j) 
     397                       for w_i, theta_i in zip(weights, dtheta*dist_x) 
     398                       for w_j, phi_j in zip(weights, dphi*dist_x)]) 
     399    #print(max(dist_w), min(dist_w), min(dist_w[dist_w > 0])) 
     400    points = points[:, dist_w > 0] 
     401    dist_w = dist_w[dist_w > 0] 
     402    dist_w /= max(dist_w) 
    403403 
    404404    # rotate relative to beam 
     
    407407    x, y, z = [np.array(v).flatten() for v in points] 
    408408    #plt.figure(2); plt.clf(); plt.hist(z, bins=np.linspace(-1, 1, 51)) 
    409     axes.scatter(x, y, z, c=w, marker='o', vmin=0., vmax=1.) 
     409    axes.scatter(x, y, z, c=dist_w, marker='o', vmin=0., vmax=1.) 
    410410 
    411411def draw_labels(axes, view, jitter, text): 
     
    430430    """Construct a matrix to rotate points about *x* by *angle* degrees.""" 
    431431    angle = radians(angle) 
    432     R = [[1, 0, 0], 
    433          [0, +cos(angle), -sin(angle)], 
    434          [0, +sin(angle), +cos(angle)]] 
    435     return np.matrix(R) 
     432    rot = [[1, 0, 0], 
     433           [0, +cos(angle), -sin(angle)], 
     434           [0, +sin(angle), +cos(angle)]] 
     435    return np.matrix(rot) 
    436436 
    437437def Ry(angle): 
    438438    """Construct a matrix to rotate points about *y* by *angle* degrees.""" 
    439439    angle = radians(angle) 
    440     R = [[+cos(angle), 0, +sin(angle)], 
    441          [0, 1, 0], 
    442          [-sin(angle), 0, +cos(angle)]] 
    443     return np.matrix(R) 
     440    rot = [[+cos(angle), 0, +sin(angle)], 
     441           [0, 1, 0], 
     442           [-sin(angle), 0, +cos(angle)]] 
     443    return np.matrix(rot) 
    444444 
    445445def Rz(angle): 
    446446    """Construct a matrix to rotate points about *z* by *angle* degrees.""" 
    447447    angle = radians(angle) 
    448     R = [[+cos(angle), -sin(angle), 0], 
    449          [+sin(angle), +cos(angle), 0], 
    450          [0, 0, 1]] 
    451     return np.matrix(R) 
     448    rot = [[+cos(angle), -sin(angle), 0], 
     449           [+sin(angle), +cos(angle), 0], 
     450           [0, 0, 1]] 
     451    return np.matrix(rot) 
    452452 
    453453def transform_xyz(view, jitter, x, y, z): 
     
    564564    elif 1: 
    565565        axes.contourf(qx/qx.max(), qy/qy.max(), Iqxy, zdir='z', offset=-1.1, 
    566                     levels=np.linspace(vmin, vmax, 24)) 
     566                      levels=np.linspace(vmin, vmax, 24)) 
    567567    else: 
    568568        axes.pcolormesh(qx, qy, Iqxy) 
     
    583583    for details. 
    584584    """ 
    585     from sasmodels.core import load_model_info, build_model 
     585    from sasmodels.core import load_model_info, build_model as build_sasmodel 
    586586    from sasmodels.data import empty_data2D 
    587587    from sasmodels.direct_model import DirectModel 
    588588 
    589589    model_info = load_model_info(model_name) 
    590     model = build_model(model_info) #, dtype='double!') 
     590    model = build_sasmodel(model_info) #, dtype='double!') 
    591591    q = np.linspace(-qmax, qmax, n) 
    592592    data = empty_data2D(q, q) 
Note: See TracChangeset for help on using the changeset viewer.