示例#1
0
def interp(x, xp, fp, left=None, right=None):
    '''Linearly interpolate'''
    x = _asarray(x)
        
    xp = _asarray(xp)
    fp = _asarray(fp)
    if left is None:
        left = fp[0]
    if right is None:
        right = fp[-1]
    r = _asarray(_maths.interpolate(xp._jdataset(), fp._jdataset(), x._jdataset(), left, right))
    if x.ndim == 0:
        return r.item()
    return r
示例#2
0
def interp(x, xp, fp, left=None, right=None):
    '''Linearly interpolate'''
    x = _asarray(x)
        
    xp = _asarray(xp)
    fp = _asarray(fp)
    if left is None:
        left = fp[0]
    if right is None:
        right = fp[-1]
    r = _asarray(_maths.interpolate(xp._jdataset(), fp._jdataset(), x._jdataset(), left, right))
    if x.ndim == 0:
        return r.item()
    return r
示例#3
0
def histogram(a, bins=10, range=None, normed=False, weights=None, density=None): #@ReservedAssignment
    '''Histogram of input'''
    if normed or weights or density:
        raise ValueError, "Option not supported yet"

    if isinstance(bins, str):
        raise ValueError, "bin string option not supported yet"

    h = None
    if range is None:
        if not isinstance(bins, int):
            bins = _asarray(bins)._jdataset()
        h = _histo(bins)
    elif len(range) != 2:
        raise ValueError, "Need two values in range"
    else:
        h = _histo(bins, range[0], range[1])

    if not isinstance(a, _ds):
        a = _asarray(a)._jdataset()
    return h.value(a)
示例#4
0
def imag(a):
    '''Imaginary part of input'''
    return _asarray(a).imag
示例#5
0
def real(a):
    '''Real part of input'''
    return _asarray(a).real
示例#6
0
def roots(p):
    '''Roots of polynomial'''
#     from uk.ac.diamond.scisoft.analysis.fitting.functions import Polynomial as _poly
    pa = _asarray(p, dtype=_f64)
    return _asarray(_poly.findRoots(pa._jdataset().getBuffer()))
示例#7
0
def imag(a):
    '''Imaginary part of input'''
    return _asarray(a).imag
示例#8
0
def real(a):
    '''Real part of input'''
    return _asarray(a).real
示例#9
0
def roots(p):
    '''Roots of polynomial'''
    from uk.ac.diamond.scisoft.analysis.fitting.functions import Polynomial as _poly
    pa = _asarray(p, dtype=_f64)
    return _asarray(_poly.findRoots(pa._jdataset().getBuffer()))