Ejemplo n.º 1
0
    def testLocate(self):
        chunker = Chunker(0, 50, 5)
        result_chunk = chunker.locate((0.25, 0.25))
        self.assertEqual(result_chunk, 2500)

        result_chunk = chunker.locate((30.0, 0.0))
        self.assertEqual(result_chunk, 2408)

        result_chunk = chunker.locate((0.0, -20.0))
        self.assertEqual(result_chunk, 1900)

        # south pole
        result_chunks = chunker.getChunksAround(0, 0.017)
        self.assertEqual(result_chunks, [0, 100, 101, 102, 103, 104])

        # north pole
        result_chunks = chunker.getChunksAround(4900, 0.017)
        self.assertEqual(result_chunks, [4800, 4801, 4802, 4803, 4804, 4900])

        # first chunk of a stripe
        result_chunks = chunker.getChunksAround(2600, 0.017)
        self.assertEqual(result_chunks,
                         [2500, 2501, 2598, 2600, 2601, 2698, 2700, 2797])

        # mid stripe chunk
        result_chunks = chunker.getChunksAround(1621, 0.017)
        self.assertEqual(result_chunks,
                         [1519, 1520, 1620, 1621, 1622, 1721, 1722])
Ejemplo n.º 2
0
    def testLocate(self):
        chunker = Chunker(0, 50, 5)
        result_chunk = chunker.locate((0.25, 0.25))
        self.assertEqual(result_chunk, 2500)

        result_chunk = chunker.locate((30.0, 0.0))
        self.assertEqual(result_chunk, 2408)

        result_chunk = chunker.locate((0.0, -20.0))
        self.assertEqual(result_chunk, 1900)
Ejemplo n.º 3
0
    def testCcdVisitHpix8(self):
        filters = "ugrizy"
        num_ccd_visits = 10
        cell_id = 2500
        chunker = Chunker(0, num_stripes, num_substripes)
        ccdVisitGenerator = columns.CcdVisitGenerator(chunker,
                                                      num_ccd_visits,
                                                      filters=filters)
        hpix8_values = ccdVisitGenerator._find_hpix8_in_cell(cell_id)
        print(hpix8_values)
        self.assertTrue(len(hpix8_values) > 0)

        nside = healpy.order2nside(8)
        chunks = [
            chunker.locate(healpy.pix2ang(nside, pixel, nest=True,
                                          lonlat=True))
            for pixel in hpix8_values
        ]
        hpix_centers_in_chunk = np.array(chunks) == cell_id
        # Some of the hpix centers will be outside of the chunk area, and that seems ok.
        # The test is to confirm that we get enough of them with centers inside the
        # chunk to confirm that the code is working.
        print(chunks)
        self.assertGreaterEqual(
            np.sum(hpix_centers_in_chunk) / float(len(hpix8_values)), 0.5)