Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1# This file is part of pipe_tasks. 

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 os 

23import unittest 

24import logging 

25 

26import lsst.afw.image as afwImage 

27import lsst.utils.tests 

28from lsst.utils import getPackageDir 

29from lsst.pipe.tasks.characterizeImage import CharacterizeImageTask, CharacterizeImageConfig 

30from lsst.pipe.tasks.calibrate import CalibrateTask, CalibrateConfig 

31 

32 

33class SkySourcesTestCase(lsst.utils.tests.TestCase): 

34 

35 def setUp(self): 

36 # Load sample input from disk 

37 expPath = os.path.join(getPackageDir("pipe_tasks"), "tests", "data", "v695833-e0-c000-a00.sci.fits") 

38 self.exposure = afwImage.ExposureF(expPath) 

39 # set log level so that warnings do not display 

40 logging.getLogger("calibrate").setLevel(logging.ERROR) 

41 

42 def tearDown(self): 

43 del self.exposure 

44 

45 def testDoSkySources(self): 

46 """Tests sky_source column gets added when run. 

47 """ 

48 self._checkSkySourceColumnExistence(doSkySources=True) 

49 self._checkSkySourceColumnExistence(doSkySources=False) 

50 

51 def _checkSkySourceColumnExistence(self, doSkySources): 

52 """Implements sky_source column checking. 

53 

54 Parameters 

55 ---------- 

56 doSkySource : `bool` 

57 Value of the config flag determining whether to insert sky sources. 

58 """ 

59 charImConfig = CharacterizeImageConfig() 

60 charImTask = CharacterizeImageTask(config=charImConfig) 

61 charImResults = charImTask.run(self.exposure) 

62 calibConfig = CalibrateConfig() 

63 calibConfig.doAstrometry = False 

64 calibConfig.doPhotoCal = False 

65 calibConfig.doSkySources = doSkySources 

66 calibTask = CalibrateTask(config=calibConfig) 

67 calibResults = calibTask.run(charImResults.exposure) 

68 if doSkySources: 

69 self.assertTrue('sky_source' in calibResults.outputCat.schema.getNames()) 

70 else: 

71 self.assertFalse('sky_source' in calibResults.outputCat.schema.getNames()) 

72 

73 

74class MemoryTester(lsst.utils.tests.MemoryTestCase): 

75 pass 

76 

77 

78def setup_module(module): 

79 lsst.utils.tests.init() 

80 

81 

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

83 lsst.utils.tests.init() 

84 unittest.main()