Changeset b89f519 in sasmodels for sasmodels/bumps_model.py


Ignore:
Timestamp:
Mar 4, 2015 2:34:25 PM (9 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, core_shell_microgels, costrafo411, magnetic_model, release_v0.94, release_v0.95, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
3c56da87
Parents:
12c810f
Message:

allow q4 plots in compare; choose random values within a factor of 2 of the model value for compare -random

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/bumps_model.py

    r1353f60 rb89f519  
    154154 
    155155 
    156 def plot_data(data, iq, vmin=None, vmax=None, scale='log'): 
     156def plot_data(data, iq, vmin=None, vmax=None, view='log'): 
    157157    """ 
    158158    Plot the target value for the data.  This could be the data itself, 
     
    166166        iq = iq + 0 
    167167        valid = np.isfinite(iq) 
    168         if scale == 'log': 
     168        if view == 'log': 
    169169            valid[valid] = (iq[valid] > 0) 
    170170            iq[valid] = np.log10(iq[valid]) 
     171        elif view == 'q4': 
     172            iq[valid] = iq*(data.qx_data[valid]**2+data.qy_data[valid]**2)**2 
    171173        iq[~valid | data.mask] = 0 
    172174        #plottable = iq 
     
    183185                   extent=[xmin, xmax, ymin, ymax], vmin=vmin, vmax=vmax) 
    184186    else: # 1D data 
    185         if scale == 'linear': 
     187        if view == 'linear' or view == 'q4': 
     188            #idx = np.isfinite(iq) 
     189            scale = data.x**4 if view == 'q4' else 1.0 
     190            plt.plot(data.x, scale*iq) #, '.') 
     191        else: 
     192            # Find the values that are finite and positive 
    186193            idx = np.isfinite(iq) 
    187             plt.plot(data.x[idx], iq[idx]) 
    188         else: 
    189             idx = np.isfinite(iq) 
    190             idx[idx] = (iq[idx] > 0) 
    191             plt.loglog(data.x[idx], iq[idx]) 
     194            idx[idx] = iq[idx]>0 
     195            iq[~idx] = np.nan 
     196            plt.loglog(data.x, iq) 
    192197 
    193198 
     
    207212    mresid = masked_array((theory - data.y) / data.dy, mdata.mask) 
    208213 
     214    scale = data.x**4 if view == 'q4' else 1.0 
    209215    plt.subplot(121) 
    210     plt.errorbar(data.x, mdata, yerr=data.dy) 
    211     plt.plot(data.x, mtheory, '-', hold=True) 
    212     plt.yscale(view) 
     216    plt.errorbar(data.x, scale*mdata, yerr=data.dy) 
     217    plt.plot(data.x, scale*mtheory, '-', hold=True) 
     218    plt.yscale('linear' if view == 'q4' else view) 
    213219    plt.subplot(122) 
    214220    plt.plot(data.x, mresid, 'x') 
     
    234240    resid = (theory - data.data) / data.err_data 
    235241    plt.subplot(131) 
    236     plot_data(data, data.data, scale=view) 
     242    plot_data(data, data.data, view=view) 
    237243    plt.colorbar() 
    238244    plt.subplot(132) 
    239     plot_data(data, theory, scale=view) 
     245    plot_data(data, theory, view=view) 
    240246    plt.colorbar() 
    241247    plt.subplot(133) 
    242     plot_data(data, resid, scale='linear') 
     248    plot_data(data, resid, view='linear') 
    243249    plt.colorbar() 
    244250 
Note: See TracChangeset for help on using the changeset viewer.