예제 #1
0
def radial_symetry_af2(background, inds=None, tots=None, is_fft_shifted=True):
    if (inds is None) or (tots is None):
        print('initialising...')
        i = np.fft.fftfreq(background.shape[0]) * background.shape[0]
        j = np.fft.fftfreq(background.shape[1]) * background.shape[1]
        k = np.fft.fftfreq(background.shape[2]) * background.shape[2]
        i, j, k = np.meshgrid(i, j, k, indexing='ij')
        rs = np.rint(np.sqrt(i**2 + j**2 + k**2)).astype(np.int)

        if is_fft_shifted is False:
            rs = np.fft.fftshift(rs)
        rs = afnumpy.array(rs.ravel())

        # store a list of indexes and totals
        inds = []
        tots = []
        for i in range(0, afnumpy.max(rs) + 1):
            m = (rs == i)
            j = afnumpy.where(m)
            inds.append(j)
            tots.append(afnumpy.float(afnumpy.sum(m)))

    out = background.ravel()
    for ind, tot in zip(inds[:5], tots[:5]):
        out[ind] = 2.
        #a = afnumpy.sum(background[ind])
        #out[ind] = afnumpy.sum(background[ind]) #/ tot

    return out, inds, tots
예제 #2
0
def radial_symetry_af2(background, inds = None, tots = None, is_fft_shifted = True):
    if (inds is None) or (tots is None) :
        print 'initialising...'
        i = np.fft.fftfreq(background.shape[0]) * background.shape[0]
        j = np.fft.fftfreq(background.shape[1]) * background.shape[1]
        k = np.fft.fftfreq(background.shape[2]) * background.shape[2]
        i, j, k = np.meshgrid(i, j, k, indexing='ij')
        rs      = np.rint(np.sqrt(i**2 + j**2 + k**2)).astype(np.int)
        
        if is_fft_shifted is False :
            rs = np.fft.fftshift(rs)
        rs = afnumpy.array(rs.ravel())
        
        # store a list of indexes and totals
        inds = []
        tots = []
        for i in range(0, afnumpy.max(rs)+1):
            m = (rs == i)
            j = afnumpy.where(m)
            inds.append(j)
            tots.append(afnumpy.float(afnumpy.sum(m)))
    
    out = background.ravel()
    for ind, tot in zip(inds[:5], tots[:5]) :
        out[ind] = 2.
        #a = afnumpy.sum(background[ind])
        #out[ind] = afnumpy.sum(background[ind]) #/ tot
    
    return out, inds, tots
예제 #3
0
def test_dtypes():
    a = afnumpy.random.random((2, 3))
    b = numpy.array(a)
    fassert(afnumpy.int32(a), numpy.int32(b))
    fassert(afnumpy.complex64(a), numpy.complex64(b))
    assert (afnumpy.float(a.sum()), numpy.float(b.sum()))
    fassert(afnumpy.complex64(b), numpy.complex64(a))
    assert (type(afnumpy.complex64(b)), afnumpy.ndarray)
    assert (type(afnumpy.complex64([1, 2, 3])), afnumpy.ndarray)
    assert (type(afnumpy.bool8(True)), numpy.bool_)
예제 #4
0
def test_dtypes():
    a = afnumpy.random.random((2,3))
    b = numpy.array(a)
    fassert(afnumpy.int32(a), numpy.int32(b))
    fassert(afnumpy.complex64(a), numpy.complex64(b))
    assert(afnumpy.float(a.sum()), numpy.float(b.sum()))
    fassert(afnumpy.complex64(b), numpy.complex64(a))
    assert(type(afnumpy.complex64(b)), afnumpy.multiarray.ndarray)
    assert(type(afnumpy.complex64([1,2,3])), afnumpy.multiarray.ndarray)
    assert(type(afnumpy.bool8(True)), numpy.bool_)
예제 #5
0
파일: test_core.py 프로젝트: daurer/afnumpy
def test_dtypes():
    a = afnumpy.random.random((2,3))
    b = numpy.array(a)
    fassert(afnumpy.int32(a), numpy.int32(b))
    fassert(afnumpy.complex64(a), numpy.complex64(b))
    assert(afnumpy.float(a.sum()), numpy.float(b.sum()))