Example #1
0
    def test3(self):
        xoff = 30.
        yoff = 40.

        highResCellGrid = np.ones((5, 4))
        highResCellGrid[0, 0] = 0
        highResCellGrid[1, 1] = 0
        highResCellGrid[2, 2] = 0
        highResCellGrid[4, 3] = 0
        xs = np.array(range(4)) + xoff
        ys = np.array(range(5)) + yoff
        hiResAlphaMtx = alphaMtx(xs, ys, highResCellGrid)

        lowresDx = 4
        lowresDy = 5
        cellPoly = g.Polygon(\
                    [[xoff, yoff], [xoff + lowresDx, yoff],\
                    [xoff + lowresDx, yoff + lowresDy], [xoff, yoff + lowresDy]])
        hiResAlphaMtx.polygon = cellPoly

        betaEst = be(cellPoly, hiResAlphaMtx, maxSubSections=100000)

        dr = np.arctan(.5)
        beta = betaEst.computeBeta(dr, .1)

        expbeta = rotatingTestBeta
        self.assertAlmostEqual(expbeta, beta, delta=.0001)
Example #2
0
    def test2(self):
        xoff = 30.
        yoff = 40.

        highResCellGrid = np.ones((5, 4))
        highResCellGrid[0, 0] = 0
        highResCellGrid[1, 1] = 0
        highResCellGrid[2, 2] = 0
        highResCellGrid[4, 3] = 0
        xs = np.array(range(4)) + xoff
        ys = np.array(range(5)) + yoff
        hiResAlphaMtx = alphaMtx(xs, ys, highResCellGrid)

        lowresDx = 4
        lowresDy = 5
        cellPoly = g.Polygon(\
                    [[xoff, yoff], [xoff + lowresDx, yoff],\
                    [xoff + lowresDx, yoff + lowresDy], [xoff, yoff + lowresDy]])
        hiResAlphaMtx.polygon = cellPoly

        betaEst = be(cellPoly, hiResAlphaMtx)

        dr = np.pi / 4.
        beta = betaEst.computeBeta(dr, .1)

        expbeta = 0.72105087014725577
        self.assertAlmostEqual(expbeta, beta, delta=.0001)
Example #3
0
    def test1(self):
        xoff = 30.
        yoff = 40.

        highResCellGrid = np.ones((5, 4))
        highResCellGrid[0, 0] = 0
        highResCellGrid[1, 1] = 0
        highResCellGrid[2, 2] = 0
        highResCellGrid[4, 3] = 0
        xs = np.array(range(4)) + xoff
        ys = np.array(range(5)) + yoff
        hiResAlphaMtx = alphaMtx(xs, ys, highResCellGrid)

        lowresDx = 4
        lowresDy = 5
        cellPoly = g.Polygon(\
                    [[xoff, yoff], [xoff + lowresDx, yoff],\
                    [xoff + lowresDx, yoff + lowresDy], [xoff, yoff + lowresDy]])
        hiResAlphaMtx.polygon = cellPoly

        betaEst = be(cellPoly, hiResAlphaMtx)

        dr = 0
        beta = betaEst.computeBeta(dr, .1)

        alpha1 = .8
        alpha2 = .6
        alpha3 = .4
        alpha4 = .2
        expbeta = (alpha1 + alpha2 + alpha3 + alpha4) / 4
        self.assertAlmostEqual(expbeta, beta, delta=.0001)
Example #4
0
    def test_concavePolygon(self):
        xoff = 30.
        yoff = 40.

        highResCellGrid = np.ones((5, 4))
        highResCellGrid[2, 1] = 0
        xs = np.array(range(4)) + xoff
        ys = np.array(range(5)) + yoff
        hiResAlphaMtx = alphaMtx(xs, ys, highResCellGrid)

        lowresDx = 4
        lowresDy = 5
        vrtxxs = np.array([1., 3., 3., 1., 1., 2., 2., 1., 1.]) + xoff
        vrtxys = np.array([1., 1., 4., 4., 2.75, 2.75, 2.25, 2.25, 1.]) + yoff
        cellPolyVrtxs = [[c[0], c[1]] for c in zip(vrtxxs, vrtxys)]

        cellPoly = g.Polygon(cellPolyVrtxs)
        hiResAlphaMtx.polygon = cellPoly

        betaEst = be(cellPoly, hiResAlphaMtx)

        dr = np.arctan(.5)
        beta = betaEst.computeBeta(dr, .1)

        expbeta = 0.67258992805755391
        self.assertAlmostEqual(expbeta, beta, delta=.0001)
Example #5
0
    def test_forthQuarter(self):
        xoff = 30.
        yoff = 40.

        highResCellGrid = np.ones((5, 4))
        highResCellGrid[0, 0] = 0
        highResCellGrid[1, 1] = 0
        highResCellGrid[2, 2] = 0
        highResCellGrid[4, 3] = 0
        highResCellGrid = highResCellGrid.transpose()
        highResCellGrid = highResCellGrid[:, ::-1]
        xs = np.array(range(5)) + xoff
        ys = np.array(range(4)) + yoff
        hiResAlphaMtx = alphaMtx(xs, ys, highResCellGrid)

        lowresDx = 5
        lowresDy = 4
        cellPoly = g.Polygon(\
                    [[xoff, yoff], [xoff + lowresDx, yoff],\
                    [xoff + lowresDx, yoff + lowresDy], [xoff, yoff + lowresDy]])
        hiResAlphaMtx.polygon = cellPoly

        betaEst = be(cellPoly, hiResAlphaMtx)

        dr = np.arctan(-2.) + np.pi
        beta = betaEst.computeBeta(dr, .1)

        expbeta = rotatingTestBeta
        self.assertAlmostEqual(expbeta, beta, delta=.0001)