Changes in / [a75347f:9dcb21d] in sasmodels
- Files:
-
- 3 deleted
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/compare.py
r630156b r650c6d2 73 73 -1d*/-2d computes 1d or 2d data 74 74 -preset*/-random[=seed] preset or random parameters 75 -mono */-poly force monodisperse or allow polydisperse demo parameters75 -mono/-poly* force monodisperse/polydisperse 76 76 -magnetic/-nonmagnetic* suppress magnetism 77 77 -cutoff=1e-5* cutoff value for including a point in polydispersity … … 84 84 -edit starts the parameter explorer 85 85 -default/-demo* use demo vs default parameters 86 -h elp/-html shows the model docs instead of running the model86 -html shows the model docs instead of running the model 87 87 -title="note" adds note to the plot title, after the model name 88 88 -data="path" uses q, dq from the data file … … 753 753 comp = opts['engines'][1] if have_comp else None 754 754 data = opts['data'] 755 use_data = (opts['datafile'] is not None) and (have_base ^ have_comp)755 use_data = have_base ^ have_comp 756 756 757 757 # Plot if requested 758 758 view = opts['view'] 759 759 import matplotlib.pyplot as plt 760 if limits is None and not use_data:760 if limits is None: 761 761 vmin, vmax = np.Inf, -np.Inf 762 762 if have_base: … … 836 836 'linear', 'log', 'q4', 837 837 'hist', 'nohist', 838 'edit', 'html', 'help',838 'edit', 'html', 839 839 'demo', 'default', 840 840 ]) … … 947 947 'cutoff' : 0.0, 948 948 'seed' : -1, # default to preset 949 'mono' : True,949 'mono' : False, 950 950 # Default to magnetic a magnetic moment is set on the command line 951 951 'magnetic' : False, … … 958 958 'html' : False, 959 959 'title' : None, 960 'data file': None,960 'data' : None, 961 961 } 962 962 engines = [] … … 980 980 elif arg.startswith('-random='): opts['seed'] = int(arg[8:]) 981 981 elif arg.startswith('-title='): opts['title'] = arg[7:] 982 elif arg.startswith('-data='): opts['data file'] = arg[6:]982 elif arg.startswith('-data='): opts['data'] = arg[6:] 983 983 elif arg == '-random': opts['seed'] = np.random.randint(1000000) 984 984 elif arg == '-preset': opts['seed'] = -1 … … 1005 1005 elif arg == '-default': opts['use_demo'] = False 1006 1006 elif arg == '-html': opts['html'] = True 1007 elif arg == '-help': opts['html'] = True1008 1007 # pylint: enable=bad-whitespace 1009 1008 … … 1122 1121 1123 1122 # Create the computational engines 1124 if opts['data file'] is not None:1125 data = load_data(os.path.expanduser(opts['data file']))1123 if opts['data'] is not None: 1124 data = load_data(os.path.expanduser(opts['data'])) 1126 1125 else: 1127 1126 data, _ = make_data(opts) -
sasmodels/data.py
r630156b ra769b54 51 51 from sas.sascalc.dataloader.loader import Loader # type: ignore 52 52 loader = Loader() 53 # Allow for one part in multipart file 54 if '[' in filename: 55 filename, indexstr = filename[:-1].split('[') 56 index = int(indexstr) 57 else: 58 index = None 59 datasets = loader.load(filename) 60 if datasets is None: 53 data = loader.load(filename) 54 if data is None: 61 55 raise IOError("Data %r could not be loaded" % filename) 62 if not isinstance(datasets, list):63 datasets = [datasets]64 if index is None and len(datasets) > 1:65 raise ValueError("Need to specify filename[index] for multipart data")66 data = datasets[index if index is not None else 0]67 56 if hasattr(data, 'x'): 68 57 data.qmin, data.qmax = data.x.min(), data.x.max() 69 58 data.mask = (np.isnan(data.y) if data.y is not None 70 59 else np.zeros_like(data.x, dtype='bool')) 71 elif hasattr(data, 'qx_data'):72 data.mask = ~data.mask73 60 return data 74 61 … … 463 450 if view is 'log': 464 451 mtheory[mtheory <= 0] = masked 465 plt.plot(data.x, scale*mtheory, '-' )452 plt.plot(data.x, scale*mtheory, '-', hold=True) 466 453 all_positive = all_positive and (mtheory > 0).all() 467 454 some_present = some_present or (mtheory.count() > 0) … … 470 457 plt.ylim(*limits) 471 458 472 plt.xscale('linear' if not some_present or non_positive_x 473 else view if view is not None 474 else 'log') 459 plt.xscale('linear' if not some_present or non_positive_x else view) 475 460 plt.yscale('linear' 476 461 if view == 'q4' or not some_present or not all_positive 477 else view if view is not None 478 else 'log') 462 else view) 479 463 plt.xlabel("$q$/A$^{-1}$") 480 464 plt.ylabel('$I(q)$') 481 title = ("data and model" if use_theory and use_data482 else "data" if use_data483 else "model")484 plt.title(title)485 465 486 466 if use_calc: … … 502 482 if num_plots > 1: 503 483 plt.subplot(1, num_plots, use_calc + 2) 504 plt.plot(data.x, mresid, ' .')484 plt.plot(data.x, mresid, '-') 505 485 plt.xlabel("$q$/A$^{-1}$") 506 486 plt.ylabel('residuals') 507 plt.xscale('linear') 508 plt.title('(model - Iq)/dIq') 487 plt.xscale('linear' if not some_present or non_positive_x else view) 509 488 510 489 … … 533 512 if theory is not None: 534 513 if is_tof: 535 plt.plot(data.x, np.log(theory)/(data.lam*data.lam), '-' )514 plt.plot(data.x, np.log(theory)/(data.lam*data.lam), '-', hold=True) 536 515 else: 537 plt.plot(data.x, theory, '-' )516 plt.plot(data.x, theory, '-', hold=True) 538 517 if limits is not None: 539 518 plt.ylim(*limits) -
sasmodels/models/spherical_sld.py
r63a7fe8 r3330bb4 199 199 category = "shape:sphere" 200 200 201 SHAPES = [ "erf(|nu|*z)", "Rpow(z^|nu|)", "Lpow(z^|nu|)",202 "Rexp(-|nu|z)", "Lexp(-|nu|z)"]201 SHAPES = [["erf(|nu|*z)", "Rpow(z^|nu|)", "Lpow(z^|nu|)", 202 "Rexp(-|nu|z)", "Lexp(-|nu|z)"]] 203 203 204 204 # pylint: disable=bad-whitespace, line-too-long … … 209 209 ["thickness[n_shells]", "Ang", 100.0, [0, inf], "volume", "thickness shell"], 210 210 ["interface[n_shells]", "Ang", 50.0, [0, inf], "volume", "thickness of the interface"], 211 ["shape[n_shells]", "", 0, [SHAPES],"", "interface shape"],211 ["shape[n_shells]", "", 0, SHAPES, "", "interface shape"], 212 212 ["nu[n_shells]", "", 2.5, [0, inf], "", "interface shape exponent"], 213 213 ["n_steps", "", 35, [0, inf], "", "number of steps in each interface (must be an odd integer)"], -
sasmodels/rst2html.py
rf2f5413 rc4e3215 155 155 return frame 156 156 157 def view_html_wxapp(html, url=""):158 import wx # type: ignore159 app = wx.App()160 frame = wxview(html, url)161 app.MainLoop()162 163 def view_url_wxapp(url):164 import wx # type: ignore165 from wx.html2 import WebView166 app = wx.App()167 frame = wx.Frame(None, -1, size=(850, 540))168 view = WebView.New(frame)169 view.LoadURL(url)170 frame.Show()171 app.MainLoop()172 173 157 def qtview(html, url=""): 174 158 try: … … 183 167 return helpView 184 168 169 def view_html_wxapp(html, url=""): 170 import wx # type: ignore 171 app = wx.App() 172 frame = wxview(html, url) 173 app.MainLoop() 174 185 175 def view_html_qtapp(html, url=""): 186 176 import sys … … 193 183 sys.exit(app.exec_()) 194 184 195 def view_url_qtapp(url): 196 import sys 197 try: 198 from PyQt5.QtWidgets import QApplication 199 except ImportError: 200 from PyQt4.QtGui import QApplication 201 app = QApplication([]) 202 try: 203 from PyQt5.QtWebKitWidgets import QWebView 204 from PyQt5.QtCore import QUrl 205 except ImportError: 206 from PyQt4.QtWebkit import QWebView 207 from PyQt4.QtCore import QUrl 208 frame = QWebView() 209 frame.load(QUrl(url)) 210 frame.show() 211 sys.exit(app.exec_()) 212 213 def view_help(filename, qt=False): 185 def view_rst_app(filename, qt=False): 214 186 import os 215 url="file:///"+os.path.abspath(filename).replace("\\","/") 216 if filename.endswith('.rst'): 217 html = load_rst_as_html(filename) 218 if qt: 219 view_html_qtapp(html, url) 220 else: 221 view_html_wxapp(html, url) 187 html = load_rst_as_html(filename) 188 url="file://"+os.path.abspath(filename)+"/" 189 if qt: 190 view_html_qtapp(html, url) 222 191 else: 223 if qt: 224 view_url_qtapp(url) 225 else: 226 view_url_wxapp(url) 192 view_html_wxapp(html, url) 227 193 228 194 if __name__ == "__main__": 229 195 import sys 230 view_ help(sys.argv[1], qt=True)196 view_rst_app(sys.argv[1], qt=True) 231 197
Note: See TracChangeset
for help on using the changeset viewer.