Changeset 6871c9e in sasmodels


Ignore:
Timestamp:
Mar 24, 2015 4:05:05 PM (10 years ago)
Author:
Paul Kienzle <pkienzle@…>
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:
42ade62, f1b8c90
Parents:
c210c94
Message:

add slit-smeared ellipsoid test

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/resolution.py

    r7954f5c r6871c9e  
    357357    """ 
    358358    from scipy.integrate import romberg 
     359 
     360    if any(k not in form.info['defaults'] for k in pars.keys()): 
     361        keys = set(form.info['defaults'].keys()) 
     362        extra = set(pars.keys()) - keys 
     363        raise ValueError("bad parameters: [%s] not in [%s]"% 
     364                         (", ".join(sorted(extra)), ", ".join(sorted(keys)))) 
     365 
    359366    _fn = lambda u, q0: eval_form(sqrt(q0**2 + u**2), form, pars) 
    360367    r = [romberg(_fn, 0, delta_qv[0], args=(qi,), 
     
    373380    """ 
    374381    from scipy.integrate import romberg 
     382 
     383    if any(k not in form.info['defaults'] for k in pars.keys()): 
     384        keys = set(form.info['defaults'].keys()) 
     385        extra = set(pars.keys()) - keys 
     386        raise ValueError("bad parameters: [%s] not in [%s]"% 
     387                         (", ".join(sorted(extra)), ", ".join(sorted(keys)))) 
    375388 
    376389    _fn = lambda q, q0, dq: eval_form(q, form, pars)*gaussian(q, q0, dq) 
     
    593606        # TODO: relative error should be lower 
    594607        self.compare(q, output, answer, 0.025) 
     608 
     609    def test_ellipsoid(self): 
     610        """ 
     611        Compare romberg integration for ellipsoid model. 
     612        """ 
     613        from .core import load_model 
     614        pars = { 
     615            'scale':0.05, 
     616            'rpolar':500, 'requatorial':15000, 
     617            'sld':6, 'solvent_sld': 1, 
     618            } 
     619        form = load_model('ellipsoid', dtype='double') 
     620        q = np.logspace(log10(4e-5),log10(2.5e-2), 68) 
     621        delta_qv = [0.117] 
     622        resolution = Slit1D(q, width=delta_qv, height=0) 
     623        answer = romberg_slit_1d(q, delta_qv, form, pars) 
     624        output = resolution.apply(eval_form(resolution.q_calc, form, pars)) 
     625        # TODO: 10% is too much error; use better algorithm 
     626        self.compare(q, output, answer, 0.1) 
    595627 
    596628    #TODO: can sas q spacing be too sparse for the resolution calculation? 
Note: See TracChangeset for help on using the changeset viewer.