Changeset ea75043 in sasmodels for sasmodels/data.py


Ignore:
Timestamp:
Mar 29, 2016 8:22:13 PM (8 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:
d6f5da6
Parents:
1d61d07
Message:

add support for oriented usans using direct 2d resolution integral

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/data.py

    r1d61d07 rea75043  
    322322 
    323323def plot_theory(data, theory, resid=None, view='log', 
    324                 use_data=True, limits=None): 
     324                use_data=True, limits=None, Iq_calc=None): 
    325325    """ 
    326326    Plot theory calculation. 
     
    343343        _plot_result2D(data, theory, resid, view, use_data, limits=limits) 
    344344    else: 
    345         _plot_result1D(data, theory, resid, view, use_data, limits=limits) 
     345        _plot_result1D(data, theory, resid, view, use_data, 
     346                       limits=limits, Iq_calc=Iq_calc) 
    346347 
    347348 
     
    366367 
    367368@protect 
    368 def _plot_result1D(data, theory, resid, view, use_data, limits=None): 
     369def _plot_result1D(data, theory, resid, view, use_data, 
     370                   limits=None, Iq_calc=None): 
    369371    """ 
    370372    Plot the data and residuals for 1D data. 
     
    376378    use_theory = theory is not None 
    377379    use_resid = resid is not None 
    378     num_plots = (use_data or use_theory) + use_resid 
     380    use_calc = use_theory and Iq_calc is not None 
     381    num_plots = (use_data or use_theory) + use_calc + use_resid 
     382 
    379383 
    380384    scale = data.x**4 if view == 'q4' else 1.0 
     
    416420        plt.ylabel('$I(q)$') 
    417421 
     422    if use_calc: 
     423        # Only have use_calc if have use_theory 
     424        plt.subplot(1, num_plots, 2) 
     425        qx, qy, Iqxy = Iq_calc 
     426        plt.pcolormesh(qx, qy, np.log10(Iqxy)) 
     427        plt.xlabel("$q_x$/A$^{-1}$") 
     428        plt.xlabel("$q_y$/A$^{-1}$") 
     429        #plt.axis('equal') 
     430 
    418431    if use_resid: 
    419432        mresid = masked_array(resid, data.mask.copy()) 
     
    422435 
    423436        if num_plots > 1: 
    424             plt.subplot(1, num_plots, (use_data or use_theory) + 1) 
     437            plt.subplot(1, num_plots, use_calc + 2) 
    425438        plt.plot(data.x, mresid, '-') 
    426439        plt.xlabel("$q$/A$^{-1}$") 
     
    562575    plottable = masked_array(image, ~valid | data.mask) 
    563576    # Divide range by 10 to convert from angstroms to nanometers 
    564     xmin, xmax = min(data.qx_data)/10, max(data.qx_data)/10 
    565     ymin, ymax = min(data.qy_data)/10, max(data.qy_data)/10 
     577    xmin, xmax = min(data.qx_data), max(data.qx_data) 
     578    ymin, ymax = min(data.qy_data), max(data.qy_data) 
    566579    if view == 'log': 
    567580        vmin, vmax = np.log10(vmin), np.log10(vmax) 
    568581    plt.imshow(plottable.reshape(len(data.x_bins), len(data.y_bins)), 
    569                interpolation='nearest', aspect=1, origin='upper', 
     582               interpolation='nearest', aspect=1, origin='lower', 
    570583               extent=[xmin, xmax, ymin, ymax], vmin=vmin, vmax=vmax) 
    571     plt.xlabel("$q_x$/nm$^{-1}$") 
    572     plt.ylabel("$q_y$/nm$^{-1}$") 
     584    plt.xlabel("$q_x$/A$^{-1}$") 
     585    plt.ylabel("$q_y$/A$^{-1}$") 
    573586    return vmin, vmax 
    574587 
Note: See TracChangeset for help on using the changeset viewer.