Example #1
0
def reflectivity_amplitude(Q,
                           depth,
                           rho,
                           mu=0,
                           sigma=None,
                           wavelength=1,
                           ):
    """
    Returns the complex reflectivity waveform.

    See reflectivity for details.
    """
    Q = _dense(Q,'d')
    R = numpy.empty(Q.shape,'D')

    n = len(depth)
    if numpy.isscalar(wavelength):
        wavelength=wavelength*numpy.ones(Q.shape, 'd')
    if numpy.isscalar(mu):
        mu = mu*numpy.ones(n, 'd')
    if numpy.isscalar(sigma):
        sigma = sigma*numpy.ones(n-1, 'd')

    wavelength,depth,rho,mu = [_dense(v,'d')
                                 for v in wavelength,depth,rho,mu]

    rho,mu = [v*1e-6 for v in rho,mu]
    if sigma is not None:
        sigma = _dense(sigma, 'd')
        reflmodule._reflectivity_amplitude_rough(rho, mu, depth, sigma, wavelength, Q, R)
    else:
        reflmodule._reflectivity_amplitude (rho, mu, depth, wavelength, Q, R)
    return R
Example #2
0
def magnetic_amplitude(Q,
                       depth,
                       rho,
                       mu=0,
                       wavelength=1,
                       rho_m=0,
                       theta_m=0,
                       Aguide=-90.0):
    """
    Returns the complex magnetic reflectivity waveform.

    See magnetic_reflectivity for details.
    """
    Q = _dense(Q, 'd')
    n = len(depth)
    if np.isscalar(wavelength):
        wavelength = wavelength * np.ones(Q.shape, 'd')
    if np.isscalar(mu):
        mu = mu * np.ones(n, 'd')
    if np.isscalar(rho_m):
        rho_m = rho_m * np.ones(n, 'd')
    if np.isscalar(theta_m):
        theta_m = theta_m * np.ones(n, 'd')

    depth, rho, mu, rho_m, wavelength, theta_m = [
        _dense(a, 'd') for a in (depth, rho, mu, rho_m, wavelength, theta_m)
    ]
    R1, R2, R3, R4 = [np.empty(Q.shape, 'D') for pol in (1, 2, 3, 4)]
    expth = cos(theta_m * pi / 180.0) + 1j * sin(theta_m * pi / 180.0)

    rho, mu, rho_m = [v * 1e-6 for v in (rho, mu, rho_m)]
    reflmodule._magnetic_amplitude(rho, mu, depth, wavelength, rho_m, expth,
                                   Aguide, Q, R1, R2, R3, R4)
    return R1, R2, R3, R4
Example #3
0
def convolve(Qi,Ri,Q,dQ):
    """
    Return convolution R[k] of width dQ[k] at points Q[k].
    """
    R = numpy.empty(Q.shape,'d')
    reflmodule._convolve(_dense(Qi,'d'),_dense(Ri,'d'),
                         _dense(Q,'d'),_dense(dQ,'d'),R)
    return R
Example #4
0
def convolve(Qi, Ri, Q, dQ):
    """
    Return convolution R[k] of width dQ[k] at points Q[k].
    """
    R = np.empty(Q.shape, 'd')
    reflmodule._convolve(_dense(Qi, 'd'), _dense(Ri, 'd'), _dense(Q, 'd'),
                         _dense(dQ, 'd'), R)
    return R
Example #5
0
File: data.py Project: RONNCC/bumps
def convolve(xi,yi,x,dx):
    """
    Apply x-dependent resolution function to the theory.

    Returns convolution y[k] of width dx[k] at points x[k].
    """
    from bumpsmodule import _convolve
    y = numpy.empty(x.shape, 'd')
    _convolve(_dense(xi), _dense(yi), _dense(x), _dense(dx), y)
    return y
Example #6
0
def varyingres(wavelength,dLoL,dToT,Q):
    """
    Return resolution dQ for varying slits.

    Angular divergence dT/T is (s1+s2)/d/theta(Q(s1,s2)).
    """
    dQ = numpy.empty(Q.shape,'d')
    reflmodule._varyingres(wavelength,dLoL,dToT,_dense(Q,'d'),dQ)
    return dQ
Example #7
0
def varyingres(wavelength, dLoL, dToT, Q):
    """
    Return resolution dQ for varying slits.

    Angular divergence dT/T is (s1+s2)/d/theta(Q(s1, s2)).
    """
    dQ = np.empty(Q.shape, 'd')
    reflmodule._varyingres(wavelength, dLoL, dToT, _dense(Q, 'd'), dQ)
    return dQ
Example #8
0
def _c_erf(x):
    """
    Error function calculator.
    """
    from ._reduction import _erf
    input = _dense(x, 'd')
    output = np.empty_like(input)
    _erf(input, output)
    return output
Example #9
0
def _c_erf(x):
    """
    Error function calculator.
    """
    from ._reduction import _erf
    input = _dense(x, 'd')
    output = np.empty_like(input)
    _erf(input, output)
    return output
Example #10
0
File: util.py Project: RONNCC/bumps
def erf(x):
    """
    Error function calculator.
    """
    from bumpsmodule import _erf

    input = _dense(x, "d")
    output = numpy.empty_like(input)
    _erf(input, output)
    return output
Example #11
0
def fixedres(wavelength,dLoL,dT,Q):
    """
    Return resolution dQ for fixed slits.


    Angular divergence dT is (s1+s2)/d, where d is the distance
    between the slits and s1,s2 is the slit openings.  Slits and
    distances should use the same units.
    """
    dQ = numpy.empty(Q.shape,'d')
    reflmodule._fixedres(wavelength,dLoL,dT,_dense(Q,'d'),dQ)
    return dQ
Example #12
0
def fixedres(wavelength, dLoL, dT, Q):
    """
    Return resolution dQ for fixed slits.


    Angular divergence dT is (s1+s2)/d, where d is the distance
    between the slits and s1, s2 is the slit openings.  Slits and
    distances should use the same units.
    """
    dQ = np.empty(Q.shape, 'd')
    reflmodule._fixedres(wavelength, dLoL, dT, _dense(Q, 'd'), dQ)
    return dQ
Example #13
0
def magnetic_amplitude(kz,
                       depth,
                       rho,
                       irho=0,
                       rhoM=0,
                       thetaM=0,
                       sigma=0,
                       Aguide=-90.0,
                       rho_index=None,
                       ):
    """
    Returns the complex magnetic reflectivity waveform.

    See :class:`magnetic_reflectivity <refl1d.reflectivity.magnetic_reflectivity>` for details.
    """
    kz = _dense(kz,'d')
    if rho_index == None:
        rho_index = numpy.zeros(kz.shape,'i')
    else:
        rho_index = _dense(rho_index, 'i')
    n = len(depth)
    if numpy.isscalar(irho):
        irho = irho*numpy.ones(n, 'd')
    if numpy.isscalar(rhoM):
        rhoM = rhoM*numpy.ones(n, 'd')
    if numpy.isscalar(thetaM):
        thetaM = thetaM*numpy.ones(n, 'd')
    if numpy.isscalar(sigma):
        sigma = sigma*numpy.ones(n-1, 'd')

    depth, rho, irho, rho_m, thetaM, sigma \
        = [_dense(a,'d') for a in (depth, rho, irho, rhoM, thetaM, sigma)]
    expth = cos(thetaM * pi/180.0) + 1j*sin(thetaM * pi/180.0)
    #rho,irho,rho_m = [v*1e-6 for v in rho,irho,rho_m]
    R1,R2,R3,R4 = [numpy.empty(kz.shape,'D') for pol in (1,2,3,4)]
    reflmodule._magnetic_amplitude(depth, sigma, rho, irho,
                                   rhoM,  expth, Aguide, kz, rho_index,
                                   R1, R2, R3, R4
                                   )
    return R1,R2,R3,R4
Example #14
0
def reflectivity_amplitude(kz=None,
                           depth=None,
                           rho=None,
                           irho=0,
                           sigma=0,
                           rho_index=None,
                           ):
    r"""
    Calculate reflectivity amplitude $r(k_z)$ from slab model.

    :Parameters :
        *depth* : float[N] | |Ang|
            Thickness of the individual layers (incident and substrate
            depths are ignored)
        *sigma* = 0 : float OR float[N-1] | |Ang|
            Interface roughness between the current layer and the next.
            The final layer is ignored.  This may be a scalar for fixed
            roughness on every layer, or None if there is no roughness.
        *rho*, *irho* = 0: float[N] OR float[N,K] | |1e-6/Ang^2|
            Real and imaginary scattering length density.  Use multiple
            columns when you have kz-dependent scattering length densities,
            and set *rho_index* to select amongst them.  Data should be
            stored in column order.
        *kz* : float[M] | |1/Ang|
            Points at which to evaluate the reflectivity
        *rho_index* = 0 : integer[M]
            *rho* and *irho* columns to use for the various kz.

    :Returns:
        *r* | complex[M]
            Complex reflectivity waveform.

    This function does not compute any instrument resolution corrections.
    """
    kz = _dense(kz, 'd')
    if rho_index == None:
        rho_index = numpy.zeros(kz.shape,'i')
    else:
        rho_index = _dense(rho_index, 'i')

    depth = _dense(depth, 'd')
    if numpy.isscalar(sigma):
        sigma = sigma*numpy.ones(len(depth)-1, 'd')
    else:
        sigma = _dense(sigma, 'd')
    rho = _dense(rho, 'd')
    if numpy.isscalar(irho):
        irho = irho * numpy.ones_like(rho)
    else:
        irho = _dense(irho, 'd')

    #print depth.shape,rho.shape,irho.shape,sigma.shape
    #print depth.dtype,rho.dtype,irho.dtype,sigma.dtype
    r = numpy.empty(kz.shape,'D')
    #print "amplitude",depth,rho,kz,rho_index
    #print depth.shape, sigma.shape, rho.shape, irho.shape, kz.shape
    reflmodule._reflectivity_amplitude(depth, sigma, rho, irho, kz,
                                       rho_index, r)
    return r
Example #15
0
def magnetic_amplitude(Q,
                       depth,
                       rho,
                       mu=0,
                       wavelength=1,
                       rho_m=0,
                       theta_m=0,
                       Aguide=-90.0
                       ):
    """
    Returns the complex magnetic reflectivity waveform.

    See magnetic_reflectivity for details.
    """
    Q = _dense(Q,'d')
    n = len(depth)
    if numpy.isscalar(wavelength):
        wavelength=wavelength*numpy.ones(Q.shape, 'd')
    if numpy.isscalar(mu):
        mu = mu*numpy.ones(n, 'd')
    if numpy.isscalar(rho_m):
        rho_m = rho_m*numpy.ones(n, 'd')
    if numpy.isscalar(theta_m):
        theta_m = theta_m*numpy.ones(n, 'd')

    depth,rho,mu,rho_m,wavelength,theta_m \
        = [_dense(a,'d') for a in depth, rho, mu,
           rho_m, wavelength, theta_m]
    R1,R2,R3,R4 = [numpy.empty(Q.shape,'D') for pol in 1,2,3,4]
    expth = cos(theta_m * pi/180.0) + 1j*sin(theta_m * pi/180.0)

    rho,mu,rho_m = [v*1e-6 for v in rho,mu,rho_m]
    reflmodule._magnetic_amplitude(rho, mu, depth, wavelength,
                                   rho_m,  expth, Aguide, Q,
                                   R1, R2, R3, R4
                                   )
    return R1,R2,R3,R4
Example #16
0
def reflectivity_amplitude(
    Q,
    depth,
    rho,
    mu=0,
    sigma=None,
    wavelength=1,
):
    """
    Returns the complex reflectivity waveform.

    See reflectivity for details.
    """
    Q = _dense(Q, 'd')
    R = np.empty(Q.shape, 'D')

    n = len(depth)
    if np.isscalar(wavelength):
        wavelength = wavelength * np.ones(Q.shape, 'd')
    if np.isscalar(mu):
        mu = mu * np.ones(n, 'd')
    if np.isscalar(sigma):
        sigma = sigma * np.ones(n - 1, 'd')

    wavelength, depth, rho, mu = [
        _dense(v, 'd') for v in (wavelength, depth, rho, mu)
    ]

    rho, mu = [v * 1e-6 for v in (rho, mu)]
    if sigma is not None:
        sigma = _dense(sigma, 'd')
        reflmodule._reflectivity_amplitude_rough(rho, mu, depth, sigma,
                                                 wavelength, Q, R)
    else:
        reflmodule._reflectivity_amplitude(rho, mu, depth, wavelength, Q, R)
    return R