Esempio n. 1
0
 def setUp(self):
     self.filters1 = FilterDefinitionCollection(
         FilterDefinition(physical_filter='abc', lambdaEff=123),
         FilterDefinition(physical_filter='def', lambdaEff=456))
     self.filters2 = FilterDefinitionCollection(
         FilterDefinition(physical_filter='abc', lambdaEff=321),
         FilterDefinition(physical_filter='def', lambdaEff=654))
     FilterDefinitionCollection.reset()
Esempio n. 2
0
class TestFilterDefinitionCollection(lsst.utils.tests.TestCase):
    def setUp(self):
        self.filters1 = FilterDefinitionCollection(
            FilterDefinition(physical_filter='abc', lambdaEff=123),
            FilterDefinition(physical_filter='def', lambdaEff=456))
        self.filters2 = FilterDefinitionCollection(
            FilterDefinition(physical_filter='abc', lambdaEff=321),
            FilterDefinition(physical_filter='def', lambdaEff=654))
        FilterDefinitionCollection.reset()

    def test_singleton(self):
        self.filters1.defineFilters()
        self.assertEqual(
            lsst.afw.image.Filter('abc').getFilterProperty().getLambdaEff(),
            123)
        self.assertEqual(
            lsst.afw.image.Filter('def').getFilterProperty().getLambdaEff(),
            456)
        self.filters1.defineFilters()  # this should not change anything
        self.assertEqual(
            lsst.afw.image.Filter('abc').getFilterProperty().getLambdaEff(),
            123)
        self.assertEqual(
            lsst.afw.image.Filter('def').getFilterProperty().getLambdaEff(),
            456)
        with self.assertRaises(RuntimeError):
            self.filters2.defineFilters()
        # the defined filters should be unchanged
        self.assertEqual(
            lsst.afw.image.Filter('abc').getFilterProperty().getLambdaEff(),
            123)
        self.assertEqual(
            lsst.afw.image.Filter('def').getFilterProperty().getLambdaEff(),
            456)

    def test_reset(self):
        self.filters1.defineFilters()
        with self.assertRaises(RuntimeError):
            self.filters2.defineFilters()
        self.filters1.reset()
        # The new filters can be defiend and should replace the old ones.
        self.filters2.defineFilters()
        self.assertEqual(
            lsst.afw.image.Filter('abc').getFilterProperty().getLambdaEff(),
            321)
        self.assertEqual(
            lsst.afw.image.Filter('def').getFilterProperty().getLambdaEff(),
            654)

    def test_findAll(self):
        self.assertEqual(set(self.filters1.findAll('r')), set())
        matches = self.filters1.findAll('abc')
        self.assertEqual(len(matches), 1)
        match = list(matches)[0]
        self.assertEqual(match.physical_filter, 'abc')
Esempio n. 3
0
    def setUp(self):
        # reset the filters before we test anything
        FilterDefinitionCollection.reset()

        # The FITS WCS and VisitInfo coordinates in this header are
        # intentionally different, to make comparisons between them more
        # obvious.
        self.boresight = lsst.geom.SpherePoint(10., 20., lsst.geom.degrees)
        self.header = {
            "TELESCOP": "TEST",
            "INSTRUME": "UNKNOWN",
            "AIRMASS": 1.2,
            "RADESYS": "ICRS",
            "OBSTYPE": "science",
            "EQUINOX": 2000,
            "OBSGEO-X": "-5464588.84421314",
            "OBSGEO-Y": "-2493000.19137644",
            "OBSGEO-Z": "2150653.35350771",
            "RA": self.boresight.getLatitude().asDegrees(),
            "DEC": self.boresight.getLongitude().asDegrees(),
            "CTYPE1": "RA---SIN",
            "CTYPE2": "DEC--SIN",
            "CRPIX1": 5,
            "CRPIX2": 6,
            "CRVAL1": self.boresight.getLatitude().asDegrees() + 1,
            "CRVAL2": self.boresight.getLongitude().asDegrees() + 1,
            "CD1_1": 1e-5,
            "CD1_2": 0,
            "CD2_2": 1e-5,
            "CD2_1": 0
        }
        # make a property list of the above, for use by the formatter.
        self.metadata = lsst.daf.base.PropertyList()
        self.metadata.update(self.header)

        maker = MakeTestingRawVisitInfo()
        self.visitInfo = maker(self.header)

        self.metadataSkyWcs = lsst.afw.geom.makeSkyWcs(self.metadata, strip=False)
        self.boresightSkyWcs = createInitialSkyWcs(self.visitInfo, CameraWrapper().camera.get(10))

        # set these to `contextlib.nullcontext()` to print the log warnings
        self.warnContext = self.assertLogs(level="WARNING")
        self.logContext = lsst.log.UsePythonLogging()

        # Make a data ID to pass to the formatter.
        universe = lsst.daf.butler.DimensionUniverse()
        dataId = lsst.daf.butler.DataCoordinate.standardize(instrument="Cam1", exposure=2, detector=10,
                                                            physical_filter="u", band="u", universe=universe)

        # We have no file in these tests, so make an empty descriptor.
        fileDescriptor = lsst.daf.butler.FileDescriptor(None, None)
        self.formatter = SimpleFitsRawFormatter(fileDescriptor, dataId)
        # Force the formatter's metadata to be what we've created above.
        self.formatter._metadata = self.metadata
Esempio n. 4
0
 def setUp(self):
     self.filters1 = FilterDefinitionCollection(
         FilterDefinition(physical_filter='abc', lambdaEff=123),
         FilterDefinition(physical_filter='def',
                          band='d',
                          doc="This is a test filter.",
                          lambdaEff=456))
     self.filters2 = FilterDefinitionCollection(
         FilterDefinition(physical_filter='abc', lambdaEff=321),
         FilterDefinition(physical_filter='def', band='dd', lambdaEff=654))
     FilterDefinitionCollection.reset()