Changeset 525f3a9 in sasmodels


Ignore:
Timestamp:
Nov 20, 2015 5:58:44 AM (9 years ago)
Author:
smk78
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:
29fc2a3
Parents:
5d80bbf
Message:

Scale & Background removed from model calculation as implicit parameters
in sasmodels models; parameter 'm' changed to 'power'; re-parameterized
with just q and 'power'.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/models/power_law.py

    r8fe0b9b r525f3a9  
    1010.. math:: 
    1111 
    12     I(q) = \text{scale} \cdot q^{-m} + \text{background} 
     12    I(q) = \text{scale} \cdot q^{-power} + \text{background} 
    1313 
    14 Note the minus sign in front of the exponent. The exponent *m*  
    15 should therefore be entered as a **positive** number. 
     14Note the minus sign in front of the exponent. The exponent *power*  
     15should therefore be entered as a **positive** number for fitting. 
    1616 
    1717Also note that unlike many other models, *scale* in this model  
     
    3535description = """\ 
    3636        Evaluates the function 
    37         I(q) = scale * q^(-m) + bkgd 
    38         NB: enter m as a positive number! 
     37        I(q) = scale * q^(-power) + background 
     38        NB: enter power as a positive number! 
    3939        """ 
    4040category = "shape-independent" 
    4141 
    4242#             ["name", "units", default, [lower, upper], "type", "description"], 
    43 parameters = [["scale", "", 1.0, [-inf, inf], "", "Power law scale factor"], 
    44               ["m", "", 4.0, [-inf, inf], "", "Power law exponent"], 
    45               ["bkgd", "", 0.0, [-inf, inf], "", "Background level"]] 
     43parameters = [["power", "", 4.0, [-inf, inf], "", "Power law exponent"]] 
    4644 
    47 def Iq(scale,m,bkgd): 
    48     inten = (scale * q ** m + bkgd) 
     45# NB: Scale and Background are implicit parameters on every model 
     46def Iq(q,power): 
     47    inten = (q**-power) 
    4948    return inten 
    5049Iq.vectorized = True  # Iq accepts an array of Q values 
     
    5554 
    5655demo = dict(scale=1.0, 
    57             m=4.0, 
    58             bkgd=0.0) 
     56            power=4.0, 
     57            background=0.0) 
    5958 
    6059oldname = "PowerLawAbsModel" 
    6160oldpars = dict(scale='scale', 
    62                m='m', 
    63                bkgd='background') 
     61               power='m', 
     62               background='background') 
    6463 
    6564tests = [ 
    66         [ {'scale': 1.0, 'm': 4.0, 'bkgd' : 0.0}, [0.0106939, 0.469418], [7.64644e+07, 20.5949]] 
     65        [ {'scale': 1.0, 'power': 4.0, 'background' : 0.0}, [0.0106939, 0.469418], [7.64644e+07, 20.5949]] 
    6766        ] 
Note: See TracChangeset for help on using the changeset viewer.