예제 #1
0
def main():
    edgeLen = 2 * radPixels + 1
    rMax = float(radPixels)
    transformer = SHTransformer(edgeLen, maxL)

    # baseName = 'block'
    # vId = 5619494
    baseName = 'synth'
    vId = 0
    yamlDict = parseBlock(vId, edgeLen, baseName=baseName)

    sampler = BlockSampler(yamlDict)
    byteCube = sampler.sample(None)
    assert byteCube.shape == (edgeLen, edgeLen, edgeLen), 'wrong size cube'
    doubleCube = np.require(byteCube, dtype=np.double, requirements=['C'])

    zMat = np.outer(np.cos(transformer.thetaglq),
                    np.ones_like(transformer.phiglq))
    xMat = np.outer(np.sin(transformer.thetaglq), np.cos(transformer.phiglq))
    yMat = np.outer(np.sin(transformer.thetaglq), np.sin(transformer.phiglq))
    edgeMat = np.zeros((len(transformer.thetaglq), len(transformer.phiglq)),
                       dtype=np.float64)
    for edge in yamlDict['edges']:
        cosMat = (xMat * edge[0]) + (yMat * edge[1]) + (zMat * edge[2])
        edgeMat += np.power(cosMat, 20.0)

    samples = transformer.calcSphereOfSamples(doubleCube, rMax)
    harmonics = transformer.calcHarmonics(doubleCube, rMax)
    unRotReconSamples = transformer.reconstructSamples(harmonics)
    rotMatrix = psh.djpi2(maxL)
    thetaZ0, thetaY, thetaZ1 = yamlDict['eulerZYZ']
    rotClim = psh.SHRotateRealCoef(harmonics,
                                   np.array([-thetaZ1, -thetaY, -thetaZ0]),
                                   rotMatrix)
    reconHarm = transformer.reconstructSamples(rotClim)

    edgeHarm = psh.SHExpandGLQ(edgeMat, transformer.weights, transformer.nodes)
    rotEdgeHarm = psh.SHRotateRealCoef(edgeHarm,
                                       np.array([-thetaZ1, -thetaY, -thetaZ0]),
                                       rotMatrix)
    rotEdge = transformer.reconstructSamples(rotEdgeHarm)

    plotSphere(transformer.thetaglq,
               transformer.phiglq, {
                   'samples': samples.transpose(),
                   'unrotated': unRotReconSamples.transpose(),
                   'rotated': reconHarm.transpose(),
                   'unrotEdges': edgeMat.transpose(),
                   'rotEdges': rotEdge.transpose()
               },
               fname="%s_%d_spheres.vtk" % (baseName, vId))
예제 #2
0
 def rotateHarmonics(self, harmonics, thetaZ0, thetaY, thetaZ1, maxL=None):
     if maxL is None:
         maxL = self.maxL
     rotMatrix = psh.djpi2(maxL)
     rotHarm = psh.SHRotateRealCoef(harmonics,
                                    np.array([-thetaZ1, -thetaY, -thetaZ0]),
                                    rotMatrix)
     return rotHarm
예제 #3
0
파일: moments.py 프로젝트: bbbales2/mhp
def cubicSymmetry(o):
    angles = ((0.0, 0.0), (0.0, 270.0), (0.0, 180.0), (0.0, 90.0), (90.0, 0.0), (90.0, 270.0), (90.0, 180.0), (90.0, 90.0), (180.0, 0.0), (180.0, 270.0), (180.0, 180.0), (180.0, 90.0))

    totalSPH = numpy.zeros(o.shape)

    for thetaphi in angles:
        theta, phi = numpy.radians(thetaphi)

        totalSPH += pyshtools.SHRotateRealCoef(o, (phi, theta, 0.0), dj)

    return totalSPH
def SHRotations(coeff):

    #---- input parameters ----#
    lmax = 8  #order of the SH
    alpha, beta, gamma = 159., 80., 145.  #angles for rotation

    #--derived parameters --#
    angles = np.radians([alpha, beta, gamma])
    dj_matrix = shtools.djpi2(lmax)

    return shtools.SHRotateRealCoef(coeff, angles, dj_matrix)