Coverage for tests/test_drpAssociationPipe.py: 35%

44 statements  

« prev     ^ index     » next       coverage.py v6.5.0, created at 2023-01-21 02:32 -0800

1# This file is part of {{ cookiecutter.package_name }}. 

2 

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. 

8 

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. 

13 

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. 

18 

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# 

22 

23import numpy as np 

24import pandas as pd 

25import unittest 

26 

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 

32 

33 

34class TestDrpAssociationPipe(lsst.utils.tests.TestCase): 

35 

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] 

41 

42 self.simpleMap = skyMap.DiscreteSkyMap(simpleMapConfig) 

43 self.tractId = 0 

44 self.patchId = 10 

45 

46 self.skyInfo = makeSkyInfo(self.simpleMap, self.tractId, self.patchId) 

47 self.innerPatchBox = geom.Box2D(self.skyInfo.patchInfo.getInnerBBox()) 

48 

49 self.nSources = 100 

50 xs = np.linspace(self.innerPatchBox.getMinX() + 1, 

51 self.innerPatchBox.getMaxX() - 1, 

52 self.nSources) 

53 ys = np.linspace(self.innerPatchBox.getMinY() + 1, 

54 self.innerPatchBox.getMaxY() - 1, 

55 self.nSources) 

56 

57 dataIn = [] 

58 dataOut = [] 

59 for x, y in zip(xs, ys): 

60 coordIn = self.skyInfo.wcs.pixelToSky(x, y) 

61 coordOut = self.skyInfo.wcs.pixelToSky( 

62 x + 10 * self.innerPatchBox.getWidth(), 

63 y + 10 * self.innerPatchBox.getHeight()) 

64 dataIn.append({"ra": coordIn.getRa().asDegrees(), 

65 "decl": coordIn.getDec().asDegrees()}) 

66 dataOut.append({"ra": coordOut.getRa().asDegrees(), 

67 "decl": coordOut.getDec().asDegrees()}) 

68 

69 self.diaSrcCatIn = pd.DataFrame(data=dataIn) 

70 self.diaSrcCatOut = pd.DataFrame(data=dataOut) 

71 

72 def tearDown(self): 

73 pass 

74 

75 def testTrimToPatch(self): 

76 """Test that points inside and outside the patch are correctly 

77 identified as such. 

78 """ 

79 dpaTask = DrpAssociationPipeTask() 

80 

81 self.assertEqual( 

82 np.sum(dpaTask._trimToPatch(self.diaSrcCatIn, 

83 self.innerPatchBox, 

84 self.skyInfo.wcs)), 

85 self.nSources) 

86 

87 self.assertEqual( 

88 np.sum(dpaTask._trimToPatch(self.diaSrcCatOut, 

89 self.innerPatchBox, 

90 self.skyInfo.wcs)), 

91 0) 

92 

93 

94def setup_module(module): 

95 lsst.utils.tests.init() 

96 

97 

98class MatchMemoryTestCase(lsst.utils.tests.MemoryTestCase): 

99 pass 

100 

101 

102if __name__ == "__main__": 102 ↛ 103line 102 didn't jump to line 103, because the condition on line 102 was never true

103 lsst.utils.tests.init() 

104 unittest.main()