- Timestamp:
- Apr 5, 2017 9:36:59 AM (7 years ago)
- Branches:
- master, core_shell_microgels, costrafo411, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
- Children:
- 0b56f38, 4aaf89a
- Parents:
- 4b0a294 (diff), 6e5c0b7 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - Location:
- sasmodels
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/compare.py
r01ea374 r6e5c0b7 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 … … 85 86 -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: … … 747 749 comp = opts['engines'][1] if have_comp else None 748 750 data = opts['data'] 751 use_data = have_base ^ have_comp 749 752 750 753 # Plot if requested … … 763 766 if have_base: 764 767 if have_comp: plt.subplot(131) 765 plot_theory(data, base_value, view=view, use_data= False, limits=limits)768 plot_theory(data, base_value, view=view, use_data=use_data, limits=limits) 766 769 plt.title("%s t=%.2f ms"%(base.engine, base_time)) 767 770 #cbar_title = "log I" … … 769 772 if have_base: plt.subplot(132) 770 773 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)774 plot_theory(data, base_value, view=view, use_data=use_data, limits=limits) 775 plot_theory(data, comp_value, view=view, use_data=use_data, limits=limits) 773 776 plt.title("%s t=%.2f ms"%(comp.engine, comp_time)) 774 777 #cbar_title = "log I" … … 784 787 err[err>cutoff] = cutoff 785 788 #err,errstr = base/comp,"ratio" 786 plot_theory(data, None, resid=err, view=errview, use_data= False)789 plot_theory(data, None, resid=err, view=errview, use_data=use_data) 787 790 if view == 'linear': 788 791 plt.xscale('linear') … … 834 837 VALUE_OPTIONS = [ 835 838 # Note: random is both a name option and a value option 836 'cutoff', 'random', 'nq', 'res', 'accuracy', 'title', 839 'cutoff', 'random', 'nq', 'res', 'accuracy', 'title', 'data', 837 840 ] 838 841 … … 951 954 'html' : False, 952 955 'title' : None, 956 'data' : None, 953 957 } 954 958 engines = [] … … 971 975 elif arg.startswith('-cutoff='): opts['cutoff'] = float(arg[8:]) 972 976 elif arg.startswith('-random='): opts['seed'] = int(arg[8:]) 973 elif arg.startswith('-title'): opts['title'] = arg[7:] 977 elif arg.startswith('-title='): opts['title'] = arg[7:] 978 elif arg.startswith('-data='): opts['data'] = arg[6:] 974 979 elif arg == '-random': opts['seed'] = np.random.randint(1000000) 975 980 elif arg == '-preset': opts['seed'] = -1 … … 1113 1118 1114 1119 # Create the computational engines 1115 data, _ = make_data(opts) 1120 if opts['data'] is not None: 1121 data = load_data(os.path.expanduser(opts['data'])) 1122 else: 1123 data, _ = make_data(opts) 1116 1124 if n1: 1117 1125 base = make_engine(model_info, data, engines[0], opts['cutoff']) … … 1143 1151 show html docs for the model 1144 1152 """ 1145 import wx # type: ignore 1146 from .generate import view_html_from_info 1147 app = wx.App() if wx.GetApp() is None else None 1148 view_html_from_info(opts['def'][0]) 1149 if app: app.MainLoop() 1150 1153 import os 1154 from .generate import make_html 1155 from . import rst2html 1156 1157 info = opts['def'][0] 1158 html = make_html(info) 1159 path = os.path.dirname(info.filename) 1160 url = "file://"+path.replace("\\","/")[2:]+"/" 1161 rst2html.view_html_qtapp(html, url) 1151 1162 1152 1163 def explore(opts): -
sasmodels/data.py
r40a87fa ra769b54 54 54 if data is None: 55 55 raise IOError("Data %r could not be loaded" % filename) 56 if hasattr(data, 'x'): 57 data.qmin, data.qmax = data.x.min(), data.x.max() 58 data.mask = (np.isnan(data.y) if data.y is not None 59 else np.zeros_like(data.x, dtype='bool')) 56 60 return data 57 61 … … 348 352 # data, but they already handle the masking and graph markup already, so 349 353 # do not repeat. 350 if hasattr(data, ' lam'):354 if hasattr(data, 'isSesans') and data.isSesans: 351 355 _plot_result_sesans(data, None, None, use_data=True, limits=limits) 352 356 elif hasattr(data, 'qx_data'): … … 376 380 *Iq_calc* is the raw theory values without resolution smearing 377 381 """ 378 if hasattr(data, ' lam'):382 if hasattr(data, 'isSesans') and data.isSesans: 379 383 _plot_result_sesans(data, theory, resid, use_data=True, limits=limits) 380 384 elif hasattr(data, 'qx_data'): -
sasmodels/direct_model.py
rb397165 ra769b54 192 192 193 193 # interpret data 194 if hasattr(data, ' lam'):194 if hasattr(data, 'isSesans') and data.isSesans: 195 195 self.data_type = 'sesans' 196 196 elif hasattr(data, 'qx_data'): -
sasmodels/generate.py
r1e7b0db0 rc4e3215 928 928 from . import rst2html 929 929 url = "file://"+dirname(info.filename)+"/" 930 rst2html. wxview(make_html(info), url=url)930 rst2html.view_html(make_html(info), url=url) 931 931 932 932 def demo_time(): -
sasmodels/rst2html.py
r0890871 rc4e3215 29 29 from docutils.writers.html4css1 import HTMLTranslator 30 30 from docutils.nodes import SkipNode 31 32 def wxview(html, url="", size=(850, 540)):33 import wx34 from wx.html2 import WebView35 frame = wx.Frame(None, -1, size=size)36 view = WebView.New(frame)37 view.SetPage(html, url)38 frame.Show()39 return frame40 41 def view_rst(filename):42 from os.path import expanduser43 with open(expanduser(filename)) as fid:44 rst = fid.read()45 html = rst2html(rst)46 wxview(html)47 31 48 32 def rst2html(rst, part="whole", math_output="mathjax"): … … 155 139 assert replace_dollar(u"a (again $in parens$) a") == u"a (again :math:`in parens`) a" 156 140 157 def view_rst_app(filename): 141 def load_rst_as_html(filename): 142 from os.path import expanduser 143 with open(expanduser(filename)) as fid: 144 rst = fid.read() 145 html = rst2html(rst) 146 return html 147 148 def wxview(html, url="", size=(850, 540)): 149 import wx 150 from wx.html2 import WebView 151 frame = wx.Frame(None, -1, size=size) 152 view = WebView.New(frame) 153 view.SetPage(html, url) 154 frame.Show() 155 return frame 156 157 def qtview(html, url=""): 158 try: 159 from PyQt5.QtWebKitWidgets import QWebView 160 from PyQt5.QtCore import QUrl 161 except ImportError: 162 from PyQt4.QtWebkit import QWebView 163 from PyQt4.QtCore import QUrl 164 helpView = QWebView() 165 helpView.setHtml(html, QUrl(url)) 166 helpView.show() 167 return helpView 168 169 def view_html_wxapp(html, url=""): 158 170 import wx # type: ignore 159 171 app = wx.App() 160 view_rst(filename)172 frame = wxview(html, url) 161 173 app.MainLoop() 162 174 175 def view_html_qtapp(html, url=""): 176 import sys 177 try: 178 from PyQt5.QtWidgets import QApplication 179 except ImportError: 180 from PyQt4.QtGui import QApplication 181 app = QApplication([]) 182 frame = qtview(html, url) 183 sys.exit(app.exec_()) 184 185 def view_rst_app(filename, qt=False): 186 import os 187 html = load_rst_as_html(filename) 188 url="file://"+os.path.abspath(filename)+"/" 189 if qt: 190 view_html_qtapp(html, url) 191 else: 192 view_html_wxapp(html, url) 163 193 164 194 if __name__ == "__main__": 165 195 import sys 166 view_rst_app(sys.argv[1] )196 view_rst_app(sys.argv[1], qt=True) 167 197 -
sasmodels/models/ellipsoid.py
r3b571ae r4b0a294 161 161 def ER(radius_polar, radius_equatorial): 162 162 import numpy as np 163 163 # see equation (26) in A.Isihara, J.Chem.Phys. 18(1950)1446-1449 164 164 ee = np.empty_like(radius_polar) 165 165 idx = radius_polar > radius_equatorial -
sasmodels/models/triaxial_ellipsoid.py
r28d3067 r4b0a294 16 16 \frac{X^2}{R_a^2} + \frac{Y^2}{R_b^2} + \frac{Z^2}{R_c^2} = 1 17 17 18 the scattering is defined by the average over all orientations $\Omega$,18 the scattering for randomly oriented particles is defined by the average over all orientations $\Omega$ of: 19 19 20 20 .. math:: 21 21 22 P(q) = \text{scale} \frac{V}{4 \pi}\int_\Omega \Phi^2(qr) d\Omega + \text{background}22 P(q) = \text{scale}(\Delta\rho)^2\frac{V}{4 \pi}\int_\Omega \Phi^2(qr) d\Omega + \text{background} 23 23 24 24 where … … 79 79 The radius-of-gyration for this system is $R_g^2 = (R_a R_b R_c)^2/5$. 80 80 81 The contrast is defined as SLD(ellipsoid) - SLD(solvent). In the81 The contrast $\Delta\rho$ is defined as SLD(ellipsoid) - SLD(solvent). In the 82 82 parameters, $R_a$ is the minor equatorial radius, $R_b$ is the major 83 83 equatorial radius, and $R_c$ is the polar radius of the ellipsoid. … … 102 102 *Light scattering by ellipsoidal particles in solution*, 103 103 J. Phys. D: Appl. Phys. 4, 72-77. doi:10.1088/0022-3727/4/1/310 104 105 Authorship and Verification 106 ---------------------------- 107 108 * **Author:** NIST IGOR/DANSE **Date:** pre 2010 109 * **Last Modified by:** Paul Kienzle (improved calculation) **Date:** April 4, 2017 110 * **Last Reviewed by:** Paul Kienzle &Richard Heenan **Date:** April 4, 2017 104 111 105 112 """ … … 144 151 import numpy as np 145 152 from .ellipsoid import ER as ellipsoid_ER 153 # now that radii can be in any size order, radii need sorting a,b,c where a~b and c is either much smaller or much larger 154 # also need some unit tests! 155 146 156 return ellipsoid_ER(radius_polar, np.sqrt(radius_equat_minor * radius_equat_major)) 147 157
Note: See TracChangeset
for help on using the changeset viewer.