Changeset 1198f90 in sasmodels for sasmodels/compare.py


Ignore:
Timestamp:
May 17, 2018 8:07:02 PM (6 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:
df0d2ca
Parents:
33969b6
Message:

limit pinhole resolution integral to ± 2.5 dq

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/compare.py

    r1fbadb2 r1198f90  
    645645 
    646646def make_data(opts): 
    647     # type: (Dict[str, Any]) -> Tuple[Data, np.ndarray] 
     647    # type: (Dict[str, Any], float) -> Tuple[Data, np.ndarray] 
    648648    """ 
    649649    Generate an empty dataset, used with the model to set Q points 
     
    786786    base_n, comp_n = opts['count'] 
    787787    base_pars, comp_pars = opts['pars'] 
    788     data = opts['data'] 
     788    base_data, comp_data = opts['data'] 
    789789 
    790790    comparison = comp is not None 
     
    800800            print("%s t=%.2f ms, intensity=%.0f" 
    801801                  % (base.engine, base_time, base_value.sum())) 
    802         _show_invalid(data, base_value) 
     802        _show_invalid(base_data, base_value) 
    803803    except ImportError: 
    804804        traceback.print_exc() 
     
    812812                print("%s t=%.2f ms, intensity=%.0f" 
    813813                      % (comp.engine, comp_time, comp_value.sum())) 
    814             _show_invalid(data, comp_value) 
     814            _show_invalid(base_data, comp_value) 
    815815        except ImportError: 
    816816            traceback.print_exc() 
     
    866866    have_base, have_comp = (base_value is not None), (comp_value is not None) 
    867867    base, comp = opts['engines'] 
    868     data = opts['data'] 
     868    base_data, comp_data = opts['data'] 
    869869    use_data = (opts['datafile'] is not None) and (have_base ^ have_comp) 
    870870 
     
    884884        if have_comp: 
    885885            plt.subplot(131) 
    886         plot_theory(data, base_value, view=view, use_data=use_data, limits=limits) 
     886        plot_theory(base_data, base_value, view=view, use_data=use_data, limits=limits) 
    887887        plt.title("%s t=%.2f ms"%(base.engine, base_time)) 
    888888        #cbar_title = "log I" 
     
    891891            plt.subplot(132) 
    892892        if not opts['is2d'] and have_base: 
    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) 
     893            plot_theory(comp_data, base_value, view=view, use_data=use_data, limits=limits) 
     894        plot_theory(comp_data, comp_value, view=view, use_data=use_data, limits=limits) 
    895895        plt.title("%s t=%.2f ms"%(comp.engine, comp_time)) 
    896896        #cbar_title = "log I" 
     
    908908            err[err > cutoff] = cutoff 
    909909        #err,errstr = base/comp,"ratio" 
    910         plot_theory(data, None, resid=err, view=errview, use_data=use_data) 
     910        # Note: base_data only since base and comp have same q values (though 
     911        # perhaps different resolution), and we are plotting the difference 
     912        # at each q 
     913        plot_theory(base_data, None, resid=err, view=errview, use_data=use_data) 
    911914        plt.xscale('log' if view == 'log' and not opts['is2d'] else 'linear') 
    912915        plt.legend(['P%d'%(k+1) for k in range(setnum+1)], loc='best') 
     
    10751078        'qmax'      : 0.05, 
    10761079        'nq'        : 128, 
    1077         'res'       : 0.0, 
     1080        'res'       : '0.0', 
    10781081        'noise'     : 0.0, 
    10791082        'accuracy'  : 'Low', 
     
    11151118        elif arg.startswith('-q='): 
    11161119            opts['qmin'], opts['qmax'] = [float(v) for v in arg[3:].split(':')] 
    1117         elif arg.startswith('-res='):      opts['res'] = float(arg[5:]) 
     1120        elif arg.startswith('-res='):      opts['res'] = arg[5:] 
    11181121        elif arg.startswith('-noise='):    opts['noise'] = float(arg[7:]) 
    11191122        elif arg.startswith('-sets='):     opts['sets'] = int(arg[6:]) 
     
    11731176    if opts['qmin'] is None: 
    11741177        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) 
    11791178 
    11801179    comparison = any(PAR_SPLIT in v for v in values) 
     
    12161215        opts['cutoff'] = [float(opts['cutoff'])]*2 
    12171216 
    1218     base = make_engine(model_info[0], data, opts['engine'][0], 
     1217    if PAR_SPLIT in opts['res']: 
     1218        opts['res'] = [float(k) for k in opts['res'].split(PAR_SPLIT, 2)] 
     1219        comparison = True 
     1220    else: 
     1221        opts['res'] = [float(opts['res'])]*2 
     1222 
     1223    if opts['datafile'] is not None: 
     1224        data = load_data(os.path.expanduser(opts['datafile'])) 
     1225    else: 
     1226        # Hack around the fact that make_data doesn't take a pair of resolutions 
     1227        res = opts['res'] 
     1228        opts['res'] = res[0] 
     1229        data0, _ = make_data(opts) 
     1230        if res[0] != res[1]: 
     1231            opts['res'] = res[1] 
     1232            data1, _ = make_data(opts) 
     1233        else: 
     1234            data1 = data0 
     1235        opts['res'] = res 
     1236        data = data0, data1 
     1237 
     1238    base = make_engine(model_info[0], data[0], opts['engine'][0], 
    12191239                       opts['cutoff'][0], opts['ngauss'][0]) 
    12201240    if comparison: 
    1221         comp = make_engine(model_info[1], data, opts['engine'][1], 
     1241        comp = make_engine(model_info[1], data[1], opts['engine'][1], 
    12221242                           opts['cutoff'][1], opts['ngauss'][1]) 
    12231243    else: 
Note: See TracChangeset for help on using the changeset viewer.