Changeset ba69383 in sasmodels


Ignore:
Timestamp:
Oct 31, 2014 4:44:17 PM (10 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:
31819c5
Parents:
ef2861b
Message:

add relerr histogram to compare

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • compare.py

    r2d0aced rba69383  
    8989 
    9090def compare(name, pars, Ncpu, Ngpu, opts, set_pars): 
    91  
    9291    # Sort out data 
    9392    qmax = 1.0 if '-highq' in opts else (0.2 if '-midq' in opts else 0.05) 
     
    180179        resid[index] = (gpu - cpu)[index] 
    181180        relerr[index] = resid[index]/cpu[index] 
     181        #bad = (relerr>1e-4) 
     182        #print relerr[bad],cpu[bad],gpu[bad],data.qx_data[bad],data.qy_data[bad] 
    182183        print "max(|ocl-%s|)"%comp, max(abs(resid[index])) 
    183         print "max(|(ocl-%s)/ocl|)"%comp, max(abs(relerr[index])) 
     184        print "max(|(ocl-%s)/%s|)"%(comp,comp), max(abs(relerr[index])) 
     185        p98 = int(len(relerr[index])*0.98) 
     186        print "98%% (|(ocl-%s)/%s|) <"%(comp,comp), np.sort(abs(relerr[index]))[p98] 
     187 
    184188 
    185189    # Plot if requested 
     
    201205        plot_data(data, err, scale='linear') 
    202206        plt.title("max %s = %.3g"%(errstr, max(abs(err[index])))) 
    203         if is2D: plt.colorbar() 
     207    if is2D: plt.colorbar() 
     208 
     209    if Ncpu > 0 and Ngpu > 0 and '-hist' in opts: 
     210        plt.figure() 
     211        v = relerr[index] 
     212        v[v==0] = 0.5*np.min(np.abs(v[v!=0])) 
     213        plt.hist(np.log10(np.abs(v)), normed=1, bins=50); 
     214        plt.xlabel('log10(err), err = | F(q) single - F(q) double| / | F(q) double |'); 
     215        plt.ylabel('P(err)') 
     216        plt.title('Comparison of single and double precision models for %s'%name) 
     217 
    204218    plt.show() 
    205219 
     
    228242    -pars/-nopars* prints the parameter set or not 
    229243    -abs/-rel* plot relative or absolute error 
     244    -hist/-nohist* plot histogram of relative error 
    230245 
    231246Key=value pairs allow you to set specific values to any of the model 
     
    247262    'nopars','pars', 
    248263    'rel','abs', 
     264    'hist','nohist', 
    249265    ] 
    250266 
     
    272288    name, pars = MODELS[args[0]]() 
    273289    Nopencl = int(args[1]) if len(args) > 1 else 5 
    274     Nsasview = int(args[2]) if len(args) > 3 else 1 
     290    Nsasview = int(args[2]) if len(args) > 2 else 1 
    275291 
    276292    # Fill in default polydispersity parameters 
  • sasmodels/bumps_model.py

    r78356b31 rba69383  
    167167        xmin, xmax = min(data.qx_data), max(data.qx_data) 
    168168        ymin, ymax = min(data.qy_data), max(data.qy_data) 
     169        if vmin is None: vmin = iq[valid&~data.mask].min() 
     170        if vmax is None: vmax = iq[valid&~data.mask].max() 
    169171        plt.imshow(plottable.reshape(128,128), 
    170172                   interpolation='nearest', aspect=1, origin='upper', 
Note: See TracChangeset for help on using the changeset viewer.