コード例 #1
0
ファイル: test_functors.py プロジェクト: kiyoyabe/pipe_tasks
    def testMag(self):
        fluxName = 'base_PsfFlux'

        # Check that things work when you provide dataset explicitly
        for dataset in ['forced_src', 'meas']:
            psfMag_G = self._funcVal(
                Mag(fluxName, dataset=dataset, filt='HSC-G'))
            psfMag_R = self._funcVal(
                Mag(fluxName, dataset=dataset, filt='HSC-R'))

            psfColor_GR = self._funcVal(
                Color(fluxName, 'HSC-G', 'HSC-R', dataset=dataset))

            self.assertTrue(
                np.allclose((psfMag_G - psfMag_R).dropna(),
                            psfColor_GR,
                            rtol=0,
                            atol=1e-13))

        # Check that behavior as expected when dataset not provided;
        #  that is, that the color comes from forced and default Mag is meas
        psfMag_G = self._funcVal(Mag(fluxName, filt='HSC-G'))
        psfMag_R = self._funcVal(Mag(fluxName, filt='HSC-R'))

        psfColor_GR = self._funcVal(Color(fluxName, 'HSC-G', 'HSC-R'))

        # These should *not* be equal.
        self.assertFalse(
            np.allclose((psfMag_G - psfMag_R).dropna(), psfColor_GR))
コード例 #2
0
ファイル: test_functors.py プロジェクト: kiyoyabe/pipe_tasks
 def testCompositeColor(self):
     funcDict = {
         'a': Mag('base_PsfFlux', dataset='meas', filt='HSC-G'),
         'b': Mag('base_PsfFlux', dataset='forced_src', filt='HSC-G'),
         'c': Color('base_PsfFlux', 'HSC-G', 'HSC-R')
     }
     # Covering the code is better than nothing
     df = self._compositeFuncVal(CompositeFunctor(funcDict))  # noqa
コード例 #3
0
ファイル: test_functors.py プロジェクト: kiyoyabe/pipe_tasks
    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))
コード例 #4
0
 def testCompositeColor(self):
     self.dataDict["base_PsfFlux_instFlux"] = np.full(self.nRecords, 1000)
     self.dataDict["base_PsfFlux_instFluxErr"] = np.full(self.nRecords, 10)
     parq = self.simulateMultiParquet(self.dataDict)
     funcDict = {
         'a': Mag('base_PsfFlux', dataset='meas', filt='HSC-G'),
         'b': Mag('base_PsfFlux', dataset='forced_src', filt='HSC-G'),
         'c': Color('base_PsfFlux', 'HSC-G', 'HSC-R')
     }
     # Covering the code is better than nothing
     df = self._compositeFuncVal(CompositeFunctor(funcDict), parq)  # noqa
コード例 #5
0
    def testCompositeDifference(self):
        self.dataDict["base_PsfFlux_instFlux"] = np.full(self.nRecords, 1000)
        self.dataDict["base_PsfFlux_instFluxErr"] = np.full(self.nRecords, 10)
        parq1 = self.simulateMultiParquet(self.dataDict)

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

        funcDict = {
            'a': Mag('base_PsfFlux', dataset='meas', filt='g'),
            'b': Mag('base_PsfFlux', dataset='forced_src', filt='g'),
            'c': Color('base_PsfFlux', 'g', 'r')
        }
        # Covering the code is better than nothing
        df = self._compositeDifferenceVal(CompositeFunctor(funcDict), parq1,
                                          parq2)  # noqa
コード例 #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))
コード例 #7
0
    def testMag(self):
        self.columns.extend(
            ["base_PsfFlux_instFlux", "base_PsfFlux_instFluxErr"])
        self.dataDict["base_PsfFlux_instFlux"] = np.full(self.nRecords, 1000)
        self.dataDict["base_PsfFlux_instFluxErr"] = np.full(self.nRecords, 10)
        parq = self.simulateMultiParquet(self.dataDict)
        # Change one dataset filter combinations value.
        parq._df[("meas", "HSC-G", "base_PsfFlux_instFlux")] -= 1

        fluxName = 'base_PsfFlux'

        # Check that things work when you provide dataset explicitly
        for dataset in ['forced_src', 'meas']:
            psfMag_G = self._funcVal(
                Mag(fluxName, dataset=dataset, filt='HSC-G'), parq)
            psfMag_R = self._funcVal(
                Mag(fluxName, dataset=dataset, filt='HSC-R'), parq)

            psfColor_GR = self._funcVal(
                Color(fluxName, 'HSC-G', 'HSC-R', dataset=dataset), parq)

            self.assertTrue(
                np.allclose((psfMag_G - psfMag_R).dropna(),
                            psfColor_GR,
                            rtol=0,
                            atol=1e-13))

        # Check that behavior as expected when dataset not provided;
        #  that is, that the color comes from forced and default Mag is meas
        psfMag_G = self._funcVal(Mag(fluxName, filt='HSC-G'), parq)
        psfMag_R = self._funcVal(Mag(fluxName, filt='HSC-R'), parq)

        psfColor_GR = self._funcVal(Color(fluxName, 'HSC-G', 'HSC-R'), parq)

        # These should *not* be equal.
        self.assertFalse(
            np.allclose((psfMag_G - psfMag_R).dropna(), psfColor_GR))
コード例 #8
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
コード例 #9
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)
コード例 #10
0
ファイル: test_functors.py プロジェクト: kiyoyabe/pipe_tasks
    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))
コード例 #11
0
ファイル: explorer.py プロジェクト: lsst-dm/qa_explorer
import datashader as ds
from holoviews.operation.datashader import aggregate, datashade, dynspread
import colorcet as cc

import param
import parambokeh

from lsst.pipe.tasks.functors import (Mag, CustomFunctor, DeconvolvedMoments,
                                      StarGalaxyLabeller, RAColumn, DecColumn,
                                      Column, SdssTraceSize,
                                      PsfSdssTraceSizeDiff, HsmTraceSize,
                                      PsfHsmTraceSizeDiff, CompositeFunctor)

default_xFuncs = {
    'base_PsfFlux': Mag('base_PsfFlux'),
    'modelfit_CModel': Mag('modelfit_CModel')
}
default_yFuncs = {'modelfit_CModel - base_PsfFlux' : CustomFunctor('mag(modelfit_CModel) - mag(base_PsfFlux)'),
                  'Deconvolved Moments' : DeconvolvedMoments(),
                  'Footprint NPix' : Column('base_Footprint_nPix'),
                  'ext_photometryKron_KronFlux - base_PsfFlux' : \
                        CustomFunctor('mag(ext_photometryKron_KronFlux) - mag(base_PsfFlux)'),
                  'base_GaussianFlux - base_PsfFlux' : CustomFunctor('mag(base_GaussianFlux) - mag(base_PsfFlux)'),
                  'SDSS Trace Size' : SdssTraceSize(),
                  'PSF - SDSS Trace Size' : PsfSdssTraceSizeDiff(),
                  'HSM Trace Size' : HsmTraceSize(),
                  'PSF - HSM Trace Size': PsfHsmTraceSizeDiff()}

default_labellers = {'default': StarGalaxyLabeller()}