Changes in sasmodels/compare.py [65fbf7c:1fbadb2] in sasmodels


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/compare.py

    r65fbf7c r1fbadb2  
    645645 
    646646def make_data(opts): 
    647     # type: (Dict[str, Any], float) -> Tuple[Data, np.ndarray] 
     647    # type: (Dict[str, Any]) -> Tuple[Data, np.ndarray] 
    648648    """ 
    649649    Generate an empty dataset, used with the model to set Q points 
     
    667667        if opts['zero']: 
    668668            q = np.hstack((0, q)) 
    669         # TODO: provide command line control of lambda and Delta lambda/lambda 
    670         #L, dLoL = 5, 0.14/np.sqrt(6)  # wavelength and 14% triangular FWHM 
    671         L, dLoL = 0, 0 
    672         data = empty_data1D(q, resolution=res, L=L, dL=L*dLoL) 
     669        data = empty_data1D(q, resolution=res) 
    673670        index = slice(None, None) 
    674671    return data, index 
     
    789786    base_n, comp_n = opts['count'] 
    790787    base_pars, comp_pars = opts['pars'] 
    791     base_data, comp_data = opts['data'] 
     788    data = opts['data'] 
    792789 
    793790    comparison = comp is not None 
     
    803800            print("%s t=%.2f ms, intensity=%.0f" 
    804801                  % (base.engine, base_time, base_value.sum())) 
    805         _show_invalid(base_data, base_value) 
     802        _show_invalid(data, base_value) 
    806803    except ImportError: 
    807804        traceback.print_exc() 
     
    815812                print("%s t=%.2f ms, intensity=%.0f" 
    816813                      % (comp.engine, comp_time, comp_value.sum())) 
    817             _show_invalid(base_data, comp_value) 
     814            _show_invalid(data, comp_value) 
    818815        except ImportError: 
    819816            traceback.print_exc() 
     
    869866    have_base, have_comp = (base_value is not None), (comp_value is not None) 
    870867    base, comp = opts['engines'] 
    871     base_data, comp_data = opts['data'] 
     868    data = opts['data'] 
    872869    use_data = (opts['datafile'] is not None) and (have_base ^ have_comp) 
    873870 
    874871    # Plot if requested 
    875872    view = opts['view'] 
    876     #view = 'log' 
    877873    if limits is None: 
    878874        vmin, vmax = np.inf, -np.inf 
     
    888884        if have_comp: 
    889885            plt.subplot(131) 
    890         plot_theory(base_data, base_value, view=view, use_data=use_data, limits=limits) 
     886        plot_theory(data, base_value, view=view, use_data=use_data, limits=limits) 
    891887        plt.title("%s t=%.2f ms"%(base.engine, base_time)) 
    892888        #cbar_title = "log I" 
     
    895891            plt.subplot(132) 
    896892        if not opts['is2d'] and have_base: 
    897             plot_theory(comp_data, base_value, view=view, use_data=use_data, limits=limits) 
    898         plot_theory(comp_data, comp_value, view=view, use_data=use_data, limits=limits) 
     893            plot_theory(data, base_value, view=view, use_data=use_data, limits=limits) 
     894        plot_theory(data, comp_value, view=view, use_data=use_data, limits=limits) 
    899895        plt.title("%s t=%.2f ms"%(comp.engine, comp_time)) 
    900896        #cbar_title = "log I" 
     
    912908            err[err > cutoff] = cutoff 
    913909        #err,errstr = base/comp,"ratio" 
    914         # Note: base_data only since base and comp have same q values (though 
    915         # perhaps different resolution), and we are plotting the difference 
    916         # at each q 
    917         plot_theory(base_data, None, resid=err, view=errview, use_data=use_data) 
     910        plot_theory(data, None, resid=err, view=errview, use_data=use_data) 
    918911        plt.xscale('log' if view == 'log' and not opts['is2d'] else 'linear') 
    919912        plt.legend(['P%d'%(k+1) for k in range(setnum+1)], loc='best') 
     
    10821075        'qmax'      : 0.05, 
    10831076        'nq'        : 128, 
    1084         'res'       : '0.0', 
     1077        'res'       : 0.0, 
    10851078        'noise'     : 0.0, 
    10861079        'accuracy'  : 'Low', 
     
    11221115        elif arg.startswith('-q='): 
    11231116            opts['qmin'], opts['qmax'] = [float(v) for v in arg[3:].split(':')] 
    1124         elif arg.startswith('-res='):      opts['res'] = arg[5:] 
     1117        elif arg.startswith('-res='):      opts['res'] = float(arg[5:]) 
    11251118        elif arg.startswith('-noise='):    opts['noise'] = float(arg[7:]) 
    11261119        elif arg.startswith('-sets='):     opts['sets'] = int(arg[6:]) 
     
    11801173    if opts['qmin'] is None: 
    11811174        opts['qmin'] = 0.001*opts['qmax'] 
     1175    if opts['datafile'] is not None: 
     1176        data = load_data(os.path.expanduser(opts['datafile'])) 
     1177    else: 
     1178        data, _ = make_data(opts) 
    11821179 
    11831180    comparison = any(PAR_SPLIT in v for v in values) 
     
    12191216        opts['cutoff'] = [float(opts['cutoff'])]*2 
    12201217 
    1221     if PAR_SPLIT in opts['res']: 
    1222         opts['res'] = [float(k) for k in opts['res'].split(PAR_SPLIT, 2)] 
    1223         comparison = True 
    1224     else: 
    1225         opts['res'] = [float(opts['res'])]*2 
    1226  
    1227     if opts['datafile'] is not None: 
    1228         data = load_data(os.path.expanduser(opts['datafile'])) 
    1229     else: 
    1230         # Hack around the fact that make_data doesn't take a pair of resolutions 
    1231         res = opts['res'] 
    1232         opts['res'] = res[0] 
    1233         data0, _ = make_data(opts) 
    1234         if res[0] != res[1]: 
    1235             opts['res'] = res[1] 
    1236             data1, _ = make_data(opts) 
    1237         else: 
    1238             data1 = data0 
    1239         opts['res'] = res 
    1240         data = data0, data1 
    1241  
    1242     base = make_engine(model_info[0], data[0], opts['engine'][0], 
     1218    base = make_engine(model_info[0], data, opts['engine'][0], 
    12431219                       opts['cutoff'][0], opts['ngauss'][0]) 
    12441220    if comparison: 
    1245         comp = make_engine(model_info[1], data[1], opts['engine'][1], 
     1221        comp = make_engine(model_info[1], data, opts['engine'][1], 
    12461222                           opts['cutoff'][1], opts['ngauss'][1]) 
    12471223    else: 
Note: See TracChangeset for help on using the changeset viewer.