def testDefaultNames(self):
     """Test reading without renaming
     """
     task = ReadTextCatalogTask()
     arr = task.run(TextPath)
     self.assertTrue(np.array_equal(arr, self.arr))
     self.assertEqual(len(arr), 2)
 def testDefaultNames(self):
     """Test reading without renaming
     """
     task = ReadTextCatalogTask()
     arr = task.run(TextPath)
     self.assertTrue(np.array_equal(arr, self.arr))
     self.assertEqual(len(arr), 2)
 def testTooFewColumnNames(self):
     """Test that too few names in config.colnames causes an error"""
     config = ReadTextCatalogTask.ConfigClass()
     for badColNames in (
         ["name", "ra", "dec", "counts", "flux"],
         ["name"],
     ):
         config.colnames = badColNames
         config.header_lines = 1
         task = ReadTextCatalogTask(config=config)
         with self.assertRaises(ValueError):
             task.run(TextPath)
 def testTooFewColumnNames(self):
     """Test that too few names in config.colnames causes an error"""
     config = ReadTextCatalogTask.ConfigClass()
     for badColNames in (
         ["name", "ra", "dec", "counts", "flux"],
         ["name"],
     ):
         config.colnames = badColNames
         config.header_lines = 1
         task = ReadTextCatalogTask(config=config)
         with self.assertRaises(ValueError):
             task.run(TextPath)
 def testGivenNames(self):
     """Test reading with column names in the config
     """
     colnames = ("id", "ra_deg", "dec_deg", "total_counts", "total_flux", "is_resolved")
     config = ReadTextCatalogTask.ConfigClass()
     config.colnames = colnames
     config.header_lines = 1
     task = ReadTextCatalogTask(config=config)
     arr = task.run(TextPath)
     self.assertEqual(arr.dtype.names, colnames)
     self.assertEqual(len(arr), 2)
     for inname, outname in zip(self.arr.dtype.names, colnames):
         self.assertTrue(np.array_equal(self.arr[inname], arr[outname]))
 def testGivenNames(self):
     """Test reading with column names in the config
     """
     colnames = ("id", "ra_deg", "dec_deg", "total_counts", "total_flux",
                 "is_resolved")
     config = ReadTextCatalogTask.ConfigClass()
     config.colnames = colnames
     config.header_lines = 1
     task = ReadTextCatalogTask(config=config)
     arr = task.run(TextPath)
     self.assertEqual(arr.dtype.names, colnames)
     self.assertEqual(len(arr), 2)
     for inname, outname in zip(self.arr.dtype.names, colnames):
         self.assertTrue(np.array_equal(self.arr[inname], arr[outname]))
    def setUp(self):
        np.random.seed(10)

        self.log = lsst.log.Log.getLogger("TestIngestIndexManager")
        self.config = ingestIndexTestBase.makeIngestIndexConfig(withRaDecErr=True)
        self.config.id_name = 'id'
        depth = 2  # very small depth, for as few pixels as possible.
        self.indexer = HtmIndexer(depth)
        self.htm = lsst.sphgeom.HtmPixelization(depth)
        ingester = IngestIndexedReferenceTask(self.config)
        dtype = [('id', '<f8'), ('ra', '<f8'), ('dec', '<f8'), ('ra_err', '<f8'), ('dec_err', '<f8'),
                 ('a', '<f8'), ('a_err', '<f8')]
        self.schema, self.key_map = ingester.makeSchema(dtype)
        self.fileReader = ReadTextCatalogTask()

        self.fakeInput = self.makeSkyCatalog(outPath=None, size=5, idStart=6543)
        self.matchedPixels = np.array([1, 1, 2, 2, 3])
        self.path = tempfile.mkdtemp()
        self.filenames = {x: os.path.join(self.path, "%d.fits" % x) for x in set(self.matchedPixels)}

        self.worker = IngestIndexManager(self.filenames,
                                         self.config,
                                         self.fileReader,
                                         self.indexer,
                                         self.schema,
                                         self.key_map,
                                         self.htm.universe()[0],
                                         addRefCatMetadata,
                                         self.log)
 def testBadPath(self):
     """Test that an invalid path causes an error"""
     task = ReadTextCatalogTask()
     badPath = "does/not/exists.garbage"
     with self.assertRaises(IOError):
         task.run(badPath)
示例#9
0
from lsst.meas.algorithms.readTextCatalogTask import ReadTextCatalogTask
task = ReadTextCatalogTask()
catalogArray = task.run("exxtable.csv")



 def testBadPath(self):
     """Test that an invalid path causes an error"""
     task = ReadTextCatalogTask()
     badPath = "does/not/exists.garbage"
     with self.assertRaises(IOError):
         task.run(badPath)