Changes in sasmodels/compare.py [f72d70a:630156b] in sasmodels
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/compare.py
rf72d70a r630156b 30 30 31 31 import sys 32 import os 32 33 import math 33 34 import datetime … … 40 41 from . import kerneldll 41 42 from . import exception 42 from .data import plot_theory, empty_data1D, empty_data2D 43 from .data import plot_theory, empty_data1D, empty_data2D, load_data 43 44 from .direct_model import DirectModel 44 45 from .convert import revert_name, revert_pars, constrain_new_to_old … … 72 73 -1d*/-2d computes 1d or 2d data 73 74 -preset*/-random[=seed] preset or random parameters 74 -mono /-poly* force monodisperse/polydisperse75 -mono*/-poly force monodisperse or allow polydisperse demo parameters 75 76 -magnetic/-nonmagnetic* suppress magnetism 76 77 -cutoff=1e-5* cutoff value for including a point in polydispersity … … 83 84 -edit starts the parameter explorer 84 85 -default/-demo* use demo vs default parameters 85 -h tml shows the model docs instead of running the model86 -help/-html shows the model docs instead of running the model 86 87 -title="note" adds note to the plot title, after the model name 88 -data="path" uses q, dq from the data file 87 89 88 90 Any two calculation engines can be selected for comparison: … … 544 546 'f32': '32', 545 547 'f64': '64', 548 'float16': '16', 549 'float32': '32', 550 'float64': '64', 551 'float128': '128', 546 552 'longdouble': '128', 547 553 } … … 747 753 comp = opts['engines'][1] if have_comp else None 748 754 data = opts['data'] 755 use_data = (opts['datafile'] is not None) and (have_base ^ have_comp) 749 756 750 757 # Plot if requested 751 758 view = opts['view'] 752 759 import matplotlib.pyplot as plt 753 if limits is None :760 if limits is None and not use_data: 754 761 vmin, vmax = np.Inf, -np.Inf 755 762 if have_base: … … 763 770 if have_base: 764 771 if have_comp: plt.subplot(131) 765 plot_theory(data, base_value, view=view, use_data= False, limits=limits)772 plot_theory(data, base_value, view=view, use_data=use_data, limits=limits) 766 773 plt.title("%s t=%.2f ms"%(base.engine, base_time)) 767 774 #cbar_title = "log I" … … 769 776 if have_base: plt.subplot(132) 770 777 if not opts['is2d'] and have_base: 771 plot_theory(data, base_value, view=view, use_data= False, limits=limits)772 plot_theory(data, comp_value, view=view, use_data= False, limits=limits)778 plot_theory(data, base_value, view=view, use_data=use_data, limits=limits) 779 plot_theory(data, comp_value, view=view, use_data=use_data, limits=limits) 773 780 plt.title("%s t=%.2f ms"%(comp.engine, comp_time)) 774 781 #cbar_title = "log I" … … 784 791 err[err>cutoff] = cutoff 785 792 #err,errstr = base/comp,"ratio" 786 plot_theory(data, None, resid=err, view=errview, use_data= False)793 plot_theory(data, None, resid=err, view=errview, use_data=use_data) 787 794 if view == 'linear': 788 795 plt.xscale('linear') … … 829 836 'linear', 'log', 'q4', 830 837 'hist', 'nohist', 831 'edit', 'html', 838 'edit', 'html', 'help', 832 839 'demo', 'default', 833 840 ]) 834 841 VALUE_OPTIONS = [ 835 842 # Note: random is both a name option and a value option 836 'cutoff', 'random', 'nq', 'res', 'accuracy', 'title', 843 'cutoff', 'random', 'nq', 'res', 'accuracy', 'title', 'data', 837 844 ] 838 845 … … 940 947 'cutoff' : 0.0, 941 948 'seed' : -1, # default to preset 942 'mono' : False,949 'mono' : True, 943 950 # Default to magnetic a magnetic moment is set on the command line 944 951 'magnetic' : False, … … 951 958 'html' : False, 952 959 'title' : None, 960 'datafile' : None, 953 961 } 954 962 engines = [] … … 971 979 elif arg.startswith('-cutoff='): opts['cutoff'] = float(arg[8:]) 972 980 elif arg.startswith('-random='): opts['seed'] = int(arg[8:]) 973 elif arg.startswith('-title'): opts['title'] = arg[7:] 981 elif arg.startswith('-title='): opts['title'] = arg[7:] 982 elif arg.startswith('-data='): opts['datafile'] = arg[6:] 974 983 elif arg == '-random': opts['seed'] = np.random.randint(1000000) 975 984 elif arg == '-preset': opts['seed'] = -1 … … 996 1005 elif arg == '-default': opts['use_demo'] = False 997 1006 elif arg == '-html': opts['html'] = True 1007 elif arg == '-help': opts['html'] = True 998 1008 # pylint: enable=bad-whitespace 999 1009 … … 1112 1122 1113 1123 # Create the computational engines 1114 data, _ = make_data(opts) 1124 if opts['datafile'] is not None: 1125 data = load_data(os.path.expanduser(opts['datafile'])) 1126 else: 1127 data, _ = make_data(opts) 1115 1128 if n1: 1116 1129 base = make_engine(model_info, data, engines[0], opts['cutoff']) … … 1142 1155 show html docs for the model 1143 1156 """ 1144 import wx # type: ignore 1145 from .generate import view_html_from_info 1146 app = wx.App() if wx.GetApp() is None else None 1147 view_html_from_info(opts['def'][0]) 1148 if app: app.MainLoop() 1149 1157 import os 1158 from .generate import make_html 1159 from . import rst2html 1160 1161 info = opts['def'][0] 1162 html = make_html(info) 1163 path = os.path.dirname(info.filename) 1164 url = "file://"+path.replace("\\","/")[2:]+"/" 1165 rst2html.view_html_qtapp(html, url) 1150 1166 1151 1167 def explore(opts):
Note: See TracChangeset
for help on using the changeset viewer.