Coverage for tests / test_drpAssociationPipe.py: 35%
45 statements
« prev ^ index » next coverage.py v7.13.5, created at 2026-04-25 08:39 +0000
« prev ^ index » next coverage.py v7.13.5, created at 2026-04-25 08:39 +0000
1# This file is part of {{ cookiecutter.package_name }}.
3# Developed for the LSST Data Management System.
4# This product includes software developed by the LSST Project
5# (https://www.lsst.org).
6# See the COPYRIGHT file at the top-level directory of this distribution
7# for details of code ownership.
9# This program is free software: you can redistribute it and/or modify
10# it under the terms of the GNU General Public License as published by
11# the Free Software Foundation, either version 3 of the License, or
12# (at your option) any later version.
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17# GNU General Public License for more details.
19# You should have received a copy of the GNU General Public License
20# along with this program. If not, see <https://www.gnu.org/licenses/>.
21#
23import numpy as np
24import pandas as pd
25import unittest
27import lsst.geom as geom
28from lsst.pipe.tasks.coaddBase import makeSkyInfo
29from lsst.pipe.tasks.drpAssociationPipe import DrpAssociationPipeTask
30import lsst.skymap as skyMap
31import lsst.utils.tests
34class TestDrpAssociationPipe(lsst.utils.tests.TestCase):
36 def setUp(self):
37 simpleMapConfig = skyMap.discreteSkyMap.DiscreteSkyMapConfig()
38 simpleMapConfig.raList = [10, 11]
39 simpleMapConfig.decList = [-1, -1]
40 simpleMapConfig.radiusList = [0.1, 0.1]
42 self.simpleMap = skyMap.DiscreteSkyMap(simpleMapConfig)
43 self.tractId = 0
44 self.patchId = 10
46 self.skyInfo = makeSkyInfo(self.simpleMap, self.tractId, self.patchId)
47 self.innerPatchBox = geom.Box2D(self.skyInfo.patchInfo.getInnerBBox())
48 self.innerTractSkyRegion = self.skyInfo.tractInfo.getInnerSkyRegion()
50 self.nSources = 100
51 xs = np.linspace(self.innerPatchBox.getMinX() + 1,
52 self.innerPatchBox.getMaxX() - 1,
53 self.nSources)
54 ys = np.linspace(self.innerPatchBox.getMinY() + 1,
55 self.innerPatchBox.getMaxY() - 1,
56 self.nSources)
58 dataIn = []
59 dataOut = []
60 for x, y in zip(xs, ys):
61 coordIn = self.skyInfo.wcs.pixelToSky(x, y)
62 coordOut = self.skyInfo.wcs.pixelToSky(
63 x + 10 * self.innerPatchBox.getWidth(),
64 y + 10 * self.innerPatchBox.getHeight())
65 dataIn.append({"ra": coordIn.getRa().asDegrees(),
66 "dec": coordIn.getDec().asDegrees()})
67 dataOut.append({"ra": coordOut.getRa().asDegrees(),
68 "dec": coordOut.getDec().asDegrees()})
70 self.diaSrcCatIn = pd.DataFrame(data=dataIn)
71 self.diaSrcCatOut = pd.DataFrame(data=dataOut)
73 def tearDown(self):
74 pass
76 def testTrimToPatch(self):
77 """Test that points inside and outside the patch are correctly
78 identified as such.
79 """
80 dpaTask = DrpAssociationPipeTask()
82 self.assertEqual(
83 np.sum(dpaTask._trimToPatch(self.diaSrcCatIn,
84 self.innerPatchBox,
85 self.skyInfo.wcs,
86 innerTractSkyRegion=self.innerTractSkyRegion)),
87 self.nSources)
89 self.assertEqual(
90 np.sum(dpaTask._trimToPatch(self.diaSrcCatOut,
91 self.innerPatchBox,
92 self.skyInfo.wcs,
93 innerTractSkyRegion=self.innerTractSkyRegion)),
94 0)
97def setup_module(module):
98 lsst.utils.tests.init()
101class MatchMemoryTestCase(lsst.utils.tests.MemoryTestCase):
102 pass
105if __name__ == "__main__": 105 ↛ 106line 105 didn't jump to line 106 because the condition on line 105 was never true
106 lsst.utils.tests.init()
107 unittest.main()