示例#1
0
def test_polar_vectors_numexpr():
    """ Check that the the version with numexpr generates the same output """
    for nn in range(5):
        for mm in range(-1*nn,nn+1):
            if (nn%2==0 and abs(mm)%2==0) or (nn%2==1 and abs(mm)%2==1):
                res0 = fsh.polar_basis_L(r,nn,mm, beta)*np.exp(-1j*th*mm)
                res1 = sh.polarDimBasis(nn,mm, beta)(r,th)
                yield assert_allclose, res0, res1, 1e-7, 1e-9
示例#2
0
def genPolarBasisFuncs(beta,nmax,phi,fourier=False):
    """Generate a list of basis functions
    beta: characteristic size of the shapelets (b_major, b_minor)
    nmax: maximum decomposition order
    phi: rotation angle
    fourier: return a FOurer transformed version of the basis functions
    """
    bfs=[]
    if type(nmax) is int: nmax=[nmax,nmax]
    for nn in range(nmax[0]):
        for mm in np.arange(-1*nn,nn+1):
            if (nn%2==0 and mm%2==0) or (nn%2==1 and mm%2==1):
                bfs.append(shapelet.polarDimBasis(nn,mm,beta=beta,phi=phi,fourier=fourier))
    return bfs
示例#3
0
文件: decomp.py 项目: rth/shapelets
def genPolarBasisMatrix(beta,nmax,r,th):
    """Generate the n x k matrix of basis functions(k) for each pixel(n)
    beta: characteristic size of the shaeplets
    nmax: maximum decomposition order
    r: radius matrix of n pixels
    th: theta matrix of n pixels
    """
    bvals=[]
    for nn in range(nmax):
        for mm in np.arange(-1*nn,nn+1):
            if (nn%2==0 and mm%2==0) or (nn%2==1 and mm%2==1):
                bf=shapelet.polarDimBasis(nn,mm,beta=beta)
                bvals.append(shapelet.computeBasisPolar(bf,r,th).flatten())
    bm=np.array(bvals)
    return bm.transpose()
示例#4
0
def genPolarBasisMatrix(beta,nmax,phi,r,th,fourier=False):
    """Generate the n x k matrix of basis functions(k) for each pixel(n)
    beta: characteristic size of the shapelets (b_major, b_minor)
    nmax: maximum decomposition order
    phi: rotation angle
    r: radius matrix of n pixels
    th: theta matrix of n pixels
    fourier: return a FOurer transformed version of the basis functions
    """
    bvals=[]
    if type(nmax) is int: nmax=[nmax,nmax]
    for nn in range(nmax[0]):
        for mm in np.arange(-1*nn,nn+1):
            if (nn%2==0 and mm%2==0) or (nn%2==1 and mm%2==1):
                bf=shapelet.polarDimBasis(nn,mm,beta=beta,phi=phi,fourier=fourier)
                bvals.append(shapelet.computeBasisPolar(bf,r,th).flatten())
    bm=np.array(bvals)
    return bm.transpose()
示例#5
0
def genPolarBasisFuncs(beta, nmax, phi, fourier=False):
    """Generate a list of basis functions
    beta: characteristic size of the shapelets (b_major, b_minor)
    nmax: maximum decomposition order
    phi: rotation angle
    fourier: return a FOurer transformed version of the basis functions
    """
    bfs = []
    if type(nmax) is int: nmax = [nmax, nmax]
    for nn in range(nmax[0]):
        for mm in np.arange(-1 * nn, nn + 1):
            if (nn % 2 == 0 and mm % 2 == 0) or (nn % 2 == 1 and mm % 2 == 1):
                bfs.append(
                    shapelet.polarDimBasis(nn,
                                           mm,
                                           beta=beta,
                                           phi=phi,
                                           fourier=fourier))
    return bfs
示例#6
0
def genPolarBasisMatrix(beta, nmax, phi, r, th, fourier=False):
    """Generate the n x k matrix of basis functions(k) for each pixel(n)
    beta: characteristic size of the shapelets (b_major, b_minor)
    nmax: maximum decomposition order
    phi: rotation angle
    r: radius matrix of n pixels
    th: theta matrix of n pixels
    fourier: return a FOurer transformed version of the basis functions
    """
    bvals = []
    if type(nmax) is int: nmax = [nmax, nmax]
    for nn in range(nmax[0]):
        for mm in np.arange(-1 * nn, nn + 1):
            if (nn % 2 == 0 and mm % 2 == 0) or (nn % 2 == 1 and mm % 2 == 1):
                bf = shapelet.polarDimBasis(nn,
                                            mm,
                                            beta=beta,
                                            phi=phi,
                                            fourier=fourier)
                bvals.append(shapelet.computeBasisPolar(bf, r, th).flatten())
    bm = np.array(bvals)
    return bm.transpose()