Changeset 34d6cab in sasmodels


Ignore:
Timestamp:
Feb 10, 2016 8:11:15 AM (8 years ago)
Author:
wojciech
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:
3eb3312
Parents:
8115d82
Message:

Documnentation and test clean-ups

Location:
sasmodels
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/convert.py

    r0a4628d r34d6cab  
    1010    'broad_peak', 
    1111    'two_lorentzian', 
     12    "two_power_law", 
    1213    'gel_fit', 
    1314    'gauss_lorentz_gel', 
  • sasmodels/models/line.py

    r0a4628d r34d6cab  
    88.. math:: 
    99 
    10     I(q) = A + B*q 
     10    I(q) = A + B \cdot q 
     11 
     12.. note:: 
     13    For 2D plots intensity has different definition than other shape independent models 
     14.. math:: 
     15    I(q) = I(qx) \cdot I(qy) 
    1116 
    1217.. figure:: None 
  • sasmodels/models/two_power_law.py

    r8115d82 r34d6cab  
    1111 
    1212    I(q) = \begin{cases} 
    13     A \pow(qval,-m1) & q <= qc \\ 
    14     C \pow(qval,-m2) & q > qc 
     13    A q^{-m1} + \text{background} & q <= qc \\ 
     14    C q^{-m2} + \text{background} & q > qc 
    1515    \end{cases} 
    1616 
    1717where $qc$ = the location of the crossover from one slope to the other, 
    1818$A$ = the scaling coefficent that sets the overall intensity of the lower Q power law region, 
    19 $m1$ = power law exponent at low Q 
     19$m1$ = power law exponent at low Q, 
    2020$m2$ = power law exponent at high Q 
    2121 
     
    2424 
    2525.. math:: 
    26     C = frac{A}{\pow(qc/-m1)\pow(qc/-m2)} 
     26    C = \frac{A}{qc^{-m1} qc^{-m2}} 
    2727 
    28 ...note 
     28.. note:: 
    2929    Be sure to enter the power law exponents as positive values! 
    3030 
     
    5050from numpy import power 
    5151from numpy import sqrt 
     52from numpy import inf 
    5253 
    5354name = "two_power_law" 
     
    6869# pylint: disable=bad-whitespace, line-too-long 
    6970#            ["name", "units", default, [lower, upper], "type", "description"], 
    70 parameters = [["coef_A",  "",     1.0, [-inf, inf], "", "scaling coefficent in low Q region"], 
    71               ["qc", "1/Ang", 0.04, [0, inf], "", "crossover location"], 
    72               ["power_1",    "",    1.0, [0, inf], "", "power law exponent at low Q"], 
    73               ["power_2",  "",      4.0, [0, inf], "", "power law exponent at high Q"], 
     71parameters = [["coefficent_1",  "",         1.0, [-inf, inf], "", "coefficent A in low Q region"], 
     72              ["crossover",     "1/Ang",    0.04,[0, inf], "", "crossover location"], 
     73              ["power_1",       "",         1.0, [0, inf], "", "power law exponent at low Q"], 
     74              ["power_2",       "",         4.0, [0, inf], "", "power law exponent at high Q"], 
    7475              ] 
    7576# pylint: enable=bad-whitespace, line-too-long 
    7677 
    7778def Iq(q, 
    78        coef_A=1.0, 
    79        qc=0.04, 
     79       coefficent_1=1.0, 
     80       crossover=0.04, 
    8081       power_1=1.0, 
    8182       power_2=4.0, 
     
    8485    """ 
    8586    :param q:                   Input q-value (float or [float, float]) 
    86     :param coef_A:              Scaling coefficent at low Q 
    87     :param qc:                  Crossover location 
     87    :param coefA:               Scaling coefficent at low Q 
     88    :param crossover:           Crossover location 
    8889    :param power_1:             Exponent of power law function at low Q 
    8990    :param power_2:             Exponent of power law function at high Q 
    9091    :return:                    Calculated intensity 
    9192    """ 
     93# pylint: disable=bad-whitespace 
    9294 
    93 # pylint: disable=bad-whitespace 
    94     if(g<=qc): 
    95         intensity = coef_A*power(q,-1.0*power_1) 
     95    if q<=crossover: 
     96        intensity = coefficent_1*power(q,-1.0*power_1) 
    9697    else: 
    97         coef_C = coef_A*power(qc,-1.0*power_1)/power(qc,-1.0*power_2) 
    98         intensity = coef_C*power(q,-1.0*power_2) 
     98        coefficent_2 = coefficent_1*power(crossover,-1.0*power_1)/power(crossover,-1.0*power_2) 
     99        intensity = coefficent_2*power(q,-1.0*power_2) 
    99100 
    100101    return intensity 
    101102 
    102 Iq.vectorized = True  # Iq accepts an array of q values 
    103  
     103Iq.vectorized = False  # Iq accepts an array of q values 
    104104 
    105105def Iqxy(qx, qy, *args): 
     
    113113    return Iq(sqrt(qx**2 + qy**2), *args) 
    114114 
    115 Iqxy.vectorized = True  # Iqxy accepts an array of qx, qy values 
     115Iqxy.vectorized = False  # Iqxy accepts an array of qx, qy values 
    116116 
    117117demo = dict(scale=1, background=0.1, 
    118             coef_A=1, 
    119             qc=0.04, 
     118            coefficent_1=1.0, 
     119            crossover=0.04, 
    120120            power_1=1.0, 
    121121            power_2=4.0) 
    122122 
    123123oldname = "TwoPowerLawModel" 
    124 oldpars = dict(background='background', 
    125                 coef_A='coef_A', 
    126                 qc='qc', 
     124oldpars = dict(coefficent_1='coef_A', 
     125                crossover='qc', 
    127126                power_1='power1', 
    128                 power_2='power2') 
     127                power_2='power2', 
     128                background='background') 
    129129 
    130130tests = [ 
    131131 
    132132    # Accuracy tests based on content in test/utest_extra_models.py 
    133     [{'coeff_A':    1.0, 
    134       'qc':         0.04, 
     133    [{'coefficent_1':     1.0, 
     134      'crossover':  0.04, 
    135135      'power_1':    1.0, 
    136136      'power_2':    4.0, 
    137       'background': 0.1, 
     137      'background': 0.0, 
    138138    }, 0.001, 1000], 
    139139 
    140     [{'coeff_A':    1.0, 
    141       'qc':         0.04, 
     140    [{'coefficent_1':     1.0, 
     141      'crossover':  0.04, 
    142142      'power_1':    1.0, 
    143143      'power_2':    4.0, 
    144       'background': 0.1, 
     144      'background': 0.0, 
    145145    }, 0.150141, 0.125945], 
    146146 
    147     [{'coeff_A':    1.0, 
    148       'qc':         0.04, 
     147    [{'coeffcent_1':    1.0, 
     148      'crossover':  0.04, 
    149149      'power_1':    1.0, 
    150150      'power_2':    4.0, 
    151       'background': 0.1, 
    152     }, [0.442528,0.0], 0.00166884], 
     151      'background': 0.0, 
     152    }, 0.442528, 0.00166884], 
    153153] 
Note: See TracChangeset for help on using the changeset viewer.