Changeset 4991048 in sasmodels for explore


Ignore:
Timestamp:
Nov 1, 2017 6:16:45 PM (7 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:
f475f90
Parents:
3a1fc7d
Message:

set projection used in theory to that selected in jitter.py

File:
1 edited

Legend:

Unmodified
Added
Removed
  • explore/jitter.py

    rde71632 r4991048  
    162162 
    163163PROJECTIONS = [ 
    164     'equirectangular', 'azimuthal_equidistance', 'sinusoidal', 'guyou', 
     164    # in order of PROJECTION number; do not change without updating the 
     165    # constants in kernel_iq.c 
     166    'equirectangular', 'sinusoidal', 'guyou', 'azimuthal_equidistance', 
    165167] 
    166168def draw_mesh(ax, view, jitter, radius=1.2, n=11, dist='gaussian', 
     
    239241        raise ValueError("expected dist to be gaussian, rectangle or uniform") 
    240242 
    241     if projection == 'equirectangular': 
     243    if projection == 'equirectangular':  #define PROJECTION 1 
    242244        def rotate(theta_i, phi_j): 
    243245            return Rx(phi_j)*Ry(theta_i) 
    244246        def weight(theta_i, phi_j, wi, wj): 
    245247            return wi*wj*abs(cos(radians(theta_i))) 
    246     elif projection == 'azimuthal_equidistance': 
     248    elif projection == 'sinusoidal':  #define PROJECTION 2 
     249        def rotate(theta_i, phi_j): 
     250            latitude = theta_i 
     251            scale = cos(radians(latitude)) 
     252            longitude = phi_j/scale if abs(phi_j) < abs(scale)*180 else 0 
     253            #print("(%+7.2f, %+7.2f) => (%+7.2f, %+7.2f)"%(theta_i, phi_j, latitude, longitude)) 
     254            return Rx(longitude)*Ry(latitude) 
     255        def weight(theta_i, phi_j, wi, wj): 
     256            latitude = theta_i 
     257            scale = cos(radians(latitude)) 
     258            w = 1 if abs(phi_j) < abs(scale)*180 else 0 
     259            return w*wi*wj 
     260    elif projection == 'guyou':  #define PROJECTION 3  (eventually?) 
     261        def rotate(theta_i, phi_j): 
     262            from guyou import guyou_invert 
     263            #latitude, longitude = guyou_invert([theta_i], [phi_j]) 
     264            longitude, latitude = guyou_invert([phi_j], [theta_i]) 
     265            return Rx(longitude[0])*Ry(latitude[0]) 
     266        def weight(theta_i, phi_j, wi, wj): 
     267            return wi*wj 
     268    elif projection == 'azimuthal_equidistance':  # Note: Rz Ry, not Rx Ry 
    247269        def rotate(theta_i, phi_j): 
    248270            latitude = sqrt(theta_i**2 + phi_j**2) 
     
    282304            w = sin(radians(latitude))/latitude if latitude != 0 else 1 
    283305            return w*wi*wj if latitude < 180 else 0 
    284     elif projection == 'sinusoidal': 
    285         def rotate(theta_i, phi_j): 
    286             latitude = theta_i 
    287             scale = cos(radians(latitude)) 
    288             longitude = phi_j/scale if abs(phi_j) < abs(scale)*180 else 0 
    289             #print("(%+7.2f, %+7.2f) => (%+7.2f, %+7.2f)"%(theta_i, phi_j, latitude, longitude)) 
    290             return Rx(longitude)*Ry(latitude) 
    291         def weight(theta_i, phi_j, wi, wj): 
    292             latitude = theta_i 
    293             scale = cos(radians(latitude)) 
    294             w = 1 if abs(phi_j) < abs(scale)*180 else 0 
    295             return w*wi*wj 
    296306    elif projection == 'azimuthal_equal_area': 
    297307        def rotate(theta_i, phi_j): 
     
    305315            w = sin(radians(latitude))/latitude if latitude != 0 else 1 
    306316            return w*wi*wj if latitude < 180 else 0 
    307     elif projection == 'guyou': 
    308         def rotate(theta_i, phi_j): 
    309             from guyou import guyou_invert 
    310             #latitude, longitude = guyou_invert([theta_i], [phi_j]) 
    311             longitude, latitude = guyou_invert([phi_j], [theta_i]) 
    312             return Rx(longitude[0])*Ry(latitude[0]) 
    313         def weight(theta_i, phi_j, wi, wj): 
    314             return wi*wj 
    315317    else: 
    316318        raise ValueError("unknown projection %r"%projection) 
     
    490492        vmin, vmax = calculator.limits 
    491493    else: 
    492         vmin, vmax = clipped_range(Iqxy, portion=0.95, mode='top') 
     494        vmax = Iqxy.max() 
     495        vmin = vmax*10**-7 
     496        #vmin, vmax = clipped_range(Iqxy, portion=portion, mode='top') 
    493497    #print("range",(vmin,vmax)) 
    494498    #qx, qy = np.meshgrid(qx, qy) 
     
    605609    *model_name* is one of the models available in :func:`select_model`. 
    606610    """ 
     611    # projection number according to 1-order position in list, but 
     612    # only 1 and 2 are implemented so far. 
     613    from sasmodels import generate 
     614    generate.PROJECTION = PROJECTIONS.index(projection) + 1 
     615    if generate.PROJECTION > 2: 
     616        print("*** PROJECTION %s not implemented in scattering function ***"%projection) 
     617        generate.PROJECTION = 2 
     618 
    607619    # set up calculator 
    608620    calculator, size = select_calculator(model_name, n=150, size=size) 
Note: See TracChangeset for help on using the changeset viewer.