Coverage for tests/test_SkyCoord.py: 42%

29 statements  

« prev     ^ index     » next       coverage.py v6.5.0, created at 2022-12-16 02:11 -0800

1# This file is part of meas_base. 

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 

22import unittest 

23 

24import lsst.geom 

25import lsst.meas.base.tests 

26import lsst.utils.tests 

27 

28 

29class SkyCoordTestCase(lsst.meas.base.tests.AlgorithmTestCase, lsst.utils.tests.TestCase): 

30 

31 def setUp(self): 

32 self.center = lsst.geom.Point2D(50.1, 49.8) 

33 self.bbox = lsst.geom.Box2I(lsst.geom.Point2I(-20, -30), 

34 lsst.geom.Extent2I(140, 160)) 

35 self.dataset = lsst.meas.base.tests.TestDataset(self.bbox) 

36 self.dataset.addSource(100000.0, self.center) 

37 

38 def tearDown(self): 

39 del self.center 

40 del self.bbox 

41 del self.dataset 

42 

43 def testSingleFramePlugin(self): 

44 task = self.makeSingleFrameMeasurementTask("base_SkyCoord") 

45 exposure, catalog = self.dataset.realize(10.0, task.schema, randomSeed=0) 

46 task.run(catalog, exposure) 

47 record = catalog[0] 

48 position = exposure.getWcs().skyToPixel(record.getCoord()) 

49 self.assertFloatsAlmostEqual(position.getX(), record.get("truth_x"), rtol=1E-8) 

50 self.assertFloatsAlmostEqual(position.getY(), record.get("truth_y"), rtol=1E-8) 

51 

52 

53class TestMemory(lsst.utils.tests.MemoryTestCase): 

54 pass 

55 

56 

57def setup_module(module): 

58 lsst.utils.tests.init() 

59 

60 

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

62 lsst.utils.tests.init() 

63 unittest.main()