Changeset 2d81cfe in sasmodels


Ignore:
Timestamp:
Nov 29, 2017 1:13:23 PM (5 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, core_shell_microgels, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
237b800f
Parents:
a839b22
Message:

lint

Files:
100 edited

Legend:

Unmodified
Added
Removed
  • extra/pylint.rc

    r823e620 r2d81cfe  
    2121# List of plugins (as comma separated values of python modules names) to load, 
    2222# usually to register additional checkers. 
    23 load-plugins=pylint_numpy,pylint_pyopencl 
     23load-plugins=pylint_numpy,pylint_pyopencl,pylint_sas 
    2424 
    2525# Use multiple processes to speed up Pylint. 
  • sasmodels/bumps_model.py

    r74b0495 r2d81cfe  
    2020from .direct_model import DataMixin 
    2121 
     22# pylint: disable=unused-import 
    2223try: 
    2324    from typing import Dict, Union, Tuple, Any 
     
    2829except ImportError: 
    2930    pass 
     31# pylint: enable=unused-import 
    3032 
    3133try: 
     
    3739 
    3840 
    39 def create_parameters(model_info, **kwargs): 
    40     # type: (ModelInfo, **Union[float, str, Parameter]) -> Tuple[Dict[str, Parameter], Dict[str, str]] 
     41def create_parameters(model_info,  # type: ModelInfo 
     42                      **kwargs     # type: Union[float, str, Parameter] 
     43                     ): 
     44    # type: (...) -> Tuple[Dict[str, Parameter], Dict[str, str]] 
    4145    """ 
    4246    Generate Bumps parameters from the model info. 
     
    238242        # pylint: disable=attribute-defined-outside-init 
    239243        self.__dict__ = state 
    240  
  • sasmodels/compare.py

    r32398dc r2d81cfe  
    4040from . import core 
    4141from . import kerneldll 
    42 from . import exception 
    4342from .data import plot_theory, empty_data1D, empty_data2D, load_data 
    4443from .direct_model import DirectModel, get_mesh 
    45 from .convert import revert_name, revert_pars 
    4644from .generate import FLOAT_RE 
    4745from .weights import plot_weights 
  • sasmodels/compare_many.py

    r32398dc r2d81cfe  
    264264        return 
    265265 
    266     data, index = make_data({'qmax':1.0, 'is2d':is2D, 'nq':Nq, 'res':0., 
    267                              'accuracy': 'Low', 'view':'log', 'zero': False}) 
     266    data, index = make_data({ 
     267        'qmin': 0.001, 'qmax': 1.0, 'is2d': is2D, 'nq': Nq, 'res': 0., 
     268        'accuracy': 'Low', 'view':'log', 'zero': False 
     269        }) 
    268270    for model in model_list: 
    269271        compare_instance(model, data, index, N=count, mono=mono, 
  • sasmodels/convert.py

    r32398dc r2d81cfe  
    275275        p_scale = oldpars['scale'] 
    276276        p_c1 = oldpars['c1'] 
    277         p_c2= oldpars['c2'] 
     277        p_c2 = oldpars['c2'] 
    278278        i_1 = 0.5*p_c1/p_c2 
    279279        i_2 = math.sqrt(math.fabs(p_scale/p_c2)) 
  • sasmodels/core.py

    re65c3ba r2d81cfe  
    3939        os.makedirs(CUSTOM_MODEL_PATH) 
    4040 
     41# pylint: disable=unused-import 
    4142try: 
    4243    from typing import List, Union, Optional, Any 
     
    4546except ImportError: 
    4647    pass 
     48# pylint: enable=unused-import 
    4749 
    4850# TODO: refactor composite model support 
  • sasmodels/data.py

    ra839b22 r2d81cfe  
    633633        _plot_2d_signal(data, target, view=view, vmin=vmin, vmax=vmax) 
    634634        plt.title('data') 
    635         handle = plt.colorbar() 
    636         handle.set_label('$I(q)$') 
     635        h = plt.colorbar() 
     636        h.set_label('$I(q)$') 
    637637 
    638638    # plot theory 
     
    642642        _plot_2d_signal(data, theory, view=view, vmin=vmin, vmax=vmax) 
    643643        plt.title('theory') 
    644         handle = plt.colorbar() 
    645         handle.set_label(r'$\log_{10}I(q)$' if view == 'log' 
    646                          else r'$q^4 I(q)$' if view == 'q4' 
    647                          else '$I(q)$') 
     644        h = plt.colorbar() 
     645        h.set_label(r'$\log_{10}I(q)$' if view == 'log' 
     646                    else r'$q^4 I(q)$' if view == 'q4' 
     647                    else '$I(q)$') 
    648648 
    649649    # plot resid 
     
    653653        _plot_2d_signal(data, resid, view='linear') 
    654654        plt.title('residuals') 
    655         handle = plt.colorbar() 
    656         handle.set_label(r'$\Delta I(q)$') 
     655        h = plt.colorbar() 
     656        h.set_label(r'$\Delta I(q)$') 
    657657 
    658658 
  • sasmodels/details.py

    r110f69c r2d81cfe  
    1515 
    1616import numpy as np  # type: ignore 
    17 from numpy import pi, cos, sin, radians 
     17from numpy import cos, sin, radians 
    1818 
    1919try: 
     
    2929            return [np.asarray(v) for v in args] 
    3030 
     31# pylint: disable=unused-import 
    3132try: 
    3233    from typing import List, Tuple, Sequence 
     
    3637    from .modelinfo import ModelInfo 
    3738    from .modelinfo import ParameterTable 
     39# pylint: enable=unused-import 
    3840 
    3941 
     
    220222 
    221223ZEROS = tuple([0.]*31) 
    222 def make_kernel_args(kernel, mesh): 
    223     # type: (Kernel, Tuple[List[np.ndarray], List[np.ndarray]]) -> Tuple[CallDetails, np.ndarray, bool] 
     224def make_kernel_args(kernel, # type: Kernel 
     225                     mesh    # type: Tuple[List[np.ndarray], List[np.ndarray]] 
     226                    ): 
     227    # type: (...) -> Tuple[CallDetails, np.ndarray, bool] 
    224228    """ 
    225229    Converts (value, dispersity, weight) for each parameter into kernel pars. 
     
    248252    return call_details, data, is_magnetic 
    249253 
    250 def correct_theta_weights(parameters, dispersity, weights): 
    251     # type: (ParameterTable, Sequence[np.ndarray], Sequence[np.ndarray]) -> Sequence[np.ndarray] 
     254def correct_theta_weights(parameters, # type: ParameterTable 
     255                          dispersity, # type: Sequence[np.ndarray] 
     256                          weights     # type: Sequence[np.ndarray] 
     257                         ): 
     258    # type: (...) -> Sequence[np.ndarray] 
    252259    """ 
    253260    If there is a theta parameter, update the weights of that parameter so that 
  • sasmodels/direct_model.py

    rfa79f5c r2d81cfe  
    3232from .details import make_kernel_args, dispersion_mesh 
    3333 
     34# pylint: disable=unused-import 
    3435try: 
    3536    from typing import Optional, Dict, Tuple 
     
    4041    from .kernel import Kernel, KernelModel 
    4142    from .modelinfo import Parameter, ParameterSet 
     43# pylint: enable=unused-import 
    4244 
    4345def call_kernel(calculator, pars, cutoff=0., mono=False): 
     
    163165        nsigma = values.get(parameter.name+'_pd_nsigma', 3.0) 
    164166        pd = weights.get_weights(disperser, npts, width, nsigma, 
    165                                 value, limits, relative) 
     167                                 value, limits, relative) 
    166168    return value, pd[0], pd[1] 
    167169 
     
    411413        try: 
    412414            values = [float(v) for v in call.split(',')] 
    413         except Exception: 
     415        except ValueError: 
    414416            values = [] 
    415417        if len(values) == 1: 
  • sasmodels/generate.py

    re65c3ba r2d81cfe  
    174174from .custom import load_custom_kernel_module 
    175175 
     176# pylint: disable=unused-import 
    176177try: 
    177178    from typing import Tuple, Sequence, Iterator, Dict 
     
    179180except ImportError: 
    180181    pass 
     182# pylint: enable=unused-import 
    181183 
    182184# jitter projection to use in the kernel code.  See explore/jitter.py 
  • sasmodels/kernel.py

    rbde38b5 r2d81cfe  
    1212from __future__ import division, print_function 
    1313 
    14 import numpy as np 
    15  
     14# pylint: disable=unused-import 
    1615try: 
    1716    from typing import List 
     
    1918    pass 
    2019else: 
     20    import numpy as np 
    2121    from .details import CallDetails 
    2222    from .modelinfo import ModelInfo 
    23     import numpy as np  # type: ignore 
     23# pylint: enable=unused-import 
    2424 
    2525class KernelModel(object): 
  • sasmodels/kernelcl.py

    rc1114bf r2d81cfe  
    7474from .kernel import KernelModel, Kernel 
    7575 
     76# pylint: disable=unused-import 
    7677try: 
    7778    from typing import Tuple, Callable, Any 
     
    8081except ImportError: 
    8182    pass 
     83# pylint: enable=unused-import 
    8284 
    8385# CRUFT: pyopencl < 2017.1  (as of June 2016 needs quotes around include path) 
  • sasmodels/kerneldll.py

    rb2f1d2f r2d81cfe  
    3939Install locations are system dependent, such as: 
    4040 
    41     C:\Program Files (x86)\Common Files\Microsoft\Visual C++ for Python\9.0\vcvarsall.bat 
     41    C:\Program Files (x86)\Common Files\Microsoft\Visual 
     42    C++ for Python\9.0\vcvarsall.bat 
    4243 
    4344or maybe 
    4445 
    45     C:\Users\yourname\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\vcvarsall.bat 
     46    C:\Users\yourname\AppData\Local\Programs\Common\Microsoft\Visual 
     47    C++ for Python\9.0\vcvarsall.bat 
    4648 
    4749OpenMP for *msvc* requires the Microsoft vcomp90.dll library, which doesn't 
     
    8991from .generate import F16, F32, F64 
    9092 
     93# pylint: disable=unused-import 
    9194try: 
    9295    from typing import Tuple, Callable, Any 
     
    9598except ImportError: 
    9699    pass 
     100# pylint: enable=unused-import 
    97101 
    98102if "SAS_COMPILER" in os.environ: 
  • sasmodels/kernelpy.py

    r8698a0d r2d81cfe  
    1212 
    1313import numpy as np  # type: ignore 
    14 from numpy import pi, sin, cos  #type: ignore 
    15  
    16 from . import details 
     14 
    1715from .generate import F64 
    1816from .kernel import KernelModel, Kernel 
    1917 
     18# pylint: disable=unused-import 
    2019try: 
    2120    from typing import Union, Callable 
     
    2322    pass 
    2423else: 
     24    from . import details 
    2525    DType = Union[None, str, np.dtype] 
     26# pylint: enable=unused-import 
    2627 
    2728class PyModel(KernelModel): 
     
    179180        self.q_input = None 
    180181 
    181 def _loops(parameters, form, form_volume, nq, call_details, values, cutoff): 
    182     # type: (np.ndarray, Callable[[], np.ndarray], Callable[[], float], int, details.CallDetails, np.ndarray, np.ndarray, float) -> None 
     182def _loops(parameters,    # type: np.ndarray 
     183           form,          # type: Callable[[], np.ndarray] 
     184           form_volume,   # type: Callable[[], float] 
     185           nq,            # type: int 
     186           call_details,  # type: details.CallDetails 
     187           values,        # type: np.ndarray 
     188           cutoff         # type: float 
     189          ): 
     190    # type: (...) -> None 
    183191    ################################################################ 
    184192    #                                                              # 
  • sasmodels/list_pars.py

    r72be531 r2d81cfe  
    1111from __future__ import print_function 
    1212 
    13 import sys 
    1413import argparse 
    1514 
  • sasmodels/mixture.py

    r0edb6c1 r2d81cfe  
    2020from .details import make_details 
    2121 
     22# pylint: disable=unused-import 
    2223try: 
    2324    from typing import List 
    2425except ImportError: 
    2526    pass 
     27# pylint: enable=unused-import 
    2628 
    2729def make_mixture_info(parts, operation='+'): 
     
    3335    combined_pars = [] 
    3436 
    35     model_num = 0 
    3637    all_parts = copy(parts) 
    3738    is_flat = False 
     
    8990            used_prefixes.append(prefix) 
    9091            prefix += '_' 
    91              
     92 
    9293        if operation == '+': 
    9394            # If model is a sum model, each constituent model gets its own scale parameter 
     
    105106                # Concatenate sub_prefixes to form prefix for the scale 
    106107                scale_prefix = ''.join(sub_prefixes) + '_' 
    107             scale =  Parameter(scale_prefix + 'scale', default=1.0, 
    108                             description="model intensity for " + part.name) 
     108            scale = Parameter(scale_prefix + 'scale', default=1.0, 
     109                              description="model intensity for " + part.name) 
    109110            combined_pars.append(scale) 
    110111        for p in part.parameters.kernel_parameters: 
     
    179180        # type: (ModelInfo, List[Kernel]) -> None 
    180181        self.dim = kernels[0].dim 
    181         self.info =  model_info 
     182        self.info = model_info 
    182183        self.kernels = kernels 
    183184        self.dtype = self.kernels[0].dtype 
  • sasmodels/model_test.py

    r20fe0cd r2d81cfe  
    6363from .modelinfo import expand_pars 
    6464 
     65# pylint: disable=unused-import 
    6566try: 
    6667    from typing import List, Iterator, Callable 
     
    7071    from .modelinfo import ParameterTable, ParameterSet, TestCondition, ModelInfo 
    7172    from .kernel import KernelModel 
     73# pylint: enable=unused-import 
    7274 
    7375 
     
    211213                if self.stash: 
    212214                    for test, target, actual in zip(tests, self.stash[0], results): 
    213                         assert np.all(abs(target-actual) < 5e-5*abs(actual)),\ 
    214                             "GPU/CPU comparison expected %s but got %s for %s"%(target, actual, test[0]) 
     215                        assert np.all(abs(target-actual) < 5e-5*abs(actual)), \ 
     216                            ("GPU/CPU comparison expected %s but got %s for %s" 
     217                             % (target, actual, test[0])) 
    215218                else: 
    216219                    self.stash.append(results) 
  • sasmodels/modelinfo.py

    re65c3ba r2d81cfe  
    1616 
    1717# Optional typing 
     18# pylint: disable=unused-import 
    1819try: 
    1920    from typing import Tuple, List, Union, Dict, Optional, Any, Callable, Sequence, Set 
     
    3031    TestValue = Union[float, List[float]] 
    3132    TestCondition = Tuple[ParameterSetUser, TestInput, TestValue] 
     33# pylint: enable=unused-import 
    3234 
    3335# If MAX_PD changes, need to change the loop macros in kernel_iq.c 
  • sasmodels/models/__init__.py

    r306e354 r2d81cfe  
    221D Modeling for SAS 
    33""" 
    4  
  • sasmodels/models/_spherepy.py

    rec45c4f r2d81cfe  
    11r""" 
    2 For information about polarised and magnetic scattering, see  
     2For information about polarised and magnetic scattering, see 
    33the :doc:`magnetic help <../sasgui/perspectives/fitting/mag_help>` documentation. 
    44 
     
    104104    dlow = d[low] 
    105105    dlow2 = dlow ** 2 
    106     g[low] = sqrt(1 - dlow2 / 4.) * (1 + dlow2 / 8.) + dlow2 / 2.*(1 - dlow2 / 16.) * log(dlow / (2. + sqrt(4. - dlow2))) 
     106    g[low] = (sqrt(1 - dlow2/4.) * (1 + dlow2/8.) 
     107              + dlow2/2.*(1 - dlow2/16.) * log(dlow / (2. + sqrt(4. - dlow2)))) 
    107108    return g 
    108109sesans.vectorized = True  # sesans accepts an array of z values 
  • sasmodels/models/adsorbed_layer.py

    r8f04da4 r2d81cfe  
    5757""" 
    5858 
     59import numpy as np 
    5960from numpy import inf, pi, exp, errstate 
    6061 
     
    100101    # the remaining parameters can be randomly generated from zero to 
    101102    # twice the default value as done by default in compare.py 
    102     import numpy as np 
    103103    pars = dict( 
    104104        scale=1, 
  • sasmodels/models/barbell.py

    r31df0c9 r2d81cfe  
    8787* **Last Reviewed by:** Richard Heenan **Date:** January 4, 2017 
    8888""" 
     89 
     90import numpy as np 
    8991from numpy import inf, sin, cos, pi 
    9092 
     
    116118 
    117119def random(): 
    118     import numpy as np 
    119120    # TODO: increase volume range once problem with bell radius is fixed 
    120121    # The issue is that bell radii of more than about 200 fail at high q 
    121     V = 10**np.random.uniform(7, 9) 
    122     bar_volume = 10**np.random.uniform(-4, -1)*V 
    123     bell_volume = V - bar_volume 
     122    volume = 10**np.random.uniform(7, 9) 
     123    bar_volume = 10**np.random.uniform(-4, -1)*volume 
     124    bell_volume = volume - bar_volume 
    124125    bell_radius = (bell_volume/6)**0.3333  # approximate 
    125126    min_bar = bar_volume/np.pi/bell_radius**2 
     
    150151qx = q*cos(pi/6.0) 
    151152qy = q*sin(pi/6.0) 
    152 tests = [[{}, 0.075, 25.5691260532], 
    153         [{'theta':80., 'phi':10.}, (qx, qy), 3.04233067789], 
    154         ] 
     153tests = [ 
     154    [{}, 0.075, 25.5691260532], 
     155    [{'theta':80., 'phi':10.}, (qx, qy), 3.04233067789], 
     156] 
    155157del qx, qy  # not necessary to delete, but cleaner 
  • sasmodels/models/bcc_paracrystal.py

    r1f159bd r2d81cfe  
    104104""" 
    105105 
     106import numpy as np 
    106107from numpy import inf, pi 
    107108 
     
    136137 
    137138def random(): 
    138     import numpy as np 
    139139    # Define lattice spacing as a multiple of the particle radius 
    140140    # using the formulat a = 4 r/sqrt(3).  Systems which are ordered 
  • sasmodels/models/be_polyelectrolyte.py

    r8f04da4 r2d81cfe  
    7171""" 
    7272 
     73import numpy as np 
    7374from numpy import inf, pi, sqrt 
    7475 
     
    140141 
    141142def random(): 
    142     import numpy as np 
    143143    # TODO: review random be_polyelectrolyte model generation 
    144144    pars = dict( 
  • sasmodels/models/binary_hard_sphere.py

    r30b60d2 r2d81cfe  
    7373""" 
    7474 
     75import numpy as np 
    7576from numpy import inf 
    7677 
     
    111112 
    112113def random(): 
    113     import numpy as np 
    114114    # TODO: binary_hard_sphere fails at low qr 
    115115    radius_lg = 10**np.random.uniform(2, 4.7) 
     
    137137# NOTE: test results taken from values returned by SasView 3.1.2 
    138138tests = [[{}, 0.001, 25.8927262013]] 
    139  
  • sasmodels/models/broad_peak.py

    r0bdddc2 r2d81cfe  
    4141""" 
    4242 
     43import numpy as np 
    4344from numpy import inf, errstate 
    4445 
     
    9596 
    9697def random(): 
    97     import numpy as np 
    9898    pars = dict( 
    9999        scale=1, 
  • sasmodels/models/capped_cylinder.py

    r31df0c9 r2d81cfe  
    8989* **Last Modified by:** Paul Butler **Date:** September 30, 2016 
    9090* **Last Reviewed by:** Richard Heenan **Date:** January 4, 2017 
     91""" 
    9192 
    92 """ 
     93import numpy as np 
    9394from numpy import inf, sin, cos, pi 
    9495 
     
    137138 
    138139def random(): 
    139     import numpy as np 
    140140    # TODO: increase volume range once problem with bell radius is fixed 
    141141    # The issue is that bell radii of more than about 200 fail at high q 
    142     V = 10**np.random.uniform(7, 9) 
    143     bar_volume = 10**np.random.uniform(-4, -1)*V 
    144     bell_volume = V - bar_volume 
     142    volume = 10**np.random.uniform(7, 9) 
     143    bar_volume = 10**np.random.uniform(-4, -1)*volume 
     144    bell_volume = volume - bar_volume 
    145145    bell_radius = (bell_volume/6)**0.3333  # approximate 
    146146    min_bar = bar_volume/np.pi/bell_radius**2 
     
    171171qx = q*cos(pi/6.0) 
    172172qy = q*sin(pi/6.0) 
    173 tests = [[{}, 0.075, 26.0698570695], 
    174         [{'theta':80., 'phi':10.}, (qx, qy), 0.561811990502], 
    175         ] 
     173tests = [ 
     174    [{}, 0.075, 26.0698570695], 
     175    [{'theta':80., 'phi':10.}, (qx, qy), 0.561811990502], 
     176] 
    176177del qx, qy  # not necessary to delete, but cleaner 
  • sasmodels/models/core_multi_shell.py

    r1511c37c r2d81cfe  
    4646* **Last Reviewed by:** Paul Kienzle **Date:** September 12, 2016 
    4747""" 
    48  
    49  
    50  
    5148from __future__ import division 
    5249 
     
    104101 
    105102def random(): 
    106     import numpy as np 
    107103    num_shells = np.minimum(np.random.poisson(3)+1, 10) 
    108104    total_radius = 10**np.random.uniform(1.7, 4) 
     
    162158            thickness1_pd_n=10, 
    163159            thickness2_pd_n=10, 
    164             ) 
     160           ) 
  • sasmodels/models/core_shell_bicelle.py

    r30b60d2 r2d81cfe  
    5050    \begin{align*} 
    5151    F(Q,\alpha) = &\bigg[ 
    52     (\rho_c - \rho_f) V_c \frac{2J_1(QRsin \alpha)}{QRsin\alpha}\frac{sin(QLcos\alpha/2)}{Q(L/2)cos\alpha} \\ 
    53     &+(\rho_f - \rho_r) V_{c+f} \frac{2J_1(QRsin\alpha)}{QRsin\alpha}\frac{sin(Q(L/2+t_f)cos\alpha)}{Q(L/2+t_f)cos\alpha} \\ 
    54     &+(\rho_r - \rho_s) V_t \frac{2J_1(Q(R+t_r)sin\alpha)}{Q(R+t_r)sin\alpha}\frac{sin(Q(L/2+t_f)cos\alpha)}{Q(L/2+t_f)cos\alpha} 
     52    (\rho_c - \rho_f) V_c 
     53     \frac{2J_1(QRsin \alpha)}{QRsin\alpha} 
     54     \frac{sin(QLcos\alpha/2)}{Q(L/2)cos\alpha} \\ 
     55    &+(\rho_f - \rho_r) V_{c+f} 
     56     \frac{2J_1(QRsin\alpha)}{QRsin\alpha} 
     57     \frac{sin(Q(L/2+t_f)cos\alpha)}{Q(L/2+t_f)cos\alpha} \\ 
     58    &+(\rho_r - \rho_s) V_t 
     59     \frac{2J_1(Q(R+t_r)sin\alpha)}{Q(R+t_r)sin\alpha} 
     60     \frac{sin(Q(L/2+t_f)cos\alpha)}{Q(L/2+t_f)cos\alpha} 
    5561    \bigg] 
    5662    \end{align*} 
     
    6470cylinders is then given by integrating over all possible $\theta$ and $\phi$. 
    6571 
    66 For oriented bicelles the *theta*, and *phi* orientation parameters will appear when fitting 2D data, 
    67 see the :ref:`cylinder` model for further information. 
     72For oriented bicelles the *theta*, and *phi* orientation parameters will appear 
     73when fitting 2D data, see the :ref:`cylinder` model for further information. 
    6874Our implementation of the scattering kernel and the 1D scattering intensity 
    6975use the c-library from NIST. 
     
    9298""" 
    9399 
     100import numpy as np 
    94101from numpy import inf, sin, cos, pi 
    95102 
     
    149156 
    150157def random(): 
    151     import numpy as np 
    152158    pars = dict( 
    153159        radius=10**np.random.uniform(1.3, 3), 
     
    173179qx = q*cos(pi/6.0) 
    174180qy = q*sin(pi/6.0) 
    175 tests = [[{}, 0.05, 7.4883545957], 
    176         [{'theta':80., 'phi':10.}, (qx, qy), 2.81048892474 ] 
    177         ] 
     181tests = [ 
     182    [{}, 0.05, 7.4883545957], 
     183    [{'theta':80., 'phi':10.}, (qx, qy), 2.81048892474] 
     184] 
    178185del qx, qy  # not necessary to delete, but cleaner 
    179  
  • sasmodels/models/core_shell_bicelle_elliptical.py

    r30b60d2 r2d81cfe  
    77of the core-shell bicelle model, but with an elliptical cylinder for the core. 
    88Outer shells on the rims and flat ends may be of different thicknesses and 
    9 scattering length densities. The form factor is normalized by the total particle volume. 
     9scattering length densities. The form factor is normalized by the total 
     10particle volume. 
    1011 
    1112 
     
    3637 
    3738The form factor for the bicelle is calculated in cylindrical coordinates, where 
    38 $\alpha$ is the angle between the $Q$ vector and the cylinder axis, and $\psi$ is the angle 
    39 for the ellipsoidal cross section core, to give: 
     39$\alpha$ is the angle between the $Q$ vector and the cylinder axis, and $\psi$ 
     40is the angle for the ellipsoidal cross section core, to give: 
    4041 
    4142.. math:: 
     
    4445        F(Q,\alpha, \psi)^2 \cdot sin(\alpha) + \text{background} 
    4546 
    46 where a numerical integration of $F(Q,\alpha, \psi)^2 \cdot sin(\alpha)$ is carried out over \alpha and \psi for: 
     47where a numerical integration of $F(Q,\alpha, \psi)^2 \cdot sin(\alpha)$ 
     48is carried out over \alpha and \psi for: 
    4749 
    4850.. math:: 
     
    5153    \begin{align*} 
    5254    F(Q,\alpha,\psi) = &\bigg[ 
    53     (\rho_c - \rho_f) V_c \frac{2J_1(QR'sin \alpha)}{QR'sin\alpha}\frac{sin(QLcos\alpha/2)}{Q(L/2)cos\alpha} \\ 
    54     &+(\rho_f - \rho_r) V_{c+f} \frac{2J_1(QR'sin\alpha)}{QR'sin\alpha}\frac{sin(Q(L/2+t_f)cos\alpha)}{Q(L/2+t_f)cos\alpha} \\ 
    55     &+(\rho_r - \rho_s) V_t \frac{2J_1(Q(R'+t_r)sin\alpha)}{Q(R'+t_r)sin\alpha}\frac{sin(Q(L/2+t_f)cos\alpha)}{Q(L/2+t_f)cos\alpha} 
     55    (\rho_c - \rho_f) V_c 
     56     \frac{2J_1(QR'sin \alpha)}{QR'sin\alpha} 
     57     \frac{sin(QLcos\alpha/2)}{Q(L/2)cos\alpha} \\ 
     58    &+(\rho_f - \rho_r) V_{c+f} 
     59     \frac{2J_1(QR'sin\alpha)}{QR'sin\alpha} 
     60     \frac{sin(Q(L/2+t_f)cos\alpha)}{Q(L/2+t_f)cos\alpha} \\ 
     61    &+(\rho_r - \rho_s) V_t 
     62     \frac{2J_1(Q(R'+t_r)sin\alpha)}{Q(R'+t_r)sin\alpha} 
     63     \frac{sin(Q(L/2+t_f)cos\alpha)}{Q(L/2+t_f)cos\alpha} 
    5664    \bigg] 
    5765    \end{align*} 
     
    6472 
    6573 
    66 and $V_t = \pi.(R+t_r)(Xcore.R+t_r)^2.(L+2.t_f)$ is the total volume of the bicelle, 
    67 $V_c = \pi.Xcore.R^2.L$ the volume of the core, $V_{c+f} = \pi.Xcore.R^2.(L+2.t_f)$ 
    68 the volume of the core plus the volume of the faces, $R$ is the radius 
    69 of the core, $Xcore$ is the axial ratio of the core, $L$ the length of the core, 
    70 $t_f$ the thickness of the face, $t_r$ the thickness of the rim and $J_1$ the usual 
    71 first order bessel function. The core has radii $R$ and $Xcore.R$ so is circular, 
    72 as for the core_shell_bicelle model, for $Xcore$ =1. Note that you may need to 
    73 limit the range of $Xcore$, especially if using the Monte-Carlo algorithm, as 
    74 setting radius to $R/Xcore$ and axial ratio to $1/Xcore$ gives an equivalent solution! 
     74and $V_t = \pi.(R+t_r)(Xcore.R+t_r)^2.(L+2.t_f)$ is the total volume of 
     75the bicelle, $V_c = \pi.Xcore.R^2.L$ the volume of the core, 
     76$V_{c+f} = \pi.Xcore.R^2.(L+2.t_f)$ the volume of the core plus the volume 
     77of the faces, $R$ is the radius of the core, $Xcore$ is the axial ratio of 
     78the core, $L$ the length of the core, $t_f$ the thickness of the face, $t_r$ 
     79the thickness of the rim and $J_1$ the usual first order bessel function. 
     80The core has radii $R$ and $Xcore.R$ so is circular, as for the 
     81core_shell_bicelle model, for $Xcore$ =1. Note that you may need to 
     82limit the range of $Xcore$, especially if using the Monte-Carlo algorithm, 
     83as setting radius to $R/Xcore$ and axial ratio to $1/Xcore$ gives an 
     84equivalent solution! 
    7585 
    7686The output of the 1D scattering intensity function for randomly oriented 
    7787bicelles is then given by integrating over all possible $\alpha$ and $\psi$. 
    7888 
    79 For oriented bicelles the *theta*, *phi* and *psi* orientation parameters will appear when fitting 2D data, 
    80 see the :ref:`elliptical-cylinder` model for further information. 
     89For oriented bicelles the *theta*, *phi* and *psi* orientation parameters will 
     90appear when fitting 2D data, see the :ref:`elliptical-cylinder` model 
     91for further information. 
    8192 
    8293 
     
    100111""" 
    101112 
     113import numpy as np 
    102114from numpy import inf, sin, cos, pi 
    103115 
     
    138150 
    139151def random(): 
    140     import numpy as np 
    141152    outer_major = 10**np.random.uniform(1, 4.7) 
    142153    outer_minor = 10**np.random.uniform(1, 4.7) 
     
    170181 
    171182tests = [ 
    172     [{'radius': 30.0, 'x_core': 3.0, 'thick_rim':8.0, 'thick_face':14.0, 'length':50.0}, 'ER', 1], 
    173     [{'radius': 30.0, 'x_core': 3.0, 'thick_rim':8.0, 'thick_face':14.0, 'length':50.0}, 'VR', 1], 
     183    [{'radius': 30.0, 'x_core': 3.0, 
     184      'thick_rim': 8.0, 'thick_face': 14.0, 'length': 50.0}, 'ER', 1], 
     185    [{'radius': 30.0, 'x_core': 3.0, 
     186      'thick_rim': 8.0, 'thick_face': 14.0, 'length': 50.0}, 'VR', 1], 
    174187 
    175     [{'radius': 30.0, 'x_core': 3.0, 'thick_rim':8.0, 'thick_face':14.0, 'length':50.0, 
    176     'sld_core':4.0, 'sld_face':7.0, 'sld_rim':1.0, 'sld_solvent':6.0, 'background':0.0}, 
    177     0.015, 286.540286], 
    178 #    [{'theta':80., 'phi':10.}, (qx, qy), 7.88866563001 ], 
    179         ] 
     188    [{'radius': 30.0, 'x_core': 3.0, 
     189      'thick_rim': 8.0, 'thick_face': 14.0, 'length': 50.0, 
     190      'sld_core': 4.0, 'sld_face': 7.0, 'sld_rim': 1.0, 
     191      'sld_solvent': 6.0, 'background': 0.0}, 
     192     0.015, 286.540286], 
     193    #[{'theta':80., 'phi':10.}, (qx, qy), 7.88866563001], 
     194] 
    180195 
    181196del qx, qy  # not necessary to delete, but cleaner 
  • sasmodels/models/core_shell_cylinder.py

    r9f6823b r2d81cfe  
    7373""" 
    7474 
     75import numpy as np 
    7576from numpy import pi, inf, sin, cos 
    7677 
     
    119120              ["theta", "degrees", 60, [-360, 360], "orientation", 
    120121               "cylinder axis to beam angle"], 
    121               ["phi", "degrees",   60, [-360, 360], "orientation", 
     122              ["phi", "degrees", 60, [-360, 360], "orientation", 
    122123               "rotation about beam"], 
    123124             ] 
     
    143144 
    144145def random(): 
    145     import numpy as np 
    146146    outer_radius = 10**np.random.uniform(1, 4.7) 
    147147    # Use a distribution with a preference for thin shell or thin core 
     
    170170qx = q*cos(pi/6.0) 
    171171qy = q*sin(pi/6.0) 
    172 tests = [[{}, 0.075, 10.8552692237], 
    173         [{}, (qx, qy), 0.444618752741 ], 
    174         ] 
     172tests = [ 
     173    [{}, 0.075, 10.8552692237], 
     174    [{}, (qx, qy), 0.444618752741], 
     175] 
    175176del qx, qy  # not necessary to delete, but cleaner 
  • sasmodels/models/core_shell_ellipsoid.py

    r8db25bf r2d81cfe  
    2626ellipsoid is large (ie, if $X << 1$ or $X >> 1$ ), when the $S(q)$ 
    2727- which assumes spheres - will not in any case be valid.  Generating a 
    28 custom product model will enable separate effective volume fraction and effective 
    29 radius in the $S(q)$. 
     28custom product model will enable separate effective volume fraction and 
     29effective radius in the $S(q)$. 
    3030 
    3131If SAS data are in absolute units, and the SLDs are correct, then scale should 
    3232be the total volume fraction of the "outer particle". When $S(q)$ is introduced 
    33 this moves to the $S(q)$ volume fraction, and scale should then be 1.0, 
    34 or contain some other units conversion factor (for example, if you have SAXS data). 
    35  
    36 The calculation of intensity follows that for the solid ellipsoid, but with separate 
    37 terms for the core-shell and shell-solvent boundaries. 
     33this moves to the $S(q)$ volume fraction, and scale should then be 1.0, or 
     34contain some other units conversion factor (for example, if you have SAXS data). 
     35 
     36The calculation of intensity follows that for the solid ellipsoid, but 
     37with separate terms for the core-shell and shell-solvent boundaries. 
    3838 
    3939.. math:: 
     
    4848    \begin{align*} 
    4949    F(q,\alpha) = &f(q,radius\_equat\_core,radius\_equat\_core.x\_core,\alpha) \\ 
    50     &+ f(q,radius\_equat\_core + thick\_shell,radius\_equat\_core.x\_core + thick\_shell.x\_polar\_shell,\alpha) 
     50    &+ f(q,radius\_equat\_core + thick\_shell, 
     51         radius\_equat\_core.x\_core + thick\_shell.x\_polar\_shell,\alpha) 
    5152    \end{align*} 
    5253 
     
    6869 
    6970$\alpha$ is the angle between the axis of the ellipsoid and $\vec q$, 
    70 $V = (4/3)\pi R_pR_e^2$ is the volume of the ellipsoid , $R_p$ is the polar radius along the 
    71 rotational axis of the ellipsoid, $R_e$ is the equatorial radius perpendicular 
    72 to the rotational axis of the ellipsoid and $\Delta \rho$ (contrast) is the 
    73 scattering length density difference, either $(sld\_core - sld\_shell)$ or $(sld\_shell - sld\_solvent)$. 
     71$V = (4/3)\pi R_pR_e^2$ is the volume of the ellipsoid , $R_p$ is the 
     72polar radius along the rotational axis of the ellipsoid, $R_e$ is the 
     73equatorial radius perpendicular to the rotational axis of the ellipsoid 
     74and $\Delta \rho$ (contrast) is the scattering length density difference, 
     75either $(sld\_core - sld\_shell)$ or $(sld\_shell - sld\_solvent)$. 
    7476 
    7577For randomly oriented particles: 
     
    7981   F^2(q)=\int_{0}^{\pi/2}{F^2(q,\alpha)\sin(\alpha)d\alpha} 
    8082 
    81 For oriented ellipsoids the *theta*, *phi* and *psi* orientation parameters will appear when fitting 2D data, 
    82 see the :ref:`elliptical-cylinder` model for further information. 
     83For oriented ellipsoids the *theta*, *phi* and *psi* orientation parameters 
     84will appear when fitting 2D data, see the :ref:`elliptical-cylinder` model 
     85for further information. 
    8386 
    8487References 
     
    9497* **Last Modified by:** Richard Heenan (reparametrised model) **Date:** 2015 
    9598* **Last Reviewed by:** Richard Heenan **Date:** October 6, 2016 
    96  
    9799""" 
    98100 
     101import numpy as np 
    99102from numpy import inf, sin, cos, pi 
    100103 
     
    153156 
    154157def random(): 
    155     import numpy as np 
    156     V = 10**np.random.uniform(5, 12) 
     158    volume = 10**np.random.uniform(5, 12) 
    157159    outer_polar = 10**np.random.uniform(1.3, 4) 
    158     outer_equatorial = np.sqrt(V/outer_polar) # ignore 4/3 pi 
     160    outer_equatorial = np.sqrt(volume/outer_polar) # ignore 4/3 pi 
    159161    # Use a distribution with a preference for thin shell or thin core 
    160162    # Avoid core,shell radii < 1 
     
    180182# 11Jan2017 RKH sorted tests after redefinition of angles 
    181183tests = [ 
    182      # Accuracy tests based on content in test/utest_coreshellellipsoidXTmodel.py 
     184    # Accuracy tests based on content in test/utest_coreshellellipsoidXTmodel.py 
    183185    [{'radius_equat_core': 200.0, 
    184186      'x_core': 0.1, 
     
    206208     }, 0.01, 8688.53], 
    207209 
    208    # 2D tests 
    209    [{'background': 0.001, 
    210      'theta': 90.0, 
    211      'phi': 0.0, 
     210    # 2D tests 
     211    [{'background': 0.001, 
     212      'theta': 90.0, 
     213      'phi': 0.0, 
    212214     }, (0.4, 0.5), 0.00690673], 
    213215 
    214    [{'radius_equat_core': 20.0, 
     216    [{'radius_equat_core': 20.0, 
    215217      'x_core': 200.0, 
    216218      'thick_shell': 54.0, 
     
    224226      'phi': 0.0, 
    225227     }, (qx, qy), 0.01000025], 
    226     ] 
     228] 
  • sasmodels/models/core_shell_parallelepiped.py

    r8c7d5d5 r2d81cfe  
    55Calculates the form factor for a rectangular solid with a core-shell structure. 
    66The thickness and the scattering length density of the shell or 
    7 "rim" can be different on each (pair) of faces. However at this time 
    8 the 1D calculation does **NOT** actually calculate a c face rim despite the presence of 
    9 the parameter. Some other aspects of the 1D calculation may be wrong. 
     7"rim" can be different on each (pair) of faces. However at this time the 1D 
     8calculation does **NOT** actually calculate a c face rim despite the presence 
     9of the parameter. Some other aspects of the 1D calculation may be wrong. 
    1010 
    1111.. note:: 
     
    5151 
    5252    F_{a}(Q,\alpha,\beta)= 
    53     \left[\frac{\sin(\tfrac{1}{2}Q(L_A+2t_A)\sin\alpha \sin\beta)}{\tfrac{1}{2}Q(L_A+2t_A)\sin\alpha\sin\beta} 
    54     - \frac{\sin(\tfrac{1}{2}QL_A\sin\alpha \sin\beta)}{\tfrac{1}{2}QL_A\sin\alpha \sin\beta} \right] 
    55     \left[\frac{\sin(\tfrac{1}{2}QL_B\sin\alpha \sin\beta)}{\tfrac{1}{2}QL_B\sin\alpha \sin\beta} \right] 
    56     \left[\frac{\sin(\tfrac{1}{2}QL_C\sin\alpha \sin\beta)}{\tfrac{1}{2}QL_C\sin\alpha \sin\beta} \right] 
     53    \left[\frac{\sin(\tfrac{1}{2}Q(L_A+2t_A)\sin\alpha \sin\beta) 
     54               }{\tfrac{1}{2}Q(L_A+2t_A)\sin\alpha\sin\beta} 
     55    - \frac{\sin(\tfrac{1}{2}QL_A\sin\alpha \sin\beta) 
     56           }{\tfrac{1}{2}QL_A\sin\alpha \sin\beta} \right] 
     57    \left[\frac{\sin(\tfrac{1}{2}QL_B\sin\alpha \sin\beta) 
     58               }{\tfrac{1}{2}QL_B\sin\alpha \sin\beta} \right] 
     59    \left[\frac{\sin(\tfrac{1}{2}QL_C\sin\alpha \sin\beta) 
     60               }{\tfrac{1}{2}QL_C\sin\alpha \sin\beta} \right] 
    5761 
    5862.. note:: 
     
    9498 
    9599    Definition of the angles for oriented core-shell parallelepipeds. 
    96     Note that rotation $\theta$, initially in the $xz$ plane, is carried out first, then 
    97     rotation $\phi$ about the $z$ axis, finally rotation $\Psi$ is now around the axis of the cylinder. 
    98     The neutron or X-ray beam is along the $z$ axis. 
     100    Note that rotation $\theta$, initially in the $xz$ plane, is carried 
     101    out first, then rotation $\phi$ about the $z$ axis, finally rotation 
     102    $\Psi$ is now around the axis of the cylinder. The neutron or X-ray 
     103    beam is along the $z$ axis. 
    99104 
    100105.. figure:: img/parallelepiped_angle_projection.png 
     
    182187 
    183188def random(): 
    184     import numpy as np 
    185189    outer = 10**np.random.uniform(1, 4.7, size=3) 
    186190    thick = np.random.beta(0.5, 0.5, size=3)*(outer-2) + 1 
     
    216220    qx, qy = 0.2 * cos(pi/6.), 0.2 * sin(pi/6.) 
    217221    tests = [[{}, 0.2, 0.533149288477], 
    218             [{}, [0.2], [0.533149288477]], 
    219             [{'theta':10.0, 'phi':20.0}, (qx, qy), 0.0853299803222], 
    220             [{'theta':10.0, 'phi':20.0}, [(qx, qy)], [0.0853299803222]], 
     222             [{}, [0.2], [0.533149288477]], 
     223             [{'theta':10.0, 'phi':20.0}, (qx, qy), 0.0853299803222], 
     224             [{'theta':10.0, 'phi':20.0}, [(qx, qy)], [0.0853299803222]], 
    221225            ] 
    222226    del qx, qy  # not necessary to delete, but cleaner 
  • sasmodels/models/core_shell_sphere.py

    r9f6823b r2d81cfe  
    5252""" 
    5353 
     54import numpy as np 
    5455from numpy import pi, inf 
    5556 
     
    100101 
    101102def random(): 
    102     import numpy as np 
    103103    outer_radius = 10**np.random.uniform(1.3, 4.3) 
    104104    # Use a distribution with a preference for thin shell or thin core 
  • sasmodels/models/cylinder.py

    reda8b30 r2d81cfe  
    6464 
    6565    Angles $\theta$ and $\phi$ orient the cylinder relative 
    66     to the beam line coordinates, where the beam is along the $z$ axis. Rotation $\theta$, initially  
     66    to the beam line coordinates, where the beam is along the $z$ axis. Rotation $\theta$, initially 
    6767    in the $xz$ plane, is carried out first, then rotation $\phi$ about the $z$ axis. Orientation distributions 
    6868    are described as rotations about two perpendicular axes $\delta_1$ and $\delta_2$ 
     
    133133              ["theta", "degrees", 60, [-360, 360], "orientation", 
    134134               "cylinder axis to beam angle"], 
    135               ["phi", "degrees",   60, [-360, 360], "orientation", 
     135              ["phi", "degrees", 60, [-360, 360], "orientation", 
    136136               "rotation about beam"], 
    137137             ] 
    138138 
    139 source = ["lib/polevl.c", "lib/sas_J1.c", "lib/gauss76.c",  "cylinder.c"] 
     139source = ["lib/polevl.c", "lib/sas_J1.c", "lib/gauss76.c", "cylinder.c"] 
    140140 
    141141def ER(radius, length): 
     
    147147 
    148148def random(): 
    149     import numpy as np 
    150     V = 10**np.random.uniform(5, 12) 
    151     length = 10**np.random.uniform(-2, 2)*V**0.333 
    152     radius = np.sqrt(V/length/np.pi) 
     149    volume = 10**np.random.uniform(5, 12) 
     150    length = 10**np.random.uniform(-2, 2)*volume**0.333 
     151    radius = np.sqrt(volume/length/np.pi) 
    153152    pars = dict( 
    154153        #scale=1, 
     
    172171qx, qy = 0.2 * np.cos(2.5), 0.2 * np.sin(2.5) 
    173172# After redefinition of angles, find new tests values.  Was 10 10 in old coords 
    174 tests = [[{}, 0.2, 0.042761386790780453], 
    175         [{}, [0.2], [0.042761386790780453]], 
    176 #  new coords 
    177         [{'theta':80.1534480601659, 'phi':10.1510817110481}, (qx, qy), 0.03514647218513852], 
    178         [{'theta':80.1534480601659, 'phi':10.1510817110481}, [(qx, qy)], [0.03514647218513852]], 
    179 # old coords   [{'theta':10.0, 'phi':10.0}, (qx, qy), 0.03514647218513852], 
    180 #              [{'theta':10.0, 'phi':10.0}, [(qx, qy)], [0.03514647218513852]], 
    181         ] 
     173tests = [ 
     174    [{}, 0.2, 0.042761386790780453], 
     175    [{}, [0.2], [0.042761386790780453]], 
     176    #  new coords 
     177    [{'theta':80.1534480601659, 'phi':10.1510817110481}, (qx, qy), 0.03514647218513852], 
     178    [{'theta':80.1534480601659, 'phi':10.1510817110481}, [(qx, qy)], [0.03514647218513852]], 
     179    # old coords 
     180    #[{'theta':10.0, 'phi':10.0}, (qx, qy), 0.03514647218513852], 
     181    #[{'theta':10.0, 'phi':10.0}, [(qx, qy)], [0.03514647218513852]], 
     182] 
    182183del qx, qy  # not necessary to delete, but cleaner 
    183184# ADDED by:  RKH  ON: 18Mar2016 renamed sld's etc 
  • sasmodels/models/dab.py

    r404ebbd r2d81cfe  
    3838 
    3939*2013/09/09 - Description reviewed by King, S and Parker, P.* 
    40  
    4140""" 
    4241 
     42import numpy as np 
    4343from numpy import inf 
    4444 
     
    6666 
    6767def random(): 
    68     import numpy as np 
    6968    pars = dict( 
    7069        scale=10**np.random.uniform(1, 4), 
  • sasmodels/models/ellipsoid.py

    r110f69c r2d81cfe  
    123123from __future__ import division 
    124124 
     125import numpy as np 
    125126from numpy import inf, sin, cos, pi 
    126127 
     
    163164 
    164165def ER(radius_polar, radius_equatorial): 
    165     import numpy as np 
    166166    # see equation (26) in A.Isihara, J.Chem.Phys. 18(1950)1446-1449 
    167167    ee = np.empty_like(radius_polar) 
     
    185185 
    186186def random(): 
    187     import numpy as np 
    188     V = 10**np.random.uniform(5, 12) 
     187    volume = 10**np.random.uniform(5, 12) 
    189188    radius_polar = 10**np.random.uniform(1.3, 4) 
    190     radius_equatorial = np.sqrt(V/radius_polar) # ignore 4/3 pi 
     189    radius_equatorial = np.sqrt(volume/radius_polar) # ignore 4/3 pi 
    191190    pars = dict( 
    192191        #background=0, sld=0, sld_solvent=1, 
     
    208207qx = q*cos(pi/6.0) 
    209208qy = q*sin(pi/6.0) 
    210 tests = [[{}, 0.05, 54.8525847025], 
    211         [{'theta':80., 'phi':10.}, (qx, qy), 1.74134670026], 
    212         ] 
     209tests = [ 
     210    [{}, 0.05, 54.8525847025], 
     211    [{'theta':80., 'phi':10.}, (qx, qy), 1.74134670026], 
     212] 
    213213del qx, qy  # not necessary to delete, but cleaner 
  • sasmodels/models/elliptical_cylinder.py

    reda8b30 r2d81cfe  
    4343    P(q) = \text{scale}  <F^2> / V 
    4444 
    45 For 2d data the orientation of the particle is required, described using a different set  
    46 of angles as in the diagrams below, for further details of the calculation and angular  
     45For 2d data the orientation of the particle is required, described using a different set 
     46of angles as in the diagrams below, for further details of the calculation and angular 
    4747dispersions  see :ref:`orientation` . 
    4848 
     
    9595* **Last Modified by:** 
    9696* **Last Reviewed by:**  Richard Heenan - corrected equation in docs **Date:** December 21, 2016 
    97  
    9897""" 
    9998 
     99import numpy as np 
    100100from numpy import pi, inf, sqrt, sin, cos 
    101101 
     
    141141 
    142142def random(): 
    143     import numpy as np 
    144143    # V = pi * radius_major * radius_minor * length; 
    145     V = 10**np.random.uniform(3, 9) 
     144    volume = 10**np.random.uniform(3, 9) 
    146145    length = 10**np.random.uniform(1, 3) 
    147146    axis_ratio = 10**np.random.uniform(0, 2) 
    148     radius_minor = np.sqrt(V/length/axis_ratio) 
    149     Vf = 10**np.random.uniform(-4, -2) 
     147    radius_minor = np.sqrt(volume/length/axis_ratio) 
     148    volfrac = 10**np.random.uniform(-4, -2) 
    150149    pars = dict( 
    151150        #background=0, sld=0, sld_solvent=1, 
    152         scale=1e9*Vf/V, 
     151        scale=1e9*volfrac/volume, 
    153152        length=length, 
    154153        radius_minor=radius_minor, 
     
    170169      'sld_solvent':1.0, 'background':0.0}, 
    171170     0.001, 675.504402], 
    172 #    [{'theta':80., 'phi':10.}, (qx, qy), 7.88866563001 ], 
     171    #[{'theta':80., 'phi':10.}, (qx, qy), 7.88866563001 ], 
    173172] 
  • sasmodels/models/fcc_paracrystal.py

    r1f159bd r2d81cfe  
    9595""" 
    9696 
     97import numpy as np 
    9798from numpy import inf, pi 
    9899 
     
    124125 
    125126def random(): 
    126     import numpy as np 
    127127    # copied from bcc_paracrystal 
    128128    radius = 10**np.random.uniform(1.3, 4) 
  • sasmodels/models/flexible_cylinder.py

    r2573fa1 r2d81cfe  
    606022(15) 2006 6539-6548 
    6161""" 
     62 
     63import numpy as np 
    6264from numpy import inf 
    6365 
     
    8789 
    8890def random(): 
    89     import numpy as np 
    9091    length = 10**np.random.uniform(2, 6) 
    9192    radius = 10**np.random.uniform(1, 3) 
  • sasmodels/models/flexible_cylinder_elliptical.py

    r31df0c9 r2d81cfe  
    838322(15) 2006 6539-6548 
    8484""" 
     85 
     86import numpy as np 
    8587from numpy import inf 
    8688 
     
    113115 
    114116def random(): 
    115     import numpy as np 
    116117    length = 10**np.random.uniform(2, 6) 
    117118    radius = 10**np.random.uniform(1, 3) 
     
    164165     }, 1.0, 0.0016338264790] 
    165166    ] 
    166  
  • sasmodels/models/fractal.py

    r1511c37c r2d81cfe  
    5353* **Last Modified by:** Paul Butler **Date:** March 12, 2017 
    5454* **Last Reviewed by:** Paul Butler **Date:** March 12, 2017 
    55  
    5655""" 
    5756from __future__ import division 
    5857 
     58import numpy as np 
    5959from numpy import inf 
    6060 
     
    100100 
    101101def random(): 
    102     import numpy as np 
    103102    radius = 10**np.random.uniform(0.7, 4) 
    104103    #radius = 5 
  • sasmodels/models/fractal_core_shell.py

    rca04add r2d81cfe  
    5757* **Last Modified by:** Paul Butler and Paul Kienzle **on:** November 27, 2016 
    5858* **Last Reviewed by:** Paul Butler and Paul Kienzle **on:** November 27, 2016 
    59  
    6059""" 
    6160 
     61import numpy as np 
    6262from numpy import pi, inf 
    6363 
     
    9898 
    9999def random(): 
    100     import numpy as np 
    101100    outer_radius = 10**np.random.uniform(0.7, 4) 
    102101    # Use a distribution with a preference for thin shell or thin core 
  • sasmodels/models/fuzzy_sphere.py

    r31df0c9 r2d81cfe  
    5555""" 
    5656 
     57import numpy as np 
    5758from numpy import inf 
    5859 
     
    106107 
    107108def random(): 
    108     import numpy as np 
    109109    radius = 10**np.random.uniform(1, 4.7) 
    110110    fuzziness = 10**np.random.uniform(-2, -0.5)*radius  # 1% to 31% fuzziness 
  • sasmodels/models/gauss_lorentz_gel.py

    r48462b0 r2d81cfe  
    3434G Evmenenko, E Theunissen, K Mortensen, H Reynaers, *Polymer*, 
    353542 (2001) 2907-2913 
    36  
    3736""" 
    3837 
     38import numpy as np 
    3939from numpy import inf, exp 
    4040 
     
    8989 
    9090def random(): 
    91     import numpy as np 
    9291    gauss_scale = 10**np.random.uniform(1, 3) 
    9392    lorentz_scale = 10**np.random.uniform(1, 3) 
  • sasmodels/models/gaussian_peak.py

    r48462b0 r2d81cfe  
    2828""" 
    2929 
     30import numpy as np 
    3031from numpy import inf 
    3132 
     
    5253 
    5354def random(): 
    54     import numpy as np 
    5555    peak_pos = 10**np.random.uniform(-3, -1) 
    5656    sigma = 10**np.random.uniform(-1.3, -0.3)*peak_pos 
  • sasmodels/models/gel_fit.py

    r48462b0 r2d81cfe  
    4242Simon Mallam, Ferenc Horkay, Anne-Marie Hecht, Adrian R Rennie, Erik Geissler, 
    4343*Macromolecules* 1991, 24, 543-548 
    44  
    4544""" 
    4645 
     46import numpy as np 
    4747from numpy import inf 
    4848 
     
    7272 
    7373def random(): 
    74     import numpy as np 
    7574    guinier_scale = 10**np.random.uniform(1, 3) 
    7675    lorentz_scale = 10**np.random.uniform(1, 3) 
  • sasmodels/models/guinier.py

    r48462b0 r2d81cfe  
    2727""" 
    2828 
     29import numpy as np 
    2930from numpy import inf 
    3031 
     
    5051 
    5152def random(): 
    52     import numpy as np 
    5353    scale = 10**np.random.uniform(1, 4) 
    5454    # Note: compare.py has Rg cutoff of 1e-30 at q=1 for guinier, so use that 
  • sasmodels/models/guinier_porod.py

    r48462b0 r2d81cfe  
    6363 
    6464B Hammouda, *Analysis of the Beaucage model, J. Appl. Cryst.*, (2010), 43, 1474-1478 
    65  
    6665""" 
    6766 
     67import numpy as np 
    6868from numpy import inf, sqrt, exp, errstate 
    6969 
     
    115115 
    116116def random(): 
    117     import numpy as np 
    118117    rg = 10**np.random.uniform(1, 5) 
    119118    s = np.random.uniform(0, 3) 
  • sasmodels/models/hardsphere.py

    r8f04da4 r2d81cfe  
    4242""" 
    4343 
     44import numpy as np 
    4445from numpy import inf 
    4546 
     
    7778      // these are c compiler instructions, can also put normal code inside the "if else" structure 
    7879      #if FLOAT_SIZE > 4 
    79       // double precision    orig had 0.2, don't call the variable cutoff as PAK already has one called that! Must use UPPERCASE name please. 
    80       //  0.05 better, 0.1 OK 
     80      // double precision 
     81      // orig had 0.2, don't call the variable cutoff as PAK already has one called that! 
     82      // Must use UPPERCASE name please. 
     83      // 0.05 better, 0.1 OK 
    8184      #define CUTOFFHS 0.05 
    8285      #else 
     
    9093               return(HARDSPH); 
    9194      } 
    92       // removing use of pow(xxx,2) and rearranging the calcs of A, B & G cut ~40% off execution time ( 0.5 to 0.3 msec) 
     95      // removing use of pow(xxx,2) and rearranging the calcs 
     96      // of A, B & G cut ~40% off execution time ( 0.5 to 0.3 msec) 
    9397      X = 1.0/( 1.0 -volfraction); 
    9498      D= X*X; 
     
    110114      if(X < CUTOFFHS) { 
    111115      // RKH Feb 2016, use Taylor series expansion for small X 
    112       // else no obvious way to rearrange the equations to avoid needing a very high number of significant figures. 
    113       // Series expansion found using Mathematica software. Numerical test in .xls showed terms to X^2 are sufficient 
     116      // else no obvious way to rearrange the equations to avoid 
     117      // needing a very high number of significant figures. 
     118      // Series expansion found using Mathematica software. Numerical test 
     119      // in .xls showed terms to X^2 are sufficient 
    114120      // for 5 or 6 significant figures, but I put the X^4 one in anyway 
    115121            //FF = 8*A +6*B + 4*G - (0.8*A +2.0*B/3.0 +0.5*G)*X2 +(A/35. +B/40. +G/50.)*X4; 
     
    130136      SINCOS(X,S,C); 
    131137 
    132 // RKH Feb 2016, use version FISH code as is better than original sasview one at small Q in single precision, and more than twice as fast in double. 
     138// RKH Feb 2016, use version FISH code as is better than original sasview one 
     139// at small Q in single precision, and more than twice as fast in double. 
    133140      //FF=A*(S-X*C)/X + B*(2.*X*S -(X2-2.)*C -2.)/X2 + G*( (4.*X2*X -24.*X)*S -(X4 -12.*X2 +24.)*C +24. )/X4; 
    134141      // refactoring the polynomial here & above makes it slightly faster 
     
    154161 
    155162def random(): 
    156     import numpy as np 
    157163    pars = dict( 
    158164        scale=1, background=0, 
     
    167173demo = dict(radius_effective=200, volfraction=0.2, 
    168174            radius_effective_pd=0.1, radius_effective_pd_n=40) 
    169 # Q=0.001 is in the Taylor series, low Q part, so add Q=0.1, assuming double precision sasview is correct 
     175# Q=0.001 is in the Taylor series, low Q part, so add Q=0.1, 
     176# assuming double precision sasview is correct 
    170177tests = [ 
    171         [ {'scale': 1.0, 'background' : 0.0, 'radius_effective' : 50.0, 
    172            'volfraction' : 0.2, 'radius_effective_pd' : 0}, 
    173           [0.001,0.1], [0.209128,0.930587]], 
    174         ] 
    175 # ADDED by: RKH  ON: 16Mar2016  using equations from FISH as better than orig sasview, see notes above. Added Taylor expansions at small Q, 
     178    [{'scale': 1.0, 'background' : 0.0, 'radius_effective' : 50.0, 
     179      'volfraction' : 0.2, 'radius_effective_pd' : 0}, 
     180     [0.001, 0.1], [0.209128, 0.930587]], 
     181] 
     182# ADDED by: RKH  ON: 16Mar2016  using equations from FISH as better than 
     183# orig sasview, see notes above. Added Taylor expansions at small Q. 
  • sasmodels/models/hayter_msa.py

    r8f04da4 r2d81cfe  
    4141J P Hansen and J B Hayter, *Molecular Physics*, 46 (1982) 651-656 
    4242""" 
     43 
     44import numpy as np 
    4345from numpy import inf 
    4446 
     
    9193 
    9294def random(): 
    93     import numpy as np 
    9495    # TODO: too many failures for random hayter_msa parameters 
    9596    pars = dict( 
  • sasmodels/models/hollow_cylinder.py

    r8f04da4 r2d81cfe  
    3838for structure factor $S(q)$ when $P(q) \cdot S(q)$ is applied. 
    3939 
    40 In the parameters,the *radius* is $R_\text{core}$ while *thickness* is $R_\text{outer} - R_\text{core}$. 
     40In the parameters,the *radius* is $R_\text{core}$ while *thickness* 
     41is $R_\text{outer} - R_\text{core}$. 
    4142 
    4243To provide easy access to the orientation of the core-shell cylinder, we define 
     
    5758   (reparametrised to use thickness, not outer radius) 
    5859* **Last Reviewed by:** Richard Heenan **Date:** October 06, 2016 
    59  
    6060""" 
    6161 
     62import numpy as np 
    6263from numpy import pi, inf, sin, cos 
    6364 
     
    122123 
    123124def random(): 
    124     import numpy as np 
    125125    length = 10**np.random.uniform(1, 4.7) 
    126126    outer_radius = 10**np.random.uniform(1, 4.7) 
     
    153153    [{}, 'VR', 1.8], 
    154154    [{}, 0.001, 1756.76], 
    155     [{}, (qx, qy), 2.36885476192  ], 
    156         ] 
     155    [{}, (qx, qy), 2.36885476192], 
     156] 
    157157del qx, qy  # not necessary to delete, but cleaner 
  • sasmodels/models/hollow_rectangular_prism.py

    r30b60d2 r2d81cfe  
    8080 
    8181R Nayuk and K Huber, *Z. Phys. Chem.*, 226 (2012) 837-854 
    82  
    8382""" 
    8483 
     84import numpy as np 
    8585from numpy import pi, inf, sqrt 
    8686 
     
    147147 
    148148def random(): 
    149     import numpy as np 
    150149    a, b, c = 10**np.random.uniform(1, 4.7, size=3) 
    151150    # Thickness is limited to 1/2 the smallest dimension 
     
    175174         [{}, [0.2], [0.76687283098]], 
    176175        ] 
    177  
  • sasmodels/models/hollow_rectangular_prism_thin_walls.py

    r31df0c9 r2d81cfe  
    7474 
    7575R Nayuk and K Huber, *Z. Phys. Chem.*, 226 (2012) 837-854 
    76  
    7776""" 
    7877 
     78import numpy as np 
    7979from numpy import pi, inf, sqrt 
    8080 
     
    128128 
    129129def random(): 
    130     import numpy as np 
    131130    a, b, c = 10**np.random.uniform(1, 4.7, size=3) 
    132131    pars = dict( 
     
    149148         [{}, [0.2], [0.837719188592]], 
    150149        ] 
    151  
    152  
  • sasmodels/models/lamellar.py

    r1511c37c r2d81cfe  
    4343 
    4444also in J. Phys. Chem. B, 105, (2001) 11081-11088 
    45  
    46  
    4745""" 
    4846 
     47import numpy as np 
    4948from numpy import inf 
    5049 
     
    9089 
    9190def random(): 
    92     import numpy as np 
    9391    thickness = 10**np.random.uniform(1, 4) 
    9492    pars = dict( 
     
    104102            thickness=40, 
    105103            thickness_pd=0.2, thickness_pd_n=40) 
     104#  [(qx1, qy1), (qx2, qy2), ...], [I(qx1,qy1), I(qx2,qy2), ...]], 
    106105tests = [ 
    107         [ {'scale': 1.0, 'background': 0.0, 'thickness': 50.0, 
    108            'sld': 1.0, 'sld_solvent': 6.3, 'thickness_pd': 0.0}, 
    109           [0.001], [882289.54309]] 
    110         ] 
    111 # ADDED by: converted by PAK? (or RKH?)     ON: 16Mar2016 - RKH adding unit tests from sasview to early 2015 conversion 
    112 #  [(qx1, qy1), (qx2, qy2), ...], [I(qx1,qy1), I(qx2,qy2), ...]], 
     106    [{'scale': 1.0, 'background': 0.0, 'thickness': 50.0, 
     107      'sld': 1.0, 'sld_solvent': 6.3, 'thickness_pd': 0.0}, 
     108     [0.001], [882289.54309]] 
     109] 
     110# ADDED by: converted by PAK? (or RKH?) 
     111# ON: 16Mar2016 - RKH adding unit tests from sasview to early 2015 conversion 
  • sasmodels/models/lamellar_hg.py

    r1511c37c r2d81cfe  
    4848""" 
    4949 
     50import numpy as np 
    5051from numpy import inf 
    5152 
     
    99100 
    100101def random(): 
    101     import numpy as np 
    102102    thickness = 10**np.random.uniform(1, 4) 
    103103    length_head = thickness * np.random.uniform(0, 1) 
  • sasmodels/models/lamellar_hg_stack_caille.py

    r1511c37c r2d81cfe  
    7373also in J. Phys. Chem. B, 105, (2001) 11081-11088 
    7474""" 
     75 
     76import numpy as np 
    7577from numpy import inf 
    7678 
     
    124126 
    125127def random(): 
    126     import numpy as np 
    127128    total_thickness = 10**np.random.uniform(2, 4.7) 
    128129    Nlayers = np.random.randint(2, 200) 
  • sasmodels/models/lamellar_stack_caille.py

    r1511c37c r2d81cfe  
    6868also in J. Phys. Chem. B, 105, (2001) 11081-11088 
    6969""" 
     70 
     71import numpy as np 
    7072from numpy import inf 
    7173 
     
    99101 
    100102def random(): 
    101     import numpy as np 
    102103    total_thickness = 10**np.random.uniform(2, 4.7) 
    103104    Nlayers = np.random.randint(2, 200) 
  • sasmodels/models/lamellar_stack_paracrystal.py

    r8f04da4 r2d81cfe  
    9090M Bergstrom, J S Pedersen, P Schurtenberger, S U Egelhaaf, 
    9191*J. Phys. Chem. B*, 103 (1999) 9888-9897 
    92  
    9392""" 
    9493 
     94import numpy as np 
    9595from numpy import inf 
    9696 
     
    133133 
    134134def random(): 
    135     import numpy as np 
    136135    total_thickness = 10**np.random.uniform(2, 4.7) 
    137136    Nlayers = np.random.randint(2, 200) 
     
    158157# 
    159158tests = [ 
    160     [{'scale': 1.0, 'background': 0.0, 'thickness': 33.,'Nlayers': 20.0, 
     159    [{'scale': 1.0, 'background': 0.0, 'thickness': 33., 'Nlayers': 20.0, 
    161160      'd_spacing': 250., 'sigma_d': 0.2, 'sld': 1.0, 
    162       'sld_solvent': 6.34, 'thickness_pd': 0.0, 'thickness_pd_n': 40 }, 
     161      'sld_solvent': 6.34, 'thickness_pd': 0.0, 'thickness_pd_n': 40}, 
    163162     [0.001, 0.215268], [21829.3, 0.00487686]], 
    164163] 
    165 # ADDED by: RKH  ON: 18Mar2016  converted from sasview previously, now renaming everything & sorting the docs 
     164# ADDED by: RKH  ON: 18Mar2016  converted from sasview previously, 
     165# now renaming everything & sorting the docs 
  • sasmodels/models/line.py

    rc63a7c8 r2d81cfe  
    2222 
    2323None. 
     24""" 
    2425 
    25 """ 
     26import numpy as np 
    2627from numpy import inf 
    2728 
     
    7071 
    7172def random(): 
    72     import numpy as np 
    7373    scale = 10**np.random.uniform(0, 3) 
    7474    slope = np.random.uniform(-1, 1)*1e2 
  • sasmodels/models/linear_pearls.py

    r8f04da4 r2d81cfe  
    3131A V Dobrynin, M Rubinstein and S P Obukhov, *Macromol.*, 
    323229 (1996) 2974-2979 
    33  
    3433""" 
    3534 
     35import numpy as np 
    3636from numpy import inf 
    3737 
     
    6666 
    6767def random(): 
    68     import numpy as np 
    6968    radius = 10**np.random.uniform(1, 3) # 1 - 1000 
    7069    edge_sep = 10**np.random.uniform(0, 3)  # 1 - 1000 
  • sasmodels/models/lorentz.py

    r404ebbd r2d81cfe  
    2424""" 
    2525 
     26import numpy as np 
    2627from numpy import inf 
    2728 
     
    4950 
    5051def random(): 
    51     import numpy as np 
    5252    pars = dict( 
    5353        #background=0, 
  • sasmodels/models/mass_fractal.py

    r4553dae r2d81cfe  
    5151D Mildner and P Hall, *J. Phys. D: Appl. Phys.*, 
    525219 (1986) 1535-1545 Equation(9) 
    53  
    54  
    5553""" 
    5654 
     55import numpy as np 
    5756from numpy import inf 
    5857 
     
    8988 
    9089def random(): 
    91     import numpy as np 
    9290    radius = 10**np.random.uniform(0.7, 4) 
    9391    cutoff_length = 10**np.random.uniform(0.7, 2)*radius 
    9492    # TODO: fractal dimension should range from 1 to 6 
    9593    fractal_dim_mass = 2*np.random.beta(3, 4) + 1 
    96     Vf = 10**np.random.uniform(-4, -1) 
     94    #volfrac = 10**np.random.uniform(-4, -1) 
    9795    pars = dict( 
    9896        #background=0, 
    99         scale=1, #1e5*Vf/radius**(fractal_dim_mass), 
     97        scale=1, #1e5*volfrac/radius**(fractal_dim_mass), 
    10098        radius=radius, 
    10199        cutoff_length=cutoff_length, 
  • sasmodels/models/mass_surface_fractal.py

    rca04add r2d81cfe  
    4949A J Hurd, D W Schaefer, J E Martin, *Phys. Rev. A*, 
    505035 (1987) 2361-2364 Equation(2) 
    51  
    5251""" 
    5352 
     53import numpy as np 
    5454from numpy import inf 
    5555 
     
    8686 
    8787def random(): 
    88     import numpy as np 
    8988    fractal_dim = np.random.uniform(0, 6) 
    9089    surface_portion = np.random.uniform(0, 1) 
  • sasmodels/models/mono_gauss_coil.py

    rca04add r2d81cfe  
    5353""" 
    5454 
     55import numpy as np 
    5556from numpy import inf, exp, errstate 
    5657 
     
    8485 
    8586def random(): 
    86     import numpy as np 
    8787    rg = 10**np.random.uniform(0, 4) 
    8888    #rg = 1e3 
  • sasmodels/models/multilayer_vesicle.py

    r64eecf7 r2d81cfe  
    110110""" 
    111111 
     112import numpy as np 
    112113from numpy import inf 
    113114 
     
    151152 
    152153def random(): 
    153     import numpy as np 
    154154    volfraction = 10**np.random.uniform(-3, -0.5)  # scale from 0.1% to 30% 
    155155    radius = 10**np.random.uniform(0, 2.5) # core less than 300 A 
  • sasmodels/models/onion.py

    rca04add r2d81cfe  
    260260# 
    261261 
    262  
    263262from __future__ import division 
     263 
     264from math import fabs, exp, expm1 
    264265 
    265266import numpy as np 
    266267from numpy import inf, nan 
    267 from math import fabs, exp, expm1 
    268268 
    269269name = "onion" 
     
    356356                z.append(z_current+z_shell) 
    357357                rho.append(slope*exp(A[k]*z_shell/thickness[k]) + const) 
    358      
     358 
    359359    # add in the solvent 
    360360    z.append(z[-1]) 
     
    386386    #"thickness4_pd": 0.4, 
    387387    } 
    388  
  • sasmodels/models/parallelepiped.py

    reda8b30 r2d81cfe  
    7474$S(q)$ when $P(q) \cdot S(q)$ is applied. 
    7575 
    76 For 2d data the orientation of the particle is required, described using  
    77 angles $\theta$, $\phi$ and $\Psi$ as in the diagrams below, for further details  
     76For 2d data the orientation of the particle is required, described using 
     77angles $\theta$, $\phi$ and $\Psi$ as in the diagrams below, for further details 
    7878of the calculation and angular dispersions see :ref:`orientation` . 
    7979 
     
    106106    detector plane. 
    107107 
    108 On introducing "Orientational Distribution" in the angles, "distribution of theta" and "distribution of phi" parameters will 
    109 appear. These are actually rotations about axes $\delta_1$ and $\delta_2$ of the parallelepiped, perpendicular to the $a$ x $c$ and $b$ x $c$ faces. 
    110 (When $\theta = \phi = 0$ these are parallel to the $Y$ and $X$ axes of the instrument.) The third orientation distribution, in $\psi$, is 
    111 about the $c$ axis of the particle, perpendicular to the $a$ x $b$ face. Some experimentation may be required to 
    112 understand the 2d patterns fully as discussed in :ref:`orientation` .  
     108On introducing "Orientational Distribution" in the angles, "distribution of 
     109theta" and "distribution of phi" parameters will appear. These are actually 
     110rotations about axes $\delta_1$ and $\delta_2$ of the parallelepiped, 
     111perpendicular to the $a$ x $c$ and $b$ x $c$ faces. (When $\theta = \phi = 0$ 
     112these are parallel to the $Y$ and $X$ axes of the instrument.) The third 
     113orientation distribution, in $\psi$, is about the $c$ axis of the particle, 
     114perpendicular to the $a$ x $b$ face. Some experimentation may be required to 
     115understand the 2d patterns fully as discussed in :ref:`orientation` . 
    113116 
    114117For a given orientation of the parallelepiped, the 2D form factor is 
     
    165168 
    166169* **Author:** This model is based on form factor calculations implemented 
    167     in a c-library provided by the NIST Center for Neutron Research (Kline, 2006). 
     170  in a c-library provided by the NIST Center for Neutron Research (Kline, 2006). 
    168171* **Last Modified by:**  Paul Kienzle **Date:** April 05, 2017 
    169172* **Last Reviewed by:**  Richard Heenan **Date:** April 06, 2017 
    170  
    171173""" 
    172174 
     
    216218    Return effective radius (ER) for P(q)*S(q) 
    217219    """ 
    218     # now that axes can be in any size order, need to sort a,b,c where a~b and c is either much smaller 
    219     # or much larger 
     220    # now that axes can be in any size order, need to sort a,b,c 
     221    # where a~b and c is either much smaller or much larger 
    220222    abc = np.vstack((length_a, length_b, length_c)) 
    221223    abc = np.sort(abc, axis=0) 
     
    223225    length = np.where(selector, abc[0], abc[2]) 
    224226    # surface average radius (rough approximation) 
    225     radius = np.sqrt(np.where(~selector, abc[0]*abc[1], abc[1]*abc[2]) / pi) 
     227    radius = sqrt(np.where(~selector, abc[0]*abc[1], abc[1]*abc[2]) / pi) 
    226228 
    227229    ddd = 0.75 * radius * (2*radius*length + (length + radius)*(length + pi*radius)) 
     
    232234 
    233235def random(): 
    234     import numpy as np 
    235236    length = 10**np.random.uniform(1, 4.7, size=3) 
    236237    pars = dict( 
     
    253254            phi_pd=10, phi_pd_n=1, 
    254255            psi_pd=10, psi_pd_n=10) 
    255 # rkh 7/4/17 add random unit test for 2d, note make all params different, 2d values not tested against other codes or models 
     256# rkh 7/4/17 add random unit test for 2d, note make all params different, 
     257# 2d values not tested against other codes or models 
    256258qx, qy = 0.2 * cos(pi/6.), 0.2 * sin(pi/6.) 
    257259tests = [[{}, 0.2, 0.17758004974], 
  • sasmodels/models/peak_lorentz.py

    r404ebbd r2d81cfe  
    2626 
    2727None. 
    28  
    2928""" 
    3029 
     30import numpy as np 
    3131from numpy import inf 
    3232 
     
    6060 
    6161def random(): 
    62     import numpy as np 
    6362    peak_pos = 10**np.random.uniform(-3, -1) 
    6463    peak_hwhm = peak_pos * 10**np.random.uniform(-3, 0) 
  • sasmodels/models/pearl_necklace.py

    r8f04da4 r2d81cfe  
    5555""" 
    5656 
     57import numpy as np 
    5758from numpy import inf, pi 
    5859 
     
    118119 
    119120def random(): 
    120     import numpy as np 
    121121    radius = 10**np.random.uniform(1, 3) # 1 - 1000 
    122122    thick_string = 10**np.random.uniform(0, np.log10(radius)-1) # 1 - radius/10 
  • sasmodels/models/poly_gauss_coil.py

    rca04add r2d81cfe  
    106106 
    107107def random(): 
    108     import numpy as np 
    109108    rg = 10**np.random.uniform(0, 4) 
    110109    #rg = 1e3 
  • sasmodels/models/polymer_excl_volume.py

    r404ebbd r2d81cfe  
    9090B Hammouda, *SANS from Homogeneous Polymer Mixtures - A Unified Overview, 
    9191Advances in Polym. Sci.* 106(1993) 87-133 
    92  
    9392""" 
    9493 
     94import numpy as np 
    9595from numpy import inf, power, errstate 
    9696from scipy.special import gammainc, gamma 
     
    124124    with errstate(divide='ignore', invalid='ignore'): 
    125125        upow = power(usub, -0.5*porod_exp) 
    126         result= (porod_exp*upow * 
    127                  (gamma(0.5*porod_exp)*gammainc(0.5*porod_exp, usub) - 
    128                   upow*gamma(porod_exp)*gammainc(porod_exp, usub))) 
     126        result = (porod_exp*upow * 
     127                  (gamma(0.5*porod_exp)*gammainc(0.5*porod_exp, usub) - 
     128                   upow*gamma(porod_exp)*gammainc(porod_exp, usub))) 
    129129    result[q <= 0] = 1.0 
    130130 
     
    134134 
    135135def random(): 
    136     import numpy as np 
    137136    rg = 10**np.random.uniform(0, 4) 
    138137    porod_exp = np.random.uniform(1e-3, 6) 
  • sasmodels/models/polymer_micelle.py

    rca04add r2d81cfe  
    1313the equations given by Pedersen (Pedersen, 2000), summarised briefly here. 
    1414 
    15 The micelle core is imagined as $N\_aggreg$ polymer heads, each of volume $v\_core$, 
    16 which then defines a micelle core of $radius\_core$, which is a separate parameter 
    17 even though it could be directly determined. 
    18 The Gaussian random coil tails, of gyration radius $rg$, are imagined uniformly 
    19 distributed around the spherical core, centred at a distance $radius\_core + d\_penetration.rg$ 
    20 from the micelle centre, where $d\_penetration$ is of order unity. 
    21 A volume $v\_corona$ is defined for each coil. 
    22 The model in detail seems to separately parametrise the terms for the shape of I(Q) and the 
    23 relative intensity of each term, so use with caution and check parameters for consistency. 
    24 The spherical core is monodisperse, so it's intensity and the cross terms may have sharp 
    25 oscillations (use q resolution smearing if needs be to help remove them). 
     15The micelle core is imagined as $N$ = *n_aggreg* polymer heads, each of volume 
     16$V_\text{core}$, which then defines a micelle core of radius $r$ = *r_core*, 
     17which is a separate parameter even though it could be directly determined. 
     18The Gaussian random coil tails, of gyration radius $R_g$, are imagined 
     19uniformly distributed around the spherical core, centred at a distance 
     20$r + d \cdot R_g$ from the micelle centre, where $d$ = *d_penetration* is 
     21of order unity. A volume $V_\text{corona}$ is defined for each coil. The 
     22model in detail seems to separately parametrise the terms for the shape 
     23of $I(Q)$ and the relative intensity of each term, so use with caution 
     24and check parameters for consistency. The spherical core is monodisperse, 
     25so it's intensity and the cross terms may have sharp oscillations (use $q$ 
     26resolution smearing if needs be to help remove them). 
    2627 
    2728.. math:: 
    28     P(q) = N^2\beta^2_s\Phi(qR)^2+N\beta^2_cP_c(q)+2N^2\beta_s\beta_cS_{sc}s_c(q)+N(N-1)\beta_c^2S_{cc}(q) \\ 
    29     \beta_s = v\_core(sld\_core - sld\_solvent) \\ 
    30     \beta_c = v\_corona(sld\_corona - sld\_solvent) 
     29    P(q) &= N^2\beta^2_s\Phi(qr)^2 + N\beta^2_cP_c(q) 
     30            + 2N^2\beta_s\beta_cS_{sc}s_c(q) + N(N-1)\beta_c^2S_{cc}(q) \\ 
     31    \beta_s &= V_\text{core}(\rho_\text{core} - \rho_\text{solvent}) \\ 
     32    \beta_c &= V_\text{corona}(\rho_\text{corona} - \rho_\text{solvent}) 
    3133 
    32 where $N = n\_aggreg$, and for the spherical core of radius $R$ 
     34where $\rho_\text{core}$, $\rho_\text{corona}$ and $\rho_\text{solvent}$ are 
     35the scattering length densities *sld_core*, *sld_corona* and *sld_solvent*. 
     36For the spherical core of radius $r$ 
    3337 
    3438.. math:: 
    35    \Phi(qR)= \frac{\sin(qr) - qr\cos(qr)}{(qr)^3} 
     39   \Phi(qr)= \frac{\sin(qr) - qr\cos(qr)}{(qr)^3} 
    3640 
    3741whilst for the Gaussian coils 
     
    4246   Z &= (q R_g)^2 
    4347 
    44 The sphere to coil ( core to corona) and coil to coil (corona to corona) cross terms are 
    45 approximated by: 
     48The sphere to coil (core to corona) and coil to coil (corona to corona) cross 
     49terms are approximated by: 
    4650 
    4751.. math:: 
    4852 
    49    S_{sc}(q)=\Phi(qR)\psi(Z)\frac{sin(q(R+d.R_g))}{q(R+d.R_g)} \\ 
    50    S_{cc}(q)=\psi(Z)^2\left[\frac{sin(q(R+d.R_g))}{q(R+d.R_g)} \right ]^2 \\ 
    51    \psi(Z)=\frac{[1-exp^{-Z}]}{Z} 
     53   S_{sc}(q) &= \Phi(qr)\psi(Z) 
     54       \frac{\sin(q(r+d \cdot R_g))}{q(r+d \cdot R_g)} \\ 
     55   S_{cc}(q) &= \psi(Z)^2 
     56       \left[\frac{\sin(q(r+d \cdot R_g))}{q(r+d \cdot R_g)} \right]^2 \\ 
     57   \psi(Z) &= \frac{[1-\exp^{-Z}]}{Z} 
    5258 
    5359Validation 
    5460---------- 
    5561 
    56 $P(q)$ above is multiplied by $ndensity$, and a units conversion of 10^{-13}, so $scale$ 
    57 is likely 1.0 if the scattering data is in absolute units. This model has not yet been 
    58 independently validated. 
     62$P(q)$ above is multiplied by *ndensity*, and a units conversion of $10^{-13}$, 
     63so *scale* is likely 1.0 if the scattering data is in absolute units. This 
     64model has not yet been independently validated. 
    5965 
    6066 
     
    6369 
    6470J Pedersen, *J. Appl. Cryst.*, 33 (2000) 637-640 
    65  
    6671""" 
    6772 
     73import numpy as np 
    6874from numpy import inf, pi 
    6975 
     
    102108 
    103109def random(): 
    104     import numpy as np 
    105110    radius_core = 10**np.random.uniform(1, 3) 
    106111    rg = radius_core * 10**np.random.uniform(-2, -0.3) 
  • sasmodels/models/porod.py

    r232bb12 r2d81cfe  
    2424""" 
    2525 
    26 from numpy import power, inf, errstate 
     26import numpy as np 
     27from numpy import inf, errstate 
    2728 
    2829name = "porod" 
     
    4647 
    4748def random(): 
    48     import numpy as np 
    4949    sld, solvent = np.random.uniform(-0.5, 12, size=2) 
    5050    radius = 10**np.random.uniform(1, 4.7) 
  • sasmodels/models/power_law.py

    r404ebbd r2d81cfe  
    2727""" 
    2828 
     29import numpy as np 
    2930from numpy import inf, errstate 
    3031 
     
    5152 
    5253def random(): 
    53     import numpy as np 
    5454    power = np.random.uniform(1, 6) 
    5555    pars = dict( 
  • sasmodels/models/pringle.py

    r8f04da4 r2d81cfe  
    4848 
    4949**Last Reviewed by:** Andrew Jackson **on:** September 26, 2016 
    50  
    5150""" 
    5251 
     52import numpy as np 
    5353from numpy import inf, pi 
    5454 
     
    8686 
    8787def random(): 
    88     import numpy as np 
    8988    alpha, beta = 10**np.random.uniform(-1, 1, size=2) 
    9089    radius = 10**np.random.uniform(1, 3) 
  • sasmodels/models/raspberry.py

    r8f04da4 r2d81cfe  
    109109""" 
    110110 
     111import numpy as np 
    111112from numpy import inf 
    112113 
     
    155156 
    156157def random(): 
    157     import numpy as np 
    158158    # Limit volume fraction to 20% each 
    159159    volfraction_lg = 10**np.random.uniform(-3, -0.3) 
  • sasmodels/models/rectangular_prism.py

    r31df0c9 r2d81cfe  
    8181 
    8282R Nayuk and K Huber, *Z. Phys. Chem.*, 226 (2012) 837-854 
    83  
    8483""" 
    8584 
     85import numpy as np 
    8686from numpy import pi, inf, sqrt 
    8787 
     
    126126 
    127127def random(): 
    128     import numpy as np 
    129128    a, b, c = 10**np.random.uniform(1, 4.7, size=3) 
    130129    pars = dict( 
  • sasmodels/models/rpa.py

    r30b60d2 r2d81cfe  
    150150    else: 
    151151        return HIDE_ALL 
    152  
  • sasmodels/models/sc_paracrystal.py

    reda8b30 r2d81cfe  
    2323equations (13)-(15) from the 1987 paper for Z1, Z2, and Z3. 
    2424 
    25 The lattice correction (the occupied volume of the lattice) for a simple 
    26 cubic structure of particles of radius *R* and nearest neighbor separation *D* is 
     25The lattice correction (the occupied volume of the lattice) for a simple cubic 
     26structure of particles of radius *R* and nearest neighbor separation *D* is 
    2727 
    2828.. math:: 
     
    7373    carried out with a high density of points to properly capture the sharp 
    7474    peaks of the paracrystalline scattering. 
    75     So be warned that the calculation is slow. Fitting of any experimental data  
    76     must be resolution smeared for any meaningful fit. This makes a triple integral 
    77     which may be very slow. 
     75    So be warned that the calculation is slow. Fitting of any experimental data 
     76    must be resolution smeared for any meaningful fit. This makes a triple 
     77    integral which may be very slow. 
    7878 
    7979The 2D (Anisotropic model) is based on the reference below where *I(q)* is 
    8080approximated for 1d scattering. Thus the scattering pattern for 2D may not 
    81 be accurate particularly at low $q$. For general details of the calculation  
     81be accurate particularly at low $q$. For general details of the calculation 
    8282and angular dispersions for oriented particles see :ref:`orientation` . 
    8383Note that we are not responsible for any incorrectness of the 
     
    9696Hideki Matsuoka et. al. *Physical Review B,* 41 (1990) 3854 -3856 
    9797(Corrections to FCC and BCC lattice structure calculation) 
    98  
    9998""" 
    10099 
     100import numpy as np 
    101101from numpy import inf 
    102102 
     
    140140 
    141141def random(): 
    142     import numpy as np 
    143142    # copied from bcc_paracrystal 
    144143    radius = 10**np.random.uniform(1.3, 4) 
  • sasmodels/models/sphere.py

    r97d89af r2d81cfe  
    4343""" 
    4444 
     45import numpy as np 
    4546from numpy import inf 
    4647 
     
    8788 
    8889def random(): 
    89     import numpy as np 
    9090    radius = 10**np.random.uniform(1.3, 4) 
    9191    pars = dict( 
     
    102102    [{"radius": 120., "radius_pd": 0.2, "radius_pd_n":45}, "VR", 1.], 
    103103] 
    104  
    105  
  • sasmodels/models/spherical_sld.py

    rca04add r2d81cfe  
    178178L A Feigin and D I Svergun, Structure Analysis by Small-Angle X-Ray 
    179179and Neutron Scattering, Plenum Press, New York, (1987) 
    180  
    181180""" 
    182181 
  • sasmodels/models/spinodal.py

    r48462b0 r2d81cfe  
    33---------- 
    44 
    5 This model calculates the SAS signal of a phase separating solution under spinodal decomposition. 
    6 The scattering intensity $I(q)$ is calculated as 
     5This model calculates the SAS signal of a phase separating solution 
     6under spinodal decomposition. The scattering intensity $I(q)$ is calculated as 
    77 
    88.. math:: 
    99    I(q) = I_{max}\frac{(1+\gamma/2)x^2}{\gamma/2+x^{2+\gamma}}+B 
    1010 
    11 where $x=q/q_0$ and $B$ is a flat background. The characteristic structure length 
    12 scales with the correlation peak at $q_0$. The exponent $\gamma$ is equal to 
    13 $d+1$ with d the dimensionality of the off-critical concentration mixtures. 
    14 A transition to $\gamma=2d$ is seen near the percolation threshold into the 
    15 critical concentration regime. 
     11where $x=q/q_0$ and $B$ is a flat background. The characteristic structure 
     12length scales with the correlation peak at $q_0$. The exponent $\gamma$ is 
     13equal to $d+1$ with d the dimensionality of the off-critical concentration 
     14mixtures. A transition to $\gamma=2d$ is seen near the percolation threshold 
     15into the critical concentration regime. 
    1616 
    1717References 
     
    1919 
    2020H. Furukawa. Dynamics-scaling theory for phase-separating unmixing mixtures: 
    21 Growth rates of droplets and scaling properties of autocorrelation functions. Physica A 123,497 (1984). 
     21Growth rates of droplets and scaling properties of autocorrelation functions. 
     22Physica A 123,497 (1984). 
    2223 
    2324Authorship and Verification 
     
    2930""" 
    3031 
     32import numpy as np 
    3133from numpy import inf, errstate 
    3234 
     
    6870 
    6971def random(): 
    70     import numpy as np 
    7172    pars = dict( 
    7273        scale=10**np.random.uniform(1, 3), 
  • sasmodels/models/squarewell.py

    r8f04da4 r2d81cfe  
    4545 
    4646R V Sharma, K C Sharma, *Physica*, 89A (1977) 213. 
     47""" 
    4748 
    48 """ 
     49import numpy as np 
    4950from numpy import inf 
    5051 
     
    133134 
    134135def random(): 
    135     import numpy as np 
    136136    pars = dict( 
    137137        scale=1, background=0, 
     
    148148tests = [ 
    149149    [{'scale': 1.0, 'background': 0.0, 'radius_effective': 50.0, 
    150       'volfraction': 0.04,'welldepth': 1.5, 'wellwidth': 1.2, 
     150      'volfraction': 0.04, 'welldepth': 1.5, 'wellwidth': 1.2, 
    151151      'radius_effective_pd': 0}, [0.001], [0.97665742]], 
    152152    ] 
    153153# ADDED by: converting from sasview RKH  ON: 16Mar2016 
    154  
  • sasmodels/models/stacked_disks.py

    r110f69c r2d81cfe  
    1010distribution. As such the normalization of this "composite" form factor is 
    1111relative to the individual disk volume, not the volume of the stack of disks. 
    12 This model is appropriate for example for non non exfoliated clay particles such 
    13 as Laponite. 
     12This model is appropriate for example for non non exfoliated clay particles 
     13such as Laponite. 
    1414 
    1515.. figure:: img/stacked_disks_geometry.png 
     
    3232    \Delta \rho_i = \rho_i - \rho_\text{solvent} 
    3333 
    34 and $N$ is the number of individual (single) discs per unit volume, $\alpha$ is 
    35 the angle between the axis of the disc and $q$, and $V_t$ and $V_c$ are the 
     34and $N$ is the number of individual (single) discs per unit volume, $\alpha$ 
     35is the angle between the axis of the disc and $q$, and $V_t$ and $V_c$ are the 
    3636total volume and the core volume of a single disc, respectively, and 
    3737 
     
    110110""" 
    111111 
     112import numpy as np 
    112113from numpy import inf, sin, cos, pi 
    113114 
     
    146147 
    147148def random(): 
    148     import numpy as np 
    149149    radius = 10**np.random.uniform(1, 4.7) 
    150150    total_stack = 10**np.random.uniform(1, 4.7) 
     
    212212      'scale': 0.01, 
    213213      'background': 0.001, 
    214 #     }, 0.001, 5065.12793824],    n_stacking=1 not 5 ? slight change in value here 11jan2017, check other cpu types 
    215 #     }, 0.001, 5075.11570493], 
     214      # n_stacking=1 not 5 ? slight change in value here 11jan2017, 
     215      # check other cpu types 
     216      #}, 0.001, 5065.12793824], 
     217      #}, 0.001, 5075.11570493], 
    216218     }, 0.001, 25325.635693], 
    217219    [{'thick_core': 10.0, 
     
    240242      'scale': 0.01, 
    241243      'background': 0.001, 
    242 #     }, 0.164, 0.0127673597265],    n_stacking=1 not 5 ?  slight change in value here 11jan2017, check other cpu types 
    243 #     }, 0.164, 0.01480812968], 
     244      # n_stacking=1 not 5 ?  slight change in value here 11jan2017, 
     245      # check other cpu types 
     246      #}, 0.164, 0.0127673597265], 
     247      #}, 0.164, 0.01480812968], 
    244248     }, 0.164, 0.0598367986509], 
    245249 
     
    256260      'scale': 0.01, 
    257261      'background': 0.001, 
    258 # second test here was at q=90, changed it to q=5, note I(q) is then just value of flat background 
     262      # second test here was at q=90, changed it to q=5, 
     263      # note I(q) is then just value of flat background 
    259264     }, [0.001, 5.0], [5075.12, 0.001]], 
    260265 
     
    272277      'background': 0.001, 
    273278     }, ([0.4, 0.5]), [0.00105074, 0.00121761]], 
    274 #    [{'thick_core': 10.0, 
    275 #      'thick_layer': 15.0, 
    276 #      'radius': 3000.0, 
    277 #      'n_stacking': 1.0, 
    278 #      'sigma_d': 0.0, 
    279 #      'sld_core': 4.0, 
    280 #      'sld_layer': -0.4, 
    281 #      'sld_solvent': 5.0, 
    282 #      'theta': 90.0, 
    283 #      'phi': 20.0, 
    284 #      'scale': 0.01, 
    285 #      'background': 0.001, 
    286 # 2017-05-18 PAK temporarily suppress output of qx,qy test; j1 is not accurate for large qr 
    287 #     }, (qx, qy), 0.0341738733124], 
    288 #     }, (qx, qy), None], 
     279    #[{'thick_core': 10.0, 
     280    #  'thick_layer': 15.0, 
     281    #  'radius': 3000.0, 
     282    #  'n_stacking': 1.0, 
     283    #  'sigma_d': 0.0, 
     284    #  'sld_core': 4.0, 
     285    #  'sld_layer': -0.4, 
     286    #  'sld_solvent': 5.0, 
     287    #  'theta': 90.0, 
     288    #  'phi': 20.0, 
     289    #  'scale': 0.01, 
     290    #  'background': 0.001, 
     291    # 2017-05-18 PAK temporarily suppress output of qx,qy test; j1 is 
     292    #     not accurate for large qr 
     293    # }, (qx, qy), 0.0341738733124], 
     294    # }, (qx, qy), None], 
    289295 
    290296    [{'thick_core': 10.0, 
  • sasmodels/models/star_polymer.py

    rbef029d r2d81cfe  
    5858""" 
    5959 
     60import numpy as np 
    6061from numpy import inf 
    6162 
     
    8687 
    8788def random(): 
    88     import numpy as np 
    8989    pars = dict( 
    9090        #background=0, 
  • sasmodels/models/stickyhardsphere.py

    r8f04da4 r2d81cfe  
    6868# TODO: refactor so that we pull in the old sansmodels.c_extensions 
    6969 
     70import numpy as np 
    7071from numpy import inf 
    7172 
     
    99100 
    100101def random(): 
    101     import numpy as np 
    102102    pars = dict( 
    103103        scale=1, background=0, 
  • sasmodels/models/surface_fractal.py

    r30b60d2 r2d81cfe  
    3737 
    3838D Mildner and P Hall, *J. Phys. D: Appl. Phys.*, 19 (1986) 1535-1545 
    39  
    4039""" 
    4140 
     41import numpy as np 
    4242from numpy import inf 
    4343 
     
    7878 
    7979def random(): 
    80     import numpy as np 
    8180    radius = 10**np.random.uniform(1, 4) 
    8281    fractal_dim_surf = np.random.uniform(1, 3-1e-6) 
  • sasmodels/models/teubner_strey.py

    r48462b0 r2d81cfe  
    103103 
    104104def random(): 
    105     import numpy as np 
    106105    d = 10**np.random.uniform(1, 4) 
    107106    xi = 10**np.random.uniform(-0.3, 2)*d 
  • sasmodels/models/triaxial_ellipsoid.py

    r31df0c9 r2d81cfe  
    126126""" 
    127127 
     128import numpy as np 
    128129from numpy import inf, sin, cos, pi 
    129130 
     
    174175 
    175176def random(): 
    176     import numpy as np 
    177177    a, b, c = 10**np.random.uniform(1, 4.7, size=3) 
    178178    pars = dict( 
     
    201201qx = q*cos(pi/6.0) 
    202202qy = q*sin(pi/6.0) 
    203 tests = [[{}, 0.05, 24.8839548033], 
    204         [{'theta':80., 'phi':10.}, (qx, qy), 166.712060266 ], 
    205         ] 
     203tests = [ 
     204    [{}, 0.05, 24.8839548033], 
     205    [{'theta':80., 'phi':10.}, (qx, qy), 166.712060266], 
     206    ] 
    206207del qx, qy  # not necessary to delete, but cleaner 
  • sasmodels/models/two_lorentzian.py

    r48462b0 r2d81cfe  
    3434""" 
    3535 
     36import numpy as np 
    3637from numpy import inf, power 
    3738 
     
    9495 
    9596def random(): 
    96     import numpy as np 
    9797    scale = 10**np.random.uniform(0, 4, 2) 
    9898    length = 10**np.random.uniform(1, 4, 2) 
  • sasmodels/models/two_power_law.py

    r48462b0 r2d81cfe  
    4444""" 
    4545 
     46import numpy as np 
    4647from numpy import inf, power, empty, errstate 
    4748 
     
    8889    :return:                    Calculated intensity 
    8990    """ 
    90     result= empty(q.shape, 'd') 
     91    result = empty(q.shape, 'd') 
    9192    index = (q <= crossover) 
    9293    with errstate(divide='ignore'): 
     
    99100 
    100101def random(): 
    101     import numpy as np 
    102102    coefficient_1 = 1 
    103103    crossover = 10**np.random.uniform(-3, -1) 
  • sasmodels/models/unified_power_Rg.py

    r48462b0 r2d81cfe  
    6868 
    6969B Hammouda, *Analysis of the Beaucage model, J. Appl. Cryst.*, (2010), 43, 1474-1478 
    70  
    7170""" 
    7271 
     
    7574import numpy as np 
    7675from numpy import inf, exp, sqrt, errstate 
    77 from scipy.special import erf 
     76from scipy.special import erf, gamma 
    7877 
    7978category = "shape-independent" 
     
    119118 
    120119def random(): 
    121     import numpy as np 
    122     from scipy.special import gamma 
    123120    level = np.minimum(np.random.poisson(0.5) + 1, 6) 
    124121    n = level 
  • sasmodels/models/vesicle.py

    r48462b0 r2d81cfe  
    6363""" 
    6464 
     65import numpy as np 
    6566from numpy import pi, inf 
    6667 
     
    121122 
    122123def random(): 
    123     import numpy as np 
    124124    total_radius = 10**np.random.uniform(1.3, 5) 
    125125    radius = total_radius * np.random.uniform(0, 1) 
  • sasmodels/product.py

    rac60a39 r2d81cfe  
    1616import numpy as np  # type: ignore 
    1717 
    18 from .modelinfo import Parameter, ParameterTable, ModelInfo 
     18from .modelinfo import ParameterTable, ModelInfo 
    1919from .kernel import KernelModel, Kernel 
    2020from .details import make_details, dispersion_mesh 
    2121 
     22# pylint: disable=unused-import 
    2223try: 
    2324    from typing import Tuple 
    2425except ImportError: 
    2526    pass 
     27else: 
     28    from .modelinfo import ParameterSet 
     29# pylint: enable=unused-import 
    2630 
    2731# TODO: make estimates available to constraints 
     
    7680        combined_pars = p_info.random() 
    7781        s_names = set(par.id for par in s_pars.kernel_parameters[1:]) 
    78         s = s_info.random() 
    7982        combined_pars.update((translate_name[k], v) 
    80                     for k, v in s_info.random().items() 
    81                     if k in s_names) 
     83                             for k, v in s_info.random().items() 
     84                             if k in s_names) 
    8285        return combined_pars 
    8386 
  • sasmodels/resolution.py

    r990d8df r2d81cfe  
    55""" 
    66from __future__ import division 
     7 
     8import unittest 
    79 
    810from scipy.special import erf  # type: ignore 
     
    8587 
    8688        # Build weight matrix from calculated q values 
    87         self.weight_matrix = pinhole_resolution(self.q_calc, self.q, 
    88                                 np.maximum(q_width, MINIMUM_RESOLUTION)) 
     89        self.weight_matrix = pinhole_resolution( 
     90            self.q_calc, self.q, np.maximum(q_width, MINIMUM_RESOLUTION)) 
    8991        self.q_calc = abs(self.q_calc) 
    9092 
     
    476478# unit tests 
    477479############################################################################ 
    478 import unittest 
    479  
    480480 
    481481def eval_form(q, form, pars): 
     
    547547            f_at_u = np.interp(u_sub, q_calc, Iq) 
    548548            #print(np.trapz(Iu, w_grid, axis=1)) 
    549             total  = np.trapz(np.trapz(f_at_u, w_grid, axis=1), h_grid[:, 0]) 
     549            total = np.trapz(np.trapz(f_at_u, w_grid, axis=1), h_grid[:, 0]) 
    550550            result[i] = total / (2*h*w) 
    551551            # from scipy.integrate import dblquad 
  • sasmodels/resolution2d.py

    r7e94989 r2d81cfe  
    224224        # Build weight matrix for resolution integration 
    225225        if np.any(qx_width > 0): 
    226             self.weights = resolution.pinhole_resolution(qx_calc, q, 
    227                     np.maximum(qx_width, resolution.MINIMUM_RESOLUTION)) 
     226            self.weights = resolution.pinhole_resolution( 
     227                qx_calc, q, np.maximum(qx_width, resolution.MINIMUM_RESOLUTION)) 
    228228        elif len(qx_calc) == len(q) and np.all(qx_calc == q): 
    229229            self.weights = None 
     
    236236            Iq = resolution.apply_resolution_matrix(self.weights, Iq) 
    237237        return Iq 
    238  
  • sasmodels/rst2html.py

    re65c3ba r2d81cfe  
    249249            view_url_wxapp(url) 
    250250 
    251 if __name__ == "__main__": 
     251def main(): 
    252252    import sys 
    253253    view_help(sys.argv[1], qt=False) 
     254 
     255if __name__ == "__main__": 
     256    main() 
  • sasmodels/sasview_model.py

    re65c3ba r2d81cfe  
    3131from .details import make_kernel_args, dispersion_mesh 
    3232 
     33# pylint: disable=unused-import 
    3334try: 
    34     from typing import Dict, Mapping, Any, Sequence, Tuple, NamedTuple, List, Optional, Union, Callable 
     35    from typing import (Dict, Mapping, Any, Sequence, Tuple, NamedTuple, 
     36                        List, Optional, Union, Callable) 
    3537    from .modelinfo import ModelInfo, Parameter 
    3638    from .kernel import KernelModel 
     
    4244except ImportError: 
    4345    pass 
     46# pylint: enable=unused-import 
    4447 
    4548logger = logging.getLogger(__name__) 
     
    838841    cylinder.setParam('background', 0.) 
    839842    Iq = cylinder.evalDistribution(np.asarray([0.1])) 
    840     assert np.isnan(Iq[0]), "empty distribution fails" 
     843    assert Iq[0] == 0., "empty distribution fails" 
    841844 
    842845def test_model_list(): 
  • sasmodels/weights.py

    r0db85af r2d81cfe  
    225225    """ 
    226226    if disperser == "array": 
    227         raise NotImplementedError("Don't handle arrays through get_weights; use values and weights directly") 
     227        raise NotImplementedError("Don't handle arrays through get_weights;" 
     228                                  " use values and weights directly") 
    228229    cls = MODELS[disperser] 
    229230    obj = cls(n, width, nsigmas) 
     
    245246    import pylab 
    246247 
    247     if any(len(dispersity)>1 for value, dispersity, weights in mesh): 
     248    if any(len(dispersity) > 1 for value, dispersity, weights in mesh): 
    248249        labels = [p.name for p in model_info.parameters.call_parameters] 
    249250        #pylab.interactive(True) 
    250251        pylab.figure() 
    251         for (v,x,w), s in zip(mesh, labels): 
     252        for (v, x, w), s in zip(mesh, labels): 
    252253            if len(x) > 1: 
    253254                pylab.plot(x, w, '-o', label=s) 
Note: See TracChangeset for help on using the changeset viewer.