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)
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)
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])
def testCcdVisitGenerator(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) results = ccdVisitGenerator(cell_id, num_ccd_visits) self.assertEqual(len(results), 4) ccdVisitId, ra_centers, dec_centers, filterName = results self.assertEqual(len(ccdVisitId), len(ra_centers)) self.assertEqual(len(ccdVisitId), len(filterName)) self.assertEqual(len(ccdVisitId), num_ccd_visits) self.assertEqual(len(ccdVisitId), len(set(ccdVisitId)))
import lsst.dax.data_generator.columns as columns from lsst.dax.data_generator import Chunker, UniformSpatialModel # Verify files in ingestCfgs all have correct database name, stripes, and substripes. num_stripes = 340 num_substripes = 3 chunker = Chunker(0, num_stripes, num_substripes) edge_width = 0.0167 # degrees, must be >= overlap spec = { "Object": { "columns": { "objectId": columns.ObjIdGenerator(), "parentObjectId,prv_inputId": columns.PoissonGenerator(mean_val=10, n_columns=2, column_seed=1), "psRa,psRaErr,psDecl,psDeclErr": columns.RaDecGenerator(include_err=True), "psMuRa,psMuRaErr,psMuDecl,psMuDeclErr,psParallax,psParallaxErr": columns.UniformGenerator(n_columns=6, min_val=-5, max_val=5, column_seed=2), "uPsFlux": columns.MagnitudeGenerator(n_mags=1, column_seed=102), "uPsFluxErr": columns.UniformGenerator(min_val=0.05, max_val=0.5, n_columns=1, column_seed=103), "gPsFlux":
# but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. import unittest import tempfile import lsst.dax.distribution.chunklogs as chunklogs import lsst.dax.distribution.chunktracking as chunktracking from lsst.dax.data_generator import Chunker local_chunker = Chunker(0, 50, 5) # Valid chunks for raw='1:1000' with Chunker(0, 50, 5) valid_chunks = set([ 0, 100, 101, 102, 103, 104, 200, 201, 202, 203, 204, 205, 206, 207, 208, 209, 210, 211, 300, 301, 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 420, 421, 422, 423, 500, 501, 502, 503, 504, 505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 525, 526, 527, 528, 529, 600, 601, 602, 603, 604, 605, 606, 607, 608, 609, 610, 611, 612, 613, 614, 615, 616, 617, 618, 619, 620, 621, 622, 623, 624, 625, 626, 627, 628, 629, 630, 631, 632, 633, 634, 635, 700, 701, 702, 703, 704, 705, 706, 707, 708, 709, 710, 711, 712, 713, 714, 715, 716, 717, 718, 719, 720, 721, 722, 723, 724, 725, 726, 727, 728, 729, 730, 731, 732, 733, 734, 735, 736, 737, 738, 739, 740, 741, 800, 801, 802, 803, 804, 805, 806, 807, 808, 809, 810, 811,