Changeset ea75043 in sasmodels for sasmodels/resolution.py


Ignore:
Timestamp:
Mar 29, 2016 8:22:13 PM (8 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:
d6f5da6
Parents:
1d61d07
Message:

add support for oriented usans using direct 2d resolution integral

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/resolution.py

    r8b935d1 rea75043  
    8282        self.q_calc = (pinhole_extend_q(q, q_width, nsigma=nsigma) 
    8383                       if q_calc is None else np.sort(q_calc)) 
    84         self.weight_matrix = pinhole_resolution( 
    85             self.q_calc, self.q, np.maximum(q_width, MINIMUM_RESOLUTION)) 
     84        self.weight_matrix = pinhole_resolution(self.q_calc, self.q, 
     85                                np.maximum(q_width, MINIMUM_RESOLUTION)) 
    8686 
    8787    def apply(self, theory): 
     
    9191class Slit1D(Resolution): 
    9292    """ 
    93     Slit aperture with a complicated resolution function. 
     93    Slit aperture with resolution function. 
    9494 
    9595    *q* points at which the data is measured. 
    9696 
    97     *qx_width* slit width 
    98  
    99     *qy_height* slit height 
     97    *dqx* slit width in qx 
     98 
     99    *dqy* slit height in qy 
    100100 
    101101    *q_calc* is the list of points to calculate, or None if this should 
     
    104104    The *weight_matrix* is computed by :func:`slit1d_resolution` 
    105105    """ 
    106     def __init__(self, q, width, height=0., q_calc=None): 
    107         # Remember what width/height was used even though we won't need them 
     106    def __init__(self, q, qx_width, qy_width=0., q_calc=None): 
     107        # Remember what width/dqy was used even though we won't need them 
    108108        # after the weight matrix is constructed 
    109         self.width, self.height = width, height 
     109        self.qx_width, self.qy_width = qx_width, qy_width 
    110110 
    111111        # Allow independent resolution on each point even though it is not 
    112112        # needed in practice. 
    113         if np.isscalar(width): 
    114             width = np.ones(len(q))*width 
     113        if np.isscalar(qx_width): 
     114            qx_width = np.ones(len(q))*qx_width 
    115115        else: 
    116             width = np.asarray(width) 
    117         if np.isscalar(height): 
    118             height = np.ones(len(q))*height 
     116            qx_width = np.asarray(qx_width) 
     117        if np.isscalar(qy_width): 
     118            qy_width = np.ones(len(q))*qy_width 
    119119        else: 
    120             height = np.asarray(height) 
     120            qy_width = np.asarray(qy_width) 
    121121 
    122122        self.q = q.flatten() 
    123         self.q_calc = slit_extend_q(q, width, height) \ 
     123        self.q_calc = slit_extend_q(q, qx_width, qy_width) \ 
    124124            if q_calc is None else np.sort(q_calc) 
    125125        self.weight_matrix = \ 
    126             slit_resolution(self.q_calc, self.q, width, height) 
     126            slit_resolution(self.q_calc, self.q, qx_width, qy_width) 
    127127 
    128128    def apply(self, theory): 
     
    396396    """ 
    397397    q = np.sort(q) 
    398     if q_min < q[0]: 
     398    if q_min + 2*MINIMUM_RESOLUTION < q[0]: 
    399399        if q_min <= 0: q_min = q_min*MIN_Q_SCALE_FOR_NEGATIVE_Q_EXTRAPOLATION 
    400400        n_low = np.ceil((q[0]-q_min) / (q[1]-q[0])) if q[1] > q[0] else 15 
     
    402402    else: 
    403403        q_low = [] 
    404     if q_max > q[-1]: 
     404    if q_max - 2*MINIMUM_RESOLUTION > q[-1]: 
    405405        n_high = np.ceil((q_max-q[-1]) / (q[-1]-q[-2])) if q[-1] > q[-2] else 15 
    406406        q_high = np.linspace(q[-1], q_max, n_high+1)[1:] 
     
    595595        Slit smearing with perfect resolution. 
    596596        """ 
    597         resolution = Slit1D(self.x, width=0, height=0, q_calc=self.x) 
     597        resolution = Slit1D(self.x, qx_width=0, qy_width=0, q_calc=self.x) 
    598598        theory = self.Iq(resolution.q_calc) 
    599599        output = resolution.apply(theory) 
     
    605605        Slit smearing with height 0.005 
    606606        """ 
    607         resolution = Slit1D(self.x, width=0, height=0.005, q_calc=self.x) 
     607        resolution = Slit1D(self.x, qx_width=0, qy_width=0.005, q_calc=self.x) 
    608608        theory = self.Iq(resolution.q_calc) 
    609609        output = resolution.apply(theory) 
     
    620620        """ 
    621621        q = np.logspace(-4, -1, 10) 
    622         resolution = Slit1D(q, width=0.2, height=np.inf) 
     622        resolution = Slit1D(q, qx_width=0.2, qy_width=np.inf) 
    623623        theory = 1000*self.Iq(resolution.q_calc**4) 
    624624        output = resolution.apply(theory) 
     
    634634        Slit smearing with width 0.0002 
    635635        """ 
    636         resolution = Slit1D(self.x, width=0.0002, height=0, q_calc=self.x) 
     636        resolution = Slit1D(self.x, qx_width=0.0002, qy_width=0, q_calc=self.x) 
    637637        theory = self.Iq(resolution.q_calc) 
    638638        output = resolution.apply(theory) 
     
    647647        Slit smearing with width > 100*height. 
    648648        """ 
    649         resolution = Slit1D(self.x, width=0.0002, height=0.000001, 
     649        resolution = Slit1D(self.x, qx_width=0.0002, qy_width=0.000001, 
    650650                            q_calc=self.x) 
    651651        theory = self.Iq(resolution.q_calc) 
     
    772772        data = np.loadtxt(data_string.split('\n')).T 
    773773        q, delta_qv, _, answer = data 
    774         resolution = Slit1D(q, width=delta_qv, height=0) 
     774        resolution = Slit1D(q, qx_width=delta_qv, qy_width=0) 
    775775        output = self._eval_sphere(pars, resolution) 
    776776        # TODO: eliminate Igor test since it is too inaccurate to be useful. 
     
    792792        q_calc = slit_extend_q(interpolate(q, 2*np.pi/radius/20), 
    793793                               delta_qv[0], 0.) 
    794         resolution = Slit1D(q, width=delta_qv, height=0, q_calc=q_calc) 
     794        resolution = Slit1D(q, qx_width=delta_qv, qy_width=0, q_calc=q_calc) 
    795795        output = self._eval_sphere(pars, resolution) 
    796796        # TODO: relative error should be lower 
     
    810810        q = np.logspace(log10(4e-5), log10(2.5e-2), 68) 
    811811        width, height = 0.117, 0. 
    812         resolution = Slit1D(q, width=width, height=height) 
     812        resolution = Slit1D(q, qx_width=width, qy_width=height) 
    813813        answer = romberg_slit_1d(q, width, height, form, pars) 
    814814        output = resolution.apply(eval_form(resolution.q_calc, form, pars)) 
     
    10671067 
    10681068    if isinstance(resolution, Slit1D): 
    1069         width, height = resolution.width, resolution.height 
     1069        width, height = resolution.dqx, resolution.dqy 
    10701070        Iq_romb = romberg_slit_1d(resolution.q, width, height, model, pars) 
    10711071    else: 
Note: See TracChangeset for help on using the changeset viewer.