Changeset 190fc2b in sasmodels
- Timestamp:
- Jan 28, 2016 10:35:57 PM (9 years ago)
- Branches:
- master, core_shell_microgels, costrafo411, magnetic_model, release_v0.94, release_v0.95, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
- Children:
- 3a45c2c
- Parents:
- d4666ca
- Location:
- sasmodels
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
sasmodels/bumps_model.py
r37a7252 r190fc2b 12 12 """ 13 13 14 import warnings 15 16 import numpy as np 17 18 from .data import plot_theory 19 from .direct_model import DataMixin 20 14 21 __all__ = [ 15 22 "Model", "Experiment", 16 23 ] 17 18 import warnings19 20 import numpy as np21 22 from .data import plot_theory23 from .direct_model import DataMixin24 24 25 25 # CRUFT: old style bumps wrapper which doesn't separate data and model -
sasmodels/compare.py
r841753c r190fc2b 28 28 29 29 from __future__ import print_function 30 31 import sys 32 import math 33 from os.path import basename, dirname, join as joinpath 34 import glob 35 import datetime 36 import traceback 37 38 import numpy as np 39 40 from . import core 41 from . import kerneldll 42 from . import generate 43 from .data import plot_theory, empty_data1D, empty_data2D 44 from .direct_model import DirectModel 45 from .convert import revert_model, constrain_new_to_old 30 46 31 47 USAGE = """ … … 80 96 + USAGE) 81 97 82 83 84 import sys 85 import math 86 from os.path import basename, dirname, join as joinpath 87 import glob 88 import datetime 89 import traceback 90 91 import numpy as np 92 98 kerneldll.ALLOW_SINGLE_PRECISION_DLLS = True 99 100 # List of available models 93 101 ROOT = dirname(__file__) 94 sys.path.insert(0, ROOT) # Make sure sasmodels is first on the path95 96 97 from . import core98 from . import kerneldll99 from . import generate100 from .data import plot_theory, empty_data1D, empty_data2D101 from .direct_model import DirectModel102 from .convert import revert_model, constrain_new_to_old103 kerneldll.ALLOW_SINGLE_PRECISION_DLLS = True104 105 # List of available models106 102 MODELS = [basename(f)[:-3] 107 103 for f in sorted(glob.glob(joinpath(ROOT, "models", "[a-zA-Z]*.py")))] -
sasmodels/core.py
rd15a908 r190fc2b 2 2 Core model handling routines. 3 3 """ 4 __all__ = [5 "list_models", "load_model_definition", "precompile_dll",6 "load_model", "make_kernel", "call_kernel", "call_ER", "call_VR",7 ]8 4 9 5 from os.path import basename, dirname, join as joinpath … … 24 20 HAVE_OPENCL = False 25 21 22 __all__ = [ 23 "list_models", "load_model_definition", "precompile_dll", 24 "load_model", "make_kernel", "call_kernel", "call_ER", "call_VR", 25 ] 26 26 27 27 def list_models(): -
sasmodels/generate.py
re66c9f9 r190fc2b 197 197 # TODO: identify model files which have changed since loading and reload them. 198 198 199 __all__ = ["make", "doc", "sources", "convert_type"]200 201 199 import sys 202 200 from os.path import abspath, dirname, join as joinpath, exists, basename, \ … … 206 204 207 205 import numpy as np 206 207 __all__ = ["make", "doc", "sources", "convert_type"] 208 208 209 C_KERNEL_TEMPLATE_PATH = joinpath(dirname(__file__), 'kernel_template.c') 209 210 … … 216 217 F128 = None 217 218 218 219 219 # Scale and background, which are parameters common to every form factor 220 220 COMMON_PARAMETERS = [ … … 222 222 ["background", "1/cm", 0, [0, np.inf], "", "Source background"], 223 223 ] 224 225 224 226 225 # Conversion from units defined in the parameter table for each model … … 266 265 267 266 def format_units(units): 267 """ 268 Convert units into ReStructured Text format. 269 """ 268 270 return "string" if isinstance(units, list) else RST_UNITS.get(units, units) 269 271 … … 335 337 """ 336 338 Convert code from double precision to the desired type. 339 340 Floating point constants are tagged with 'f' for single precision or 'L' 341 for long double precision. 337 342 """ 338 343 if dtype == F16: … … 350 355 351 356 def _convert_type(source, type_name, constant_flag): 357 """ 358 Replace 'double' with *type_name* in *source*, tagging floating point 359 constants with *constant_flag*. 360 """ 352 361 # Convert double keyword to float/long double/half. 353 362 # Accept an 'n' # parameter for vector # values, where n is 2, 4, 8 or 16. … … 625 634 %re.escape(string.punctuation)) 626 635 def _convert_section_titles_to_boldface(lines): 636 """ 637 Do the actual work of identifying and converting section headings. 638 """ 627 639 prior = None 628 640 for line in lines: … … 642 654 yield prior 643 655 644 def convert_section_titles_to_boldface(string): 645 return "\n".join(_convert_section_titles_to_boldface(string.split('\n'))) 656 def convert_section_titles_to_boldface(s): 657 """ 658 Use explicit bold-face rather than section headings so that the table of 659 contents is not polluted with section names from the model documentation. 660 661 Sections are identified as the title line followed by a line of punctuation 662 at least as long as the title line. 663 """ 664 return "\n".join(_convert_section_titles_to_boldface(s.split('\n'))) 646 665 647 666 def doc(kernel_module): … … 666 685 667 686 def demo_time(): 687 """ 688 Show how long it takes to process a model. 689 """ 668 690 from .models import cylinder 669 691 import datetime … … 674 696 675 697 def main(): 698 """ 699 Program which prints the source produced by the model. 700 """ 676 701 if len(sys.argv) <= 1: 677 702 print("usage: python -m sasmodels.generate modelname") -
sasmodels/resolution.py
rfdc538a r190fc2b 5 5 """ 6 6 from __future__ import division 7 8 from scipy.special import erf 9 from numpy import sqrt, log, log10 10 import numpy as np 7 11 8 12 __all__ = ["Resolution", "Perfect1D", "Pinhole1D", "Slit1D", … … 11 15 "interpolate", "linear_extrapolation", "geometric_extrapolation", 12 16 ] 13 14 from scipy.special import erf15 from numpy import sqrt, log, log1016 import numpy as np17 17 18 18 MINIMUM_RESOLUTION = 1e-8 -
sasmodels/sesans.py
r384d114 r190fc2b 43 43 *I* [cm$^{-1}$] is the value of the SANS model at *q* 44 44 """ 45 G = np.zeros (len(SElength), 'd')46 for i in range(len(SElength)):47 integr = besselj(0, q*SElength[i])*Iq*q48 G[i] = np.sum(integr )45 G = np.zeros_like(SElength, 'd') 46 for i, SElength_i in enumerate(SElength): 47 integral = besselj(0, q*SElength_i)*Iq*q 48 G[i] = np.sum(integral) 49 49 50 50 # [m^-1] step size in q, needed for integration 51 dq =(q[1]-q[0])*1e1051 dq = (q[1]-q[0])*1e10 52 52 53 53 # integration step, convert q into [m**-1] and 2 pi circle integration
Note: See TracChangeset
for help on using the changeset viewer.