Changeset 7e1d090 in sasmodels


Ignore:
Timestamp:
Feb 18, 2016 5:23:36 AM (9 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:
cfc254e
Parents:
e66075f
Message:

Final touches on Two Power Law model

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/models/two_power_law.py

    rbdb3313 r7e1d090  
    3939.. figure:: img/two_power_law_1d.jpg 
    4040 
    41     1D plot using the default values (w/500 data point). 
     41    1D plot using the default values (with 500 data point). 
    4242 
    4343References 
     
    7171#            ["name", "units", default, [lower, upper], "type", "description"], 
    7272parameters = [["coefficent_1",  "",         1.0, [-inf, inf], "", "coefficent A in low Q region"], 
    73               ["crossover",     "1/Ang",    0.04,[0, inf], "", "crossover location"], 
    74               ["power_1",       "",         1.0, [0, inf], "", "power law exponent at low Q"], 
    75               ["power_2",       "",         4.0, [0, inf], "", "power law exponent at high Q"], 
    76               ] 
     73              ["crossover",     "1/Ang",    0.04,[0, inf],    "", "crossover location"], 
     74              ["power_1",       "",         1.0, [0, inf],    "", "power law exponent at low Q"], 
     75              ["power_2",       "",         4.0, [0, inf],    "", "power law exponent at high Q"], 
     76             ] 
    7777# pylint: enable=bad-whitespace, line-too-long 
     78 
    7879 
    7980def Iq(q, 
     
    8283       power_1=1.0, 
    8384       power_2=4.0, 
    84        ): 
     85      ): 
    8586 
    8687    """ 
    8788    :param q:                   Input q-value (float or [float, float]) 
    88     :param coefA:               Scaling coefficent at low Q 
     89    :param coefficent_1:        Scaling coefficent at low Q 
    8990    :param crossover:           Crossover location 
    9091    :param power_1:             Exponent of power law function at low Q 
     
    9293    :return:                    Calculated intensity 
    9394    """ 
    94 # pylint: disable=bad-whitespace 
    9595 
    9696    #Two sub vectors are created to treat crossover values 
    97     q_lower = q[q<=crossover] 
    98     q_upper = q[q>crossover] 
    99     coefficent_2 = coefficent_1*power(crossover,-1.0*power_1)/power(crossover,-1.0*power_2) 
    100     intensity_lower = coefficent_1*power(q_lower,-1.0*power_1) 
    101     intensity_upper = coefficent_2*power(q_upper,-1.0*power_2) 
    102     intensity = concatenate( ( intensity_lower,intensity_upper ), axis=0) 
     97    q_lower = q[q <= crossover] 
     98    q_upper = q[q > crossover] 
     99    coefficent_2 = coefficent_1*power(crossover, -1.0*power_1)/power(crossover, -1.0*power_2) 
     100    intensity_lower = coefficent_1*power(q_lower, -1.0*power_1) 
     101    intensity_upper = coefficent_2*power(q_upper, -1.0*power_2) 
     102    intensity = concatenate((intensity_lower, intensity_upper), axis=0) 
    103103 
    104104    return intensity 
     
    118118Iqxy.vectorized = True  # Iqxy accepts an array of qx, qy values 
    119119 
    120 demo = dict(scale=1, background=0.1, 
     120demo = dict(scale=1, background=0.0, 
    121121            coefficent_1=1.0, 
    122122            crossover=0.04, 
     
    126126oldname = "TwoPowerLawModel" 
    127127oldpars = dict(coefficent_1='coef_A', 
    128                 crossover='qc', 
    129                 power_1='power1', 
    130                 power_2='power2', 
    131                 background='background') 
     128               crossover='qc', 
     129               power_1='power1', 
     130               power_2='power2', 
     131               background='background') 
    132132 
    133133tests = [ 
    134  
    135134    # Accuracy tests based on content in test/utest_extra_models.py 
    136135    [{'coefficent_1':     1.0, 
     
    139138      'power_2':    4.0, 
    140139      'background': 0.0, 
    141     }, 0.001, 1000], 
     140     }, 0.001, 1000], 
    142141 
    143142    [{'coefficent_1':     1.0, 
     
    146145      'power_2':    4.0, 
    147146      'background': 0.0, 
    148     }, 0.150141, 0.125945], 
     147     }, 0.150141, 0.125945], 
    149148 
    150149    [{'coeffcent_1':    1.0, 
     
    153152      'power_2':    4.0, 
    154153      'background': 0.0, 
    155     }, 0.442528, 0.00166884], 
     154     }, 0.442528, 0.00166884], 
    156155 
    157156    [{'coeffcent_1':    1.0, 
     
    160159      'power_2':    4.0, 
    161160      'background': 0.0, 
    162     }, (0.442528, 0.00166884), 0.00166884], 
     161     }, (0.442528, 0.00166884), 0.00166884], 
    163162 
    164163] 
Note: See TracChangeset for help on using the changeset viewer.