Coverage for tests/test_apertures_hsc.py: 52%

36 statements  

« prev     ^ index     » next       coverage.py v6.4.1, created at 2022-06-05 03:38 -0700

1# This file is part of fgcmcal. 

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"""Test the fgcmcal computeApertureRadius code with testdata_jointcal. 

22""" 

23 

24import unittest 

25import os 

26import tempfile 

27 

28import lsst.daf.butler 

29import lsst.utils 

30 

31from lsst.fgcmcal.utilities import computeApertureRadiusFromName 

32 

33import fgcmcalTestBase 

34 

35 

36ROOT = os.path.abspath(os.path.dirname(__file__)) 

37 

38 

39class FgcmApertureTestHsc(fgcmcalTestBase.FgcmcalTestBase, lsst.utils.tests.TestCase): 

40 @classmethod 

41 def setUpClass(cls): 

42 try: 

43 cls.dataDir = lsst.utils.getPackageDir('testdata_jointcal') 

44 except LookupError: 

45 raise unittest.SkipTest("testdata_jointcal not setup") 

46 try: 

47 lsst.utils.getPackageDir('obs_subaru') 

48 except LookupError: 

49 raise unittest.SkipTest("obs_subaru not setup") 

50 

51 lsst.daf.butler.cli.cliLog.CliLog.initLog(longlog=False) 

52 

53 cls.testDir = tempfile.mkdtemp(dir=ROOT, prefix="TestFgcm-") 

54 

55 cls._importRepository('lsst.obs.subaru.HyperSuprimeCam', 

56 os.path.join(cls.dataDir, 'hsc/repo'), 

57 os.path.join(cls.dataDir, 'hsc', 'exports.yaml')) 

58 

59 def test_fgcmAperture(self): 

60 """ 

61 Test computeApertureRadius for HSC. 

62 """ 

63 self.assertEqual(computeApertureRadiusFromName('ApFlux_12_0_instFlux'), 12.0) 

64 self.assertEqual(computeApertureRadiusFromName('ApFlux_4_5_instFlux'), 4.5) 

65 self.assertEqual(computeApertureRadiusFromName('apFlux_12_0_instFlux'), 12.0) 

66 self.assertEqual(computeApertureRadiusFromName('apFlux_4_5_instFlux'), 4.5) 

67 self.assertRaises(RuntimeError, computeApertureRadiusFromName, 'not_a_field') 

68 

69 

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

71 pass 

72 

73 

74def setup_module(module): 

75 lsst.utils.tests.init() 

76 

77 

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

79 lsst.utils.tests.init() 

80 unittest.main()