Beispiel #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
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
Beispiel #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)
def imag(a):
    '''Imaginary part of input'''
    return _asarray(a).imag
def real(a):
    '''Real part of input'''
    return _asarray(a).real
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()))
Beispiel #7
0
def imag(a):
    '''Imaginary part of input'''
    return _asarray(a).imag
Beispiel #8
0
def real(a):
    '''Real part of input'''
    return _asarray(a).real
Beispiel #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()))