Changeset 0542fe1 in sasmodels


Ignore:
Timestamp:
Dec 20, 2016 4:29:22 PM (8 years ago)
Author:
Paul Kienzle <pkienzle@…>
Branches:
master, core_shell_microgels, costrafo411, magnetic_model, ticket-1257-vesicle-product, ticket_1156, ticket_1265_superball, ticket_822_more_unit_tests
Children:
2586093f
Parents:
f1ec7002
Message:

round to the nearest level rather than truncate

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/models/unified_power_Rg.py

    rb3f2a24 r0542fe1  
    8585 
    8686def Iq(q, level, rg, power, B, G): 
    87     ilevel = int(level) 
    88     if ilevel == 0: 
     87    level = int(level + 0.5) 
     88    if level == 0: 
    8989        with errstate(divide='ignore'): 
    9090            return 1./q 
     
    9292    with errstate(divide='ignore', invalid='ignore'): 
    9393        result = np.zeros(q.shape, 'd') 
    94         for i in range(ilevel): 
     94        for i in range(level): 
    9595            exp_now = exp(-(q*rg[i])**2/3.) 
    9696            pow_now = (erf(q*rg[i]/sqrt(6.))**3/q)**power[i] 
    97             if i < ilevel-1: 
     97            if i < level-1: 
    9898                exp_next = exp(-(q*rg[i+1])**2/3.) 
    9999            else: 
     
    101101            result += G[i]*exp_now + B[i]*exp_next*pow_now 
    102102 
    103     result[q == 0] = np.sum(G[:ilevel]) 
     103    result[q == 0] = np.sum(G[:level]) 
    104104    return result 
    105105 
Note: See TracChangeset for help on using the changeset viewer.