Changes in sasmodels/data.py [1a8c11c:d86f0fc] in sasmodels


Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • sasmodels/data.py

    r1a8c11c rd86f0fc  
    3636 
    3737import numpy as np  # type: ignore 
    38 from numpy import sqrt, sin, cos, pi 
    3938 
    4039# pylint: disable=unused-import 
     
    302301 
    303302 
    304 def empty_data1D(q, resolution=0.0, L=0., dL=0.): 
     303def empty_data1D(q, resolution=0.0): 
    305304    # type: (np.ndarray, float) -> Data1D 
    306     r""" 
     305    """ 
    307306    Create empty 1D data using the given *q* as the x value. 
    308307 
    309     rms *resolution* $\Delta q/q$ defaults to 0%.  If wavelength *L* and rms 
    310     wavelength divergence *dL* are defined, then *resolution* defines 
    311     rms $\Delta \theta/\theta$ for the lowest *q*, with $\theta$ derived from 
    312     $q = 4\pi/\lambda \sin(\theta)$. 
     308    *resolution* dq/q defaults to 5%. 
    313309    """ 
    314310 
     
    317313    Iq, dIq = None, None 
    318314    q = np.asarray(q) 
    319     if L != 0 and resolution != 0: 
    320         theta = np.arcsin(q*L/(4*pi)) 
    321         dtheta = theta[0]*resolution 
    322         ## Solving Gaussian error propagation from 
    323         ##   Dq^2 = (dq/dL)^2 DL^2 + (dq/dtheta)^2 Dtheta^2 
    324         ## gives 
    325         ##   (Dq/q)^2 = (DL/L)**2 + (Dtheta/tan(theta))**2 
    326         ## Take the square root and multiply by q, giving 
    327         ##   Dq = (4*pi/L) * sqrt((sin(theta)*dL/L)**2 + (cos(theta)*dtheta)**2) 
    328         dq = (4*pi/L) * sqrt((sin(theta)*dL/L)**2 + (cos(theta)*dtheta)**2) 
    329     else: 
    330         dq = resolution * q 
    331  
    332     data = Data1D(q, Iq, dx=dq, dy=dIq) 
     315    data = Data1D(q, Iq, dx=resolution * q, dy=dIq) 
    333316    data.filename = "fake data" 
    334317    return data 
     
    503486            # Note: masks merge, so any masked theory points will stay masked, 
    504487            # and the data mask will be added to it. 
    505             #mtheory = masked_array(theory, data.mask.copy()) 
    506             theory_x = data.x[~data.mask] 
    507             mtheory = masked_array(theory) 
     488            mtheory = masked_array(theory, data.mask.copy()) 
    508489            mtheory[~np.isfinite(mtheory)] = masked 
    509490            if view is 'log': 
    510491                mtheory[mtheory <= 0] = masked 
    511             plt.plot(theory_x, scale*mtheory, '-') 
     492            plt.plot(data.x, scale*mtheory, '-') 
    512493            all_positive = all_positive and (mtheory > 0).all() 
    513494            some_present = some_present or (mtheory.count() > 0) 
     
    545526 
    546527    if use_resid: 
    547         theory_x = data.x[~data.mask] 
    548         mresid = masked_array(resid) 
     528        mresid = masked_array(resid, data.mask.copy()) 
    549529        mresid[~np.isfinite(mresid)] = masked 
    550530        some_present = (mresid.count() > 0) 
     
    552532        if num_plots > 1: 
    553533            plt.subplot(1, num_plots, use_calc + 2) 
    554         plt.plot(theory_x, mresid, '.') 
     534        plt.plot(data.x, mresid, '.') 
    555535        plt.xlabel("$q$/A$^{-1}$") 
    556536        plt.ylabel('residuals') 
Note: See TracChangeset for help on using the changeset viewer.