Changes in / [a03fad8:ba62072] in sasmodels
- Files:
-
- 13 added
- 24 deleted
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
.gitignore
r8ae8532 r2a55a6f 11 11 /doc/api/ 12 12 /doc/model/ 13 /doc/ guide/models13 /doc/ref/models 14 14 .mplconfig 15 15 /pylint_violations.txt -
doc/conf.py
r8ae8532 r40a87fa 42 42 ] 43 43 44 # Redirect mathjax to a different CDN45 mathjax_path = "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-MML-AM_CHTML"46 47 44 # Add any paths that contain templates here, relative to this directory. 48 45 templates_path = ['_templates'] -
doc/developer/calculator.rst
r2e66ef5 re822c97 7 7 model calculator which implements the polydispersity and magnetic SLD 8 8 calculations. There are three separate implementations of this layer, 9 :mod:`kernelcl`for OpenCL, which operates on a single Q value at a time,10 :mod:`kerneldll`for the DLL, which loops over a vector of Q values, and11 :mod:`kernelpy`for python models which operates on vector Q values.9 *kernelcl.py* for OpenCL, which operates on a single Q value at a time, 10 *kerneldll.c* for the DLL, which loops over a vector of Q values, and 11 *kernelpy.py* for python models which operates on vector Q values. 12 12 13 13 Each implementation provides three different calls *Iq*, *Iqxy* and *Imagnetic* -
doc/developer/index.rst
r2e66ef5 rb85be2d 7 7 :maxdepth: 4 8 8 9 overview.rst10 9 calculator.rst -
doc/genapi.py
r2e66ef5 ra5b8477 2 2 import os.path 3 3 4 MODULE_TEMPLATE =""".. Autogenerated by genmods.py4 MODULE_TEMPLATE=""".. Autogenerated by genmods.py 5 5 6 6 ****************************************************************************** … … 19 19 """ 20 20 21 INDEX_TEMPLATE =""".. Autogenerated by genmods.py21 INDEX_TEMPLATE=""".. Autogenerated by genmods.py 22 22 23 23 .. _api-index: … … 46 46 os.makedirs(dir) 47 47 48 for module, 49 with open(os.path.join(dir, 48 for module,name in modules: 49 with open(os.path.join(dir,module+'.rst'), 'w') as f: 50 50 f.write(MODULE_TEMPLATE%locals()) 51 51 52 rsts = "\n ".join(module+'.rst' for module, 53 with open(os.path.join(dir, 'index.rst'),'w') as f:52 rsts = "\n ".join(module+'.rst' for module,name in modules) 53 with open(os.path.join(dir,'index.rst'),'w') as f: 54 54 f.write(INDEX_TEMPLATE%locals()) 55 55 56 56 57 modules =[58 ('__init__', 'Sasmodels package'),57 modules=[ 58 #('__init__', 'Top level namespace'), 59 59 #('alignment', 'GPU data alignment [unused]'), 60 60 ('bumps_model', 'Bumps interface'), 61 ('compare_many', 'Batch compare models on different compute engines'),62 61 ('compare', 'Compare models on different compute engines'), 63 62 ('convert', 'Sasview to sasmodel converter'), … … 67 66 ('direct_model', 'Simple interface'), 68 67 ('exception', 'Annotate exceptions'), 68 #('frozendict', 'Freeze a dictionary to make it immutable'), 69 69 ('generate', 'Model parser'), 70 70 ('kernel', 'Evaluator type definitions'), … … 79 79 ('resolution', '1-D resolution functions'), 80 80 ('resolution2d', '2-D resolution functions'), 81 ('rst2html', 'Convert doc strings the web pages'),82 81 ('sasview_model', 'Sasview interface'), 83 82 ('sesans', 'SESANS calculation routines'), 83 #('transition', 'Model stepper for automatic model selection'), 84 84 ('weights', 'Distribution functions'), 85 85 ] 86 package ='sasmodels'87 package_name ='Reference'86 package='sasmodels' 87 package_name='Reference' 88 88 genfiles(package, package_name, modules) -
doc/gentoc.py
r990d8df r40a87fa 16 16 from sasmodels.modelinfo import ModelInfo 17 17 18 TEMPLATE ="""\18 TEMPLATE="""\ 19 19 .. 20 20 Generated from doc/gentoc.py -- DO NOT EDIT -- … … 30 30 """ 31 31 32 MODEL_TOC_PATH = " guide/models"32 MODEL_TOC_PATH = "ref/models" 33 33 34 34 def _make_category(category_name, label, title, parent=None): … … 65 65 # assume model is in sasmodels/models/name.py, and ignore the full path 66 66 model_name = basename(item)[:-3] 67 if model_name.startswith('_'): 68 continue 67 if model_name.startswith('_'): continue 69 68 model_info = load_model_info(model_name) 70 69 if model_info.category is None: 71 70 print("Missing category for", item, file=sys.stderr) 72 71 else: 73 category.setdefault(model_info.category, 72 category.setdefault(model_info.category,[]).append(model_name) 74 73 75 74 # Check category names 76 for k, 75 for k,v in category.items(): 77 76 if len(v) == 1: 78 print("Category %s contains only %s"%(k, 77 print("Category %s contains only %s"%(k,v[0]), file=sys.stderr) 79 78 80 79 # Generate category files for the table of contents. … … 87 86 # alphabetical order before them. 88 87 89 if not exists(MODEL_TOC_PATH): 90 mkdir(MODEL_TOC_PATH) 88 if not exists(MODEL_TOC_PATH): mkdir(MODEL_TOC_PATH) 91 89 model_toc = _make_category( 92 'index', 'Models', 'Model Functions')90 'index', 'Models', 'Model Functions') 93 91 #shape_toc = _make_category( 94 92 # 'shape', 'Shapes', 'Shape Functions', model_toc) 95 93 free_toc = _make_category( 96 'shape-independent', 'Shape-independent',94 'shape-independent', 'Shape-independent', 97 95 'Shape-Independent Functions') 98 96 struct_toc = _make_category( 99 'structure-factor', 'Structure-factor', 'Structure Factors')100 #custom_toc = _make_category(101 # 'custom-models','Custom-models', 'Custom Models')97 'structure-factor', 'Structure-factor', 'Structure Factors') 98 custom_toc = _make_category( 99 'custom-models', 'Custom-models', 'Custom Models') 102 100 103 101 # remember to top level categories … … 107 105 'shape-independent':free_toc, 108 106 'structure-factor': struct_toc, 109 #'custom': custom_toc,107 'custom': custom_toc, 110 108 } 111 109 112 110 # Process the model lists 113 for k, 111 for k,v in sorted(category.items()): 114 112 if ':' in k: 115 cat, 113 cat,subcat = k.split(':') 116 114 _maybe_make_category(cat, v, cat_files, model_toc) 117 115 cat_file = cat_files[cat] 118 label = "-".join((cat, 116 label = "-".join((cat,subcat)) 119 117 filename = label 120 title = subcat.capitalize() +" Functions"118 title = subcat.capitalize()+" Functions" 121 119 sub_toc = _make_category(filename, label, title, cat_file) 122 120 for model in sorted(v): … … 132 130 _add_subcategory('shape-independent', model_toc) 133 131 _add_subcategory('structure-factor', model_toc) 134 #_add_subcategory('custom-models', model_toc)132 _add_subcategory('custom-models', model_toc) 135 133 136 134 # Close the top-level category files 137 135 #model_toc.close() 138 for f in cat_files.values(): 139 f.close() 136 for f in cat_files.values(): f.close() 140 137 141 138 -
doc/guide/index.rst
r2e66ef5 rbb6f0f3 1 ********** ******2 SAS Models Guide3 ********** ******1 ********** 2 SAS Models 3 ********** 4 4 5 .. toctree:: 6 :numbered: 4 7 :maxdepth: 4 5 Small angle X-ray and Neutron (SAXS and SANS) scattering examines the 6 scattering patterns produced by a beam travelling through the sample 7 and scattering at low angles. The scattering is computed as a function 8 of $q_x$ and $q_y$, which for a given beam wavelength corresponds to 9 particular scattering angles. Each pixel on the detector corresponds to 10 a different scattering angle. If the sample is unoriented, the scattering 11 pattern will appear as rings on the detector. In this case, a circular 12 average can be taken with 1-dimension data at $q = \surd (q_x^2 + q_y^2)$ 13 compared to the orientationally averaged SAS scattering pattern. 8 14 9 intro.rst 10 install.rst 11 pd/polydispersity.rst 12 resolution.rst 13 magnetism/magnetism.rst 14 sesans/sans_to_sesans.rst 15 sesans/sesans_fitting.rst 16 plugin.rst 17 scripting.rst 18 refs.rst 15 Models have certain features in common. 16 17 Every model has a *scale* and a *background*. 18 19 Talk about orientation, with diagrams for orientation so that we don't need 20 a link on every model page? 21 22 .. _orientation: 23 24 .. figure: img/orientation1.jpg 25 26 Orientation in 3D 27 28 .. figure: img/orientation2.jpg 29 30 Orientation cross sections 31 32 Talk about polydispersity. 33 34 Talk about magnetism, converting the magnetism help file to inline text here, 35 with links so that models can point back to it. 36 37 Need to talk about structure factors even though we don't have any 38 implemented yet. -
doc/index.rst
r8ae8532 r5e1d6b0 1 sasmodels 2 ========= 3 Small angle X-ray and Neutron scattering (SAXS and SANS) examines the 4 scattering patterns produced by a beam travelling through the sample 5 and scattering at low angles. The scattering is computed as a function 6 of reciprocal space $q$, which arises from a combination of beam wavelength 7 and scattering angles. Each pixel on the detector corresponds to 8 a different scattering angle, and has a distinct $q_x$ and $q_y$. If the 9 sample is unoriented, the scattering pattern will appear as rings on the 10 detector. In this case, a circular average can be taken with 1-dimension 11 data at $q = \surd (q_x^2 + q_y^2)$ compared to the orientationally 12 averaged SAS scattering pattern. 13 1 Introduction 2 ============ 14 3 The sasmodels package provides theory functions for small angle scattering 15 calculations for different shapes, including the effects of resolution, 16 polydispersity and orientational dispersion. 4 calculations. 17 5 18 6 .. htmlonly:: … … 27 15 28 16 guide/index.rst 29 guide/models/index.rst30 17 developer/index.rst 18 ref/index.rst 19 ref/models/index.rst 31 20 api/index.rst 32 21 … … 39 28 .. htmlonly:: 40 29 * :ref:`search` 30 31 32 33 34 35 -
example/model.py
r2e66ef5 r1182da5 17 17 model = Model(kernel, 18 18 scale=0.08, 19 r adius_polar=15, radius_equatorial=800,19 r_polar=15, r_equatorial=800, 20 20 sld=.291, sld_solvent=7.105, 21 21 background=0, 22 22 theta=90, phi=0, 23 23 theta_pd=15, theta_pd_n=40, theta_pd_nsigma=3, 24 r adius_polar_pd=0.222296, radius_polar_pd_n=1, radius_polar_pd_nsigma=0,25 r adius_equatorial_pd=.000128, radius_equatorial_pd_n=1, radius_equatorial_pd_nsigma=0,24 r_polar_pd=0.222296, r_polar_pd_n=1, r_polar_pd_nsigma=0, 25 r_equatorial_pd=.000128, r_equatorial_pd_n=1, r_equatorial_pd_nsigma=0, 26 26 phi_pd=0, phi_pd_n=20, phi_pd_nsigma=3, 27 27 ) 28 28 29 29 # SET THE FITTING PARAMETERS 30 model.r adius_polar.range(15, 1000)31 model.r adius_equatorial.range(15, 1000)30 model.r_polar.range(15, 1000) 31 model.r_equatorial.range(15, 1000) 32 32 model.theta_pd.range(0, 360) 33 33 model.background.range(0,1000) -
sasmodels/core.py
r2e66ef5 r650c6d2 117 117 Load model info and build model. 118 118 119 *model_name* is the name of the model, or perhaps a model expression 120 such as sphere*hardsphere or sphere+cylinder. 121 122 *dtype* and *platform* are given by :func:`build_model`. 119 *model_name* is the name of the model as used by :func:`load_model_info`. 120 Additional keyword arguments are passed directly to :func:`build_model`. 123 121 """ 124 122 return build_model(load_model_info(model_name), … … 130 128 """ 131 129 Load a model definition given the model name. 132 133 *model_name* is the name of the model, or perhaps a model expression134 such as sphere*hardsphere or sphere+cylinder.135 130 136 131 This returns a handle to the module defining the model. This can be … … 232 227 233 228 Possible types include 'half', 'single', 'double' and 'quad'. If the 234 type is 'fast', then this is equivalent to dtype 'single' but using 235 fast native functions rather than those with the precision level guaranteed 236 by the OpenCL standard. 237 238 Platform preference can be specfied ("ocl" vs "dll"), with the default 239 being OpenCL if it is availabe. If the dtype name ends with '!' then 240 platform is forced to be DLL rather than OpenCL. 241 242 This routine ignores the preferences within the model definition. This 243 is by design. It allows us to test models in single precision even when 244 we have flagged them as requiring double precision so we can easily check 245 the performance on different platforms without having to change the model 246 definition. 229 type is 'fast', then this is equivalent to dtype 'single' with the 230 fast flag set to True. 247 231 """ 248 232 # Assign default platform, overriding ocl with dll if OpenCL is unavailable -
sasmodels/resolution.py
r990d8df rb32caab 437 437 .. math:: 438 438 439 \log \Delta q = (\log q_n - \log q_1) / (n - 1)439 \log \Delta q = (\log q_n - log q_1) / (n - 1) 440 440 441 441 From this we can compute the number of steps required to extend $q$ … … 451 451 452 452 n_\text{extend} = (n-1) (\log q_\text{max} - \log q_n) 453 / (\log q_n - \log q_1)453 / (\log q_n - log q_1) 454 454 """ 455 455 q = np.sort(q) … … 459 459 log_delta_q = log(10.) / points_per_decade 460 460 if q_min < q[0]: 461 if q_min < 0: 462 q_min = q[0]*MINIMUM_ABSOLUTE_Q 461 if q_min < 0: q_min = q[0]*MINIMUM_ABSOLUTE_Q 463 462 n_low = log_delta_q * (log(q[0])-log(q_min)) 464 463 q_low = np.logspace(log10(q_min), log10(q[0]), np.ceil(n_low)+1)[:-1] -
sasmodels/rst2html.py
r990d8df rf2f5413 38 38 - mathml 39 39 - mathjax 40 See ` <http://docutils.sourceforge.net/docs/user/config.html#math-output>`_40 See `http://docutils.sourceforge.net/docs/user/config.html#math-output`_ 41 41 for details. 42 42 … … 211 211 sys.exit(app.exec_()) 212 212 213 def can_use_qt():214 """215 Return True if QWebView exists.216 217 Checks first in PyQt5 then in PyQt4218 """219 try:220 from PyQt5.QtWebKitWidgets import QWebView221 return True222 except ImportError:223 try:224 from PyQt4.QtWebkit import QWebView225 return True226 except ImportError:227 return False228 229 213 def view_help(filename, qt=False): 230 214 import os 231 232 if qt: 233 qt = can_use_qt() 234 235 url = "file:///"+os.path.abspath(filename).replace("\\", "/") 215 url="file:///"+os.path.abspath(filename).replace("\\","/") 236 216 if filename.endswith('.rst'): 237 217 html = load_rst_as_html(filename)
Note: See TracChangeset
for help on using the changeset viewer.