Changeset 55e82f0 in sasmodels


Ignore:
Timestamp:
Sep 12, 2018 3:13:27 PM (6 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master
Children:
01dba26
Parents:
d0fdba2
Message:

add some weights examples and update docs

Location:
example/weights
Files:
3 added
1 edited

Legend:

Unmodified
Added
Removed
  • example/weights/cyclic_gaussian.py

    r36873d1 r55e82f0  
    77    r""" 
    88    Cyclic gaussian dispersion on orientation. 
    9      
     9 
    1010    .. math: 
    1111 
     
    1313 
    1414    This provides a close match to the gaussian distribution for 
    15     low angles (with $\sin \theta \approx \theta$), but the tails  
    16     are limited to $\pm 90^\circ$.  For $\sigma$ large the 
    17     distribution is approximately uniform.  The usual polar coordinate 
     15    low angles, but the tails are limited to $\pm 90^\circ$.  For $\sigma$ 
     16    large the distribution is approximately uniform.  The usual polar coordinate 
    1817    projection applies, with $\theta$ weights scaled by $\cos \theta$ 
    1918    and $\phi$ weights unscaled. 
    2019 
    21     This is closely related to a Maier-Saupe distribution with order 
    22     parameter $P_2$ and appropriate scaling constants, and changes 
    23     between $\sin$ and $\cos$ as appropriate for the coordinate system 
    24     representation. 
     20    This is eqivalent to a Maier-Saupe distribution with order 
     21    parameter $P_2 = 1/(2 \sigma^2)$, with $\sigma$ in radians. 
    2522    """ 
    2623    type = "cyclic_gaussian" 
     
    2926    # Note: center is always zero for orientation distributions 
    3027    def _weights(self, center, sigma, lb, ub): 
    31         # Convert sigma in degrees to the approximately equivalent Maier-Saupe "a" 
     28        # Convert sigma in degrees to radians 
    3229        sigma = radians(sigma) 
    33         a = -0.5/sigma**2 
    3430 
    35         # Limit width to +/-90 degrees; use an open interval since the 
    36         # pattern at +90 is the same as that at -90. 
     31        # Limit width to +/- 90 degrees 
    3732        width = min(self.nsigmas*sigma, pi/2) 
    38         x = np.linspace(-width, width, self.npts+2)[1:-1] 
     33        x = np.linspace(-width, width, self.npts) 
     34 
     35        # Truncate the distribution in case the parameter value is limited 
     36        x[(x >= radians(lb)) & (x <= radians(ub))] 
    3937 
    4038        # Return orientation in degrees with Maier-Saupe weights 
    41         return degrees(x), exp(a*sin(x)**2) 
    42  
     39        return degrees(x), exp(-0.5*sin(x)**2/sigma**2) 
Note: See TracChangeset for help on using the changeset viewer.