Changeset 5c962df in sasmodels for sasmodels/weights.py


Ignore:
Timestamp:
Jan 30, 2016 11:02:03 PM (8 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, core_shell_microgels, costrafo411, magnetic_model, release_v0.94, release_v0.95, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
3a45c2c
Parents:
5925e90
Message:

delint

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/weights.py

    r823e620 r5c962df  
    2222 
    2323    def get_pars(self): 
     24        """ 
     25        Return the parameters to the disperser as a dictionary. 
     26        """ 
    2427        pars = {'type': self.type} 
    2528        pars.update(self.__dict__) 
     
    2831    # pylint: disable=no-self-use 
    2932    def set_weights(self, values, weights): 
     33        """ 
     34        Set the weights on the disperser if it is :class:`ArrayDispersion`. 
     35        """ 
    3036        raise RuntimeError("set_weights is only available for ArrayDispersion") 
    3137 
     
    6369 
    6470class GaussianDispersion(Dispersion): 
     71    r""" 
     72    Gaussian dispersion, with 1-\ $\sigma$ width. 
     73 
     74    .. math:: 
     75 
     76        w = \exp\left(-\tfrac12 (x - c)^2/\sigma^2\right) 
     77    """ 
    6578    type = "gaussian" 
    6679    default = dict(npts=35, width=0, nsigmas=3) 
     
    7285 
    7386class RectangleDispersion(Dispersion): 
     87    r""" 
     88    Uniform dispersion, with width $\sqrt{3}\sigma$. 
     89 
     90    .. math:: 
     91 
     92        w = 1 
     93    """ 
    7494    type = "rectangle" 
    7595    default = dict(npts=35, width=0, nsigmas=1.70325) 
     
    81101 
    82102class LogNormalDispersion(Dispersion): 
     103    r""" 
     104    log Gaussian dispersion, with 1-\ $\sigma$ width. 
     105 
     106    .. math:: 
     107 
     108        w = \frac{\exp\left(-\tfrac12 (\ln x - c)^2/\sigma^2\right)}{x\sigma} 
     109    """ 
    83110    type = "lognormal" 
    84111    default = dict(npts=80, width=0, nsigmas=8) 
    85112    def _weights(self, center, sigma, lb, ub): 
    86113        x = self._linspace(center, sigma, max(lb, 1e-8), max(ub, 1e-8)) 
    87         px = np.exp(-0.5*(np.log(x)-center)**2)/sigma**2/(x*sigma) 
     114        px = np.exp(-0.5*(np.log(x)-center)**2/sigma**2)/(x*sigma) 
    88115        return x, px 
    89116 
    90117 
    91118class SchulzDispersion(Dispersion): 
     119    r""" 
     120    Schultz dispersion, with 1-\ $\sigma$ width. 
     121 
     122    .. math:: 
     123 
     124        w = \frac{z^z\,R^{z-1}}{e^{Rz}\,c \Gamma(z)} 
     125 
     126    where $c$ is the center of the distribution, $R = x/c$ and $z=(c/\sigma)^2$. 
     127 
     128    This is evaluated using logarithms as 
     129 
     130    .. math:: 
     131 
     132        w = \exp\left(z \ln z + (z-1)\ln R - Rz - \ln c - \ln \Gamma(z) \right) 
     133    """ 
    92134    type = "schulz" 
    93135    default = dict(npts=80, width=0, nsigmas=8) 
     
    102144 
    103145class ArrayDispersion(Dispersion): 
     146    r""" 
     147    Empirical dispersion curve. 
     148 
     149    Use :meth:`set_weights` to set $w = f(x)$. 
     150    """ 
    104151    type = "array" 
    105152    default = dict(npts=35, width=0, nsigmas=1) 
     
    110157 
    111158    def set_weights(self, values, weights): 
     159        """ 
     160        Set the weights for the given x values. 
     161        """ 
    112162        self.values = np.ascontiguousarray(values, 'd') 
    113163        self.weights = np.ascontiguousarray(weights, 'd') 
Note: See TracChangeset for help on using the changeset viewer.