コード例 #1
0
 def testTransform(self):
     """Test `ApertureFluxTransform` with a synthetic catalog.
     """
     FluxTransformTestCase.testTransform(self, [
         ApertureFluxAlgorithm.makeFieldPrefix(self.name, r)
         for r in self.control.radii
     ])
コード例 #2
0
 def testForcedPlugin(self):
     baseName = "base_CircularApertureFlux"
     algMetadata = lsst.daf.base.PropertyList()
     task = self.makeForcedMeasurementTask(baseName, algMetadata=algMetadata)
     radii = algMetadata.get("%s_radii" % (baseName,))
     measWcs = self.dataset.makePerturbedWcs(self.dataset.exposure.getWcs())
     measDataset = self.dataset.transform(measWcs)
     exposure, truthCatalog = measDataset.realize(10.0, measDataset.makeMinimalSchema())
     refCat = self.dataset.catalog
     refWcs = self.dataset.exposure.getWcs()
     measCat = task.generateMeasCat(exposure, refCat, refWcs)
     task.attachTransformedFootprints(measCat, refCat, exposure, refWcs)
     task.run(measCat, exposure, refCat, refWcs)
     for measRecord, truthRecord in zip(measCat, truthCatalog):
         # Centroid tolerances set to ~ single precision epsilon
         self.assertFloatsAlmostEqual(measRecord.get("slot_Centroid_x"),
                                      truthRecord.get("truth_x"), rtol=1E-7)
         self.assertFloatsAlmostEqual(measRecord.get("slot_Centroid_y"),
                                      truthRecord.get("truth_y"), rtol=1E-7)
         for n, radius in enumerate(radii):
             prefix = ApertureFluxAlgorithm.makeFieldPrefix(baseName, radius)
             self.assertFalse(measRecord.get(measRecord.schema.join(prefix, "flag")))
             # CircularApertureFlux isn't designed to do a good job in forced mode, because it doesn't
             # account for changes in the PSF or changes in the WCS.  Hence, this is really just a
             # test to make sure the values are reasonable and that it runs with no unexpected errors.
             self.assertFloatsAlmostEqual(measRecord.get(measRecord.schema.join(prefix, "flux")),
                                          truthCatalog.get("truth_flux"), rtol=1.0)
             self.assertLess(measRecord.get(measRecord.schema.join(prefix, "fluxSigma")), (n+1)*150.0)
コード例 #3
0
 def testForcedPlugin(self):
     baseName = "base_CircularApertureFlux"
     algMetadata = lsst.daf.base.PropertyList()
     task = self.makeForcedMeasurementTask(baseName, algMetadata=algMetadata)
     radii = algMetadata.get("%s_radii" % baseName)
     measWcs = self.dataset.makePerturbedWcs(self.dataset.exposure.getWcs())
     measDataset = self.dataset.transform(measWcs)
     exposure, truthCatalog = measDataset.realize(10.0, measDataset.makeMinimalSchema())
     refCat = self.dataset.catalog
     refWcs = self.dataset.exposure.getWcs()
     measCat = task.generateMeasCat(exposure, refCat, refWcs)
     task.attachTransformedFootprints(measCat, refCat, exposure, refWcs)
     s = task.run(measCat, exposure, refCat, refWcs)
     for measRecord, truthRecord in zip(measCat, truthCatalog):
         # Centroid tolerances set to ~ single precision epsilon
         self.assertClose(measRecord.get("slot_Centroid_x"), truthRecord.get("truth_x"), rtol=1E-7)
         self.assertClose(measRecord.get("slot_Centroid_y"), truthRecord.get("truth_y"), rtol=1E-7)
         for n, radius in enumerate(radii):
             prefix = ApertureFluxAlgorithm.makeFieldPrefix(baseName, radius)
             self.assertFalse(measRecord.get(measRecord.schema.join(prefix, "flag")))
             # CircularApertureFlux isn't designed to do a good job in forced mode, because it doesn't
             # account for changes in the PSF or changes in the WCS.  Hence, this is really just a
             # test to make sure the values are reasonable and that it runs with no unexpected errors.
             self.assertClose(measRecord.get(measRecord.schema.join(prefix, "flux")),
                              truthCatalog.get("truth_flux"), rtol=1.0)
             self.assertLess(measRecord.get(measRecord.schema.join(prefix, "fluxSigma")), (n+1)*150.0)
コード例 #4
0
ファイル: test_ApertureFlux.py プロジェクト: lsst/meas_base
 def testSingleFramePlugin(self):
     baseName = "base_CircularApertureFlux"
     config = self.makeSingleFrameMeasurementConfig(baseName)
     config.plugins[baseName].maxSincRadius = 20
     ctrl = config.plugins[baseName].makeControl()
     algMetadata = lsst.daf.base.PropertyList()
     task = self.makeSingleFrameMeasurementTask(config=config, algMetadata=algMetadata)
     exposure, catalog = self.dataset.realize(10.0, task.schema, randomSeed=0)
     task.run(catalog, exposure)
     radii = algMetadata.getArray("%s_radii" % (baseName,))
     self.assertEqual(list(radii), list(ctrl.radii))
     for record in catalog:
         lastFlux = 0.0
         lastFluxErr = 0.0
         for n, radius in enumerate(radii):
             # Test that the flags are what we expect
             prefix = ApertureFluxAlgorithm.makeFieldPrefix(baseName, radius)
             if radius <= ctrl.maxSincRadius:
                 self.assertFalse(record.get(record.schema.join(prefix, "flag")))
                 self.assertFalse(record.get(record.schema.join(prefix, "flag_apertureTruncated")))
                 self.assertEqual(
                     record.get(record.schema.join(prefix, "flag_sincCoeffsTruncated")),
                     radius > 12
                 )
             else:
                 self.assertTrue(record.schema.join(prefix, "flag_sincCoeffsTruncated")
                                 not in record.getSchema())
                 self.assertEqual(record.get(record.schema.join(prefix, "flag")), radius > 50)
                 self.assertEqual(record.get(record.schema.join(prefix, "flag_apertureTruncated")),
                                  radius > 50)
             # Test that the instFluxes and uncertainties increase as we
             # increase the apertures, or that they match the true instFlux
             # within 3 sigma.  This is just a test as to whether the
             # values are reasonable.  As to whether the values are exactly
             # correct, we rely on the tests on ApertureFluxAlgorithm's
             # static methods, as the way the plugins code calls that is
             # extremely simple, so if the results we get are reasonable,
             # it's hard to imagine how they could be incorrect if
             # ApertureFluxAlgorithm's tests are valid.
             currentFlux = record.get(record.schema.join(prefix, "instFlux"))
             currentFluxErr = record.get(record.schema.join(prefix, "instFluxErr"))
             if not record.get(record.schema.join(prefix, "flag")):
                 self.assertTrue(currentFlux > lastFlux or
                                 (record.get("truth_instFlux") - currentFlux) < 3*currentFluxErr)
                 self.assertGreater(currentFluxErr, lastFluxErr)
                 lastFlux = currentFlux
                 lastFluxErr = currentFluxErr
             else:
                 self.assertTrue(np.isnan(currentFlux))
                 self.assertTrue(np.isnan(currentFluxErr))
         # When measuring an isolated point source with a sufficiently
         # large aperture, we should recover the known input instFlux.
         if record.get("truth_isStar") and record.get("parent") == 0:
             self.assertFloatsAlmostEqual(record.get("base_CircularApertureFlux_25_0_instFlux"),
                                          record.get("truth_instFlux"), rtol=0.02)
コード例 #5
0
 def testSingleFramePlugin(self):
     baseName = "base_CircularApertureFlux"
     config = self.makeSingleFrameMeasurementConfig(baseName)
     config.plugins[baseName].maxSincRadius = 20
     ctrl = config.plugins[baseName].makeControl()
     algMetadata = lsst.daf.base.PropertyList()
     task = self.makeSingleFrameMeasurementTask(config=config, algMetadata=algMetadata)
     exposure, catalog = self.dataset.realize(10.0, task.schema)
     task.run(catalog, exposure)
     radii = algMetadata.get("%s_radii" % (baseName,))
     self.assertEqual(list(radii), list(ctrl.radii))
     for record in catalog:
         lastFlux = 0.0
         lastFluxSigma = 0.0
         for n, radius in enumerate(radii):
             # Test that the flags are what we expect
             prefix = ApertureFluxAlgorithm.makeFieldPrefix(baseName, radius)
             if radius <= ctrl.maxSincRadius:
                 self.assertFalse(record.get(record.schema.join(prefix, "flag")))
                 self.assertFalse(record.get(record.schema.join(prefix, "flag_apertureTruncated")))
                 self.assertEqual(
                     record.get(record.schema.join(prefix, "flag_sincCoeffsTruncated")),
                     radius > 12
                 )
             else:
                 self.assertTrue(record.schema.join(prefix, "flag_sincCoeffsTruncated")
                                 not in record.getSchema())
                 self.assertEqual(record.get(record.schema.join(prefix, "flag")), radius > 50)
                 self.assertEqual(record.get(record.schema.join(prefix, "flag_apertureTruncated")),
                                  radius > 50)
             # Test that the fluxes and uncertainties increase as we increase the apertures, or that
             # they match the true flux within 3 sigma.  This is just a test as to whether the values
             # are reasonable.  As to whether the values are exactly correct, we rely on the tests on
             # ApertureFluxAlgorithm's static methods, as the way the plugins code calls that is
             # extremely simple, so if the results we get are reasonable, it's hard to imagine
             # how they could be incorrect if ApertureFluxAlgorithm's tests are valid.
             currentFlux = record.get(record.schema.join(prefix, "flux"))
             currentFluxSigma = record.get(record.schema.join(prefix, "fluxSigma"))
             if not record.get(record.schema.join(prefix, "flag")):
                 self.assertTrue(currentFlux > lastFlux or
                                 (record.get("truth_flux") - currentFlux) < 3*currentFluxSigma)
                 self.assertGreater(currentFluxSigma, lastFluxSigma)
                 lastFlux = currentFlux
                 lastFluxSigma = currentFluxSigma
             else:
                 self.assertTrue(np.isnan(currentFlux))
                 self.assertTrue(np.isnan(currentFluxSigma))
         # When measuring an isolated point source with a sufficiently large aperture, we should
         # recover the known input flux.
         if record.get("truth_isStar") and record.get("parent") == 0:
             self.assertFloatsAlmostEqual(record.get("base_CircularApertureFlux_25_0_flux"),
                                          record.get("truth_flux"), rtol=0.02)
コード例 #6
0
 def testTransform(self):
     """Demonstrate application of the ApertureFluxTransform to a synthetic SourceCatalog."""
     FluxTransformTestCase.testTransform(self, [ApertureFluxAlgorithm.makeFieldPrefix(self.name, r)
                                                for r in self.control.radii])
コード例 #7
0
 def testTransform(self):
     """Demonstrate application of the ApertureFluxTransform to a synthetic SourceCatalog."""
     FluxTransformTestCase.testTransform(self,
         [ApertureFluxAlgorithm.makeFieldPrefix(self.name, r) for r in self.control.radii])
コード例 #8
0
ファイル: test_ApertureFlux.py プロジェクト: lsst/meas_base
 def testTransform(self):
     """Test `ApertureFluxTransform` with a synthetic catalog.
     """
     FluxTransformTestCase.testTransform(self, [ApertureFluxAlgorithm.makeFieldPrefix(self.name, r)
                                                for r in self.control.radii])