Changes in sasmodels/compare.py [65fbf7c:1fbadb2] in sasmodels
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/compare.py
r65fbf7c r1fbadb2 645 645 646 646 def make_data(opts): 647 # type: (Dict[str, Any] , float) -> Tuple[Data, np.ndarray]647 # type: (Dict[str, Any]) -> Tuple[Data, np.ndarray] 648 648 """ 649 649 Generate an empty dataset, used with the model to set Q points … … 667 667 if opts['zero']: 668 668 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) 673 670 index = slice(None, None) 674 671 return data, index … … 789 786 base_n, comp_n = opts['count'] 790 787 base_pars, comp_pars = opts['pars'] 791 base_data, comp_data = opts['data']788 data = opts['data'] 792 789 793 790 comparison = comp is not None … … 803 800 print("%s t=%.2f ms, intensity=%.0f" 804 801 % (base.engine, base_time, base_value.sum())) 805 _show_invalid( base_data, base_value)802 _show_invalid(data, base_value) 806 803 except ImportError: 807 804 traceback.print_exc() … … 815 812 print("%s t=%.2f ms, intensity=%.0f" 816 813 % (comp.engine, comp_time, comp_value.sum())) 817 _show_invalid( base_data, comp_value)814 _show_invalid(data, comp_value) 818 815 except ImportError: 819 816 traceback.print_exc() … … 869 866 have_base, have_comp = (base_value is not None), (comp_value is not None) 870 867 base, comp = opts['engines'] 871 base_data, comp_data = opts['data']868 data = opts['data'] 872 869 use_data = (opts['datafile'] is not None) and (have_base ^ have_comp) 873 870 874 871 # Plot if requested 875 872 view = opts['view'] 876 #view = 'log'877 873 if limits is None: 878 874 vmin, vmax = np.inf, -np.inf … … 888 884 if have_comp: 889 885 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) 891 887 plt.title("%s t=%.2f ms"%(base.engine, base_time)) 892 888 #cbar_title = "log I" … … 895 891 plt.subplot(132) 896 892 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) 899 895 plt.title("%s t=%.2f ms"%(comp.engine, comp_time)) 900 896 #cbar_title = "log I" … … 912 908 err[err > cutoff] = cutoff 913 909 #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) 918 911 plt.xscale('log' if view == 'log' and not opts['is2d'] else 'linear') 919 912 plt.legend(['P%d'%(k+1) for k in range(setnum+1)], loc='best') … … 1082 1075 'qmax' : 0.05, 1083 1076 'nq' : 128, 1084 'res' : '0.0',1077 'res' : 0.0, 1085 1078 'noise' : 0.0, 1086 1079 'accuracy' : 'Low', … … 1122 1115 elif arg.startswith('-q='): 1123 1116 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:]) 1125 1118 elif arg.startswith('-noise='): opts['noise'] = float(arg[7:]) 1126 1119 elif arg.startswith('-sets='): opts['sets'] = int(arg[6:]) … … 1180 1173 if opts['qmin'] is None: 1181 1174 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) 1182 1179 1183 1180 comparison = any(PAR_SPLIT in v for v in values) … … 1219 1216 opts['cutoff'] = [float(opts['cutoff'])]*2 1220 1217 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], 1243 1219 opts['cutoff'][0], opts['ngauss'][0]) 1244 1220 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], 1246 1222 opts['cutoff'][1], opts['ngauss'][1]) 1247 1223 else:
Note: See TracChangeset
for help on using the changeset viewer.