Exemple #1
0
    def testComposite(self):
        self.columns.extend(
            ["modelfit_CModel_instFlux", "base_PsfFlux_instFlux"])
        self.dataDict["modelfit_CModel_instFlux"] = np.full(self.nRecords, 1)
        self.dataDict["base_PsfFlux_instFlux"] = np.full(self.nRecords, 1)

        parq = self.simulateMultiParquet(self.dataDict)
        # Modify r band value slightly.
        parq._df[("meas", "r", "base_PsfFlux_instFlux")] -= 0.1

        filt = 'g'
        funcDict = {
            'psfMag_ref': Mag('base_PsfFlux', dataset='ref'),
            'ra': RAColumn(),
            'dec': DecColumn(),
            'psfMag': Mag('base_PsfFlux', filt=filt),
            'cmodel_magDiff': MagDiff('base_PsfFlux',
                                      'modelfit_CModel',
                                      filt=filt)
        }
        func = CompositeFunctor(funcDict)
        df = self._compositeFuncVal(func, parq)

        # Repeat same, but define filter globally instead of individually
        funcDict2 = {
            'psfMag_ref': Mag('base_PsfFlux', dataset='ref'),
            'ra': RAColumn(),
            'dec': DecColumn(),
            'psfMag': Mag('base_PsfFlux'),
            'cmodel_magDiff': MagDiff('base_PsfFlux', 'modelfit_CModel')
        }

        func2 = CompositeFunctor(funcDict2, filt=filt)
        df2 = self._compositeFuncVal(func2, parq)
        self.assertTrue(df.equals(df2))

        func2.filt = 'r'
        df3 = self._compositeFuncVal(func2, parq)
        # Because we modified the R filter this should fail.
        self.assertFalse(df2.equals(df3))

        # Make sure things work with passing list instead of dict
        funcs = [
            Mag('base_PsfFlux', dataset='ref'),
            RAColumn(),
            DecColumn(),
            Mag('base_PsfFlux', filt=filt),
            MagDiff('base_PsfFlux', 'modelfit_CModel', filt=filt)
        ]

        df = self._compositeFuncVal(CompositeFunctor(funcs), parq)
Exemple #2
0
    def testMagDiff(self):
        for filt in self.filters:
            filt = 'HSC-G'
            val = self._funcVal(
                MagDiff('base_PsfFlux', 'modelfit_CModel', filt=filt))

            mag1 = self._funcVal(Mag('modelfit_CModel', filt=filt))
            mag2 = self._funcVal(Mag('base_PsfFlux', filt=filt))
            self.assertTrue(
                np.allclose((mag2 - mag1).dropna(), val, rtol=0, atol=1e-13))
Exemple #3
0
    def testComposite(self):
        filt = 'HSC-G'
        funcDict = {
            'psfMag_ref': Mag('base_PsfFlux', dataset='ref'),
            'ra': RAColumn(),
            'dec': DecColumn(),
            'psfMag': Mag('base_PsfFlux', filt=filt),
            'cmodel_magDiff': MagDiff('base_PsfFlux',
                                      'modelfit_CModel',
                                      filt=filt)
        }
        func = CompositeFunctor(funcDict)
        df = self._compositeFuncVal(func)

        # Repeat same, but define filter globally instead of individually
        funcDict2 = {
            'psfMag_ref': Mag('base_PsfFlux', dataset='ref'),
            'ra': RAColumn(),
            'dec': DecColumn(),
            'psfMag': Mag('base_PsfFlux'),
            'cmodel_magDiff': MagDiff('base_PsfFlux', 'modelfit_CModel')
        }

        func2 = CompositeFunctor(funcDict2, filt=filt)
        df2 = self._compositeFuncVal(func2)
        self.assertTrue(df.equals(df2))

        func2.filt = 'HSC-R'
        df3 = self._compositeFuncVal(func2)
        self.assertFalse(df2.equals(df3))

        # Make sure things work with passing list instead of dict
        funcs = [
            Mag('base_PsfFlux', dataset='ref'),
            RAColumn(),
            DecColumn(),
            Mag('base_PsfFlux', filt=filt),
            MagDiff('base_PsfFlux', 'modelfit_CModel', filt=filt)
        ]

        df = self._compositeFuncVal(CompositeFunctor(funcs))
Exemple #4
0
    def testCompositeSimple(self):
        """Test single-level composite functor for functionality
        """
        self.columns.extend(
            ["modelfit_CModel_instFlux", "base_PsfFlux_instFlux"])
        self.dataDict["modelfit_CModel_instFlux"] = np.full(self.nRecords, 1)
        self.dataDict["base_PsfFlux_instFlux"] = np.full(self.nRecords, 1)

        parq = self.simulateParquet(self.dataDict)
        funcDict = {
            'ra': RAColumn(),
            'dec': DecColumn(),
            'psfMag': Mag('base_PsfFlux'),
            'cmodel_magDiff': MagDiff('base_PsfFlux', 'modelfit_CModel')
        }
        func = CompositeFunctor(funcDict)
        df = self._compositeFuncVal(func, parq)  # noqa
Exemple #5
0
    def testDifference(self):
        """Test .difference method using MagDiff as the example.
        """
        self.columns.extend([
            "base_PsfFlux_instFlux", "base_PsfFlux_instFluxErr",
            "modelfit_CModel_instFlux", "modelfit_CModel_instFluxErr"
        ])

        self.dataDict["base_PsfFlux_instFlux"] = np.full(self.nRecords, 1000)
        self.dataDict["modelfit_CModel_instFlux"] = np.full(
            self.nRecords, 1000)
        parq1 = self.simulateMultiParquet(self.dataDict)

        self.dataDict["base_PsfFlux_instFlux"] = np.full(self.nRecords, 999)
        self.dataDict["modelfit_CModel_instFlux"] = np.full(self.nRecords, 999)
        parq2 = self.simulateMultiParquet(self.dataDict)

        magDiff = MagDiff('base_PsfFlux', 'modelfit_CModel', filt='g')

        # Asserts that differences computed properly
        self._differenceVal(magDiff, parq1, parq2)
Exemple #6
0
    def testMagDiff(self):
        self.columns.extend([
            "base_PsfFlux_instFlux", "base_PsfFlux_instFluxErr",
            "modelfit_CModel_instFlux", "modelfit_CModel_instFluxErr"
        ])
        self.dataDict["base_PsfFlux_instFlux"] = np.full(self.nRecords, 1000)
        self.dataDict["base_PsfFlux_instFluxErr"] = np.full(self.nRecords, 10)
        self.dataDict["modelfit_CModel_instFlux"] = np.full(
            self.nRecords, 1000)
        self.dataDict["modelfit_CModel_instFluxErr"] = np.full(
            self.nRecords, 10)
        parq = self.simulateMultiParquet(self.dataDict)

        for filt in self.filters:
            filt = 'HSC-G'
            val = self._funcVal(
                MagDiff('base_PsfFlux', 'modelfit_CModel', filt=filt), parq)

            mag1 = self._funcVal(Mag('modelfit_CModel', filt=filt), parq)
            mag2 = self._funcVal(Mag('base_PsfFlux', filt=filt), parq)
            self.assertTrue(
                np.allclose((mag2 - mag1).dropna(), val, rtol=0, atol=1e-13))