Coverage for tests/test_Jacobian.py: 42%

40 statements  

« prev     ^ index     » next       coverage.py v6.4.2, created at 2022-07-27 02:08 -0700

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.daf.base as dafBase 

26from lsst.afw.geom import makeSkyWcs 

27import lsst.utils.tests 

28 

29from lsst.meas.base.tests import AlgorithmTestCase 

30from lsst.meas.base.sfm import SingleFrameMeasurementConfig 

31 

32 

33class JacobianTestCase(AlgorithmTestCase, lsst.utils.tests.TestCase): 

34 

35 def setUp(self): 

36 # Pick arbitrary numbers to create a detector object, and a synthetic 

37 # dataset. The particular numbers have no special meaning to the test 

38 # and be anything as long as they are self consistent (i.e. the 

39 # fake source is inside the bounding box) 

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

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

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

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

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

45 

46 md = dafBase.PropertyList() 

47 

48 for k, v in ( 

49 ("EQUINOX", 2000.0), 

50 ("CRPIX1", 5353.0), 

51 ("CRPIX2", -35.0), 

52 ("CD1_1", 0.0), 

53 ("CD1_2", -5.611E-05), 

54 ("CD2_1", -5.611E-05), 

55 ("CD2_2", -0.0), 

56 ("CRVAL1", 4.5789875), 

57 ("CRVAL2", 16.30004444), 

58 ("CUNIT1", 'deg'), 

59 ("CUNIT2", 'deg'), 

60 ("CTYPE1", 'RA---TAN'), 

61 ("CTYPE2", 'DEC--TAN'), 

62 ): 

63 md.set(k, v) 

64 

65 self.wcs = makeSkyWcs(md) 

66 

67 def tearDown(self): 

68 del self.center 

69 del self.bbox 

70 del self.dataset 

71 del self.wcs 

72 

73 def testJacobianPlugin(self): 

74 config = SingleFrameMeasurementConfig() 

75 config.plugins.names |= ['base_Jacobian'] 

76 # Pixel scale chosen to approximately match the scale defined in the 

77 # above WCS 

78 config.plugins['base_Jacobian'].pixelScale = 0.2 

79 task = self.makeSingleFrameMeasurementTask(config=config) 

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

81 exposure.setWcs(self.wcs) 

82 task.run(catalog, exposure) 

83 record = catalog[0] 

84 self.assertFalse(record.get("base_Jacobian_flag")) 

85 self.assertAlmostEqual(record.get("base_Jacobian_value"), 1.0200183929088285, 4) 

86 

87 

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

89 pass 

90 

91 

92def setup_module(module): 

93 lsst.utils.tests.init() 

94 

95 

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

97 lsst.utils.tests.init() 

98 unittest.main()