Beispiel #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
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
Beispiel #3
0
def radial_symetry_af(background, rs=None, is_fft_shifted=True):
    if rs is None:
        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)

    out = background
    for i in range(0, afnumpy.max(rs) + 1):
        m = (rs == i)
        msum = afnumpy.sum(m)
        if msum > 1:
            out[m] = afnumpy.sum(background[m]) / float(msum)

    return out, rs, None
def radial_symetry_af(background, rs = None, is_fft_shifted = True):
    if rs is None :
        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)
    
    out = background
    for i in range(0, afnumpy.max(rs)+1):
        m     = (rs == i)
        msum  = afnumpy.sum(m)
        if msum > 1 :
            out[m] = afnumpy.sum(background[m]) / float(msum)
    
    return out, rs, None
Beispiel #5
0
def test_max():
    a = afnumpy.random.random((2, 3))
    b = numpy.array(a)
    fassert(afnumpy.max(a), numpy.max(b))
    fassert(afnumpy.max(a, axis=0), numpy.max(b, axis=0))
    fassert(afnumpy.max(a, axis=1), numpy.max(b, axis=1))
Beispiel #6
0
def test_max():
    a = afnumpy.random.random((2,3))
    b = numpy.array(a)
    fassert(afnumpy.max(a), numpy.max(b))
    fassert(afnumpy.max(a,axis=0), numpy.max(b,axis=0))
    fassert(afnumpy.max(a,axis=1), numpy.max(b,axis=1))