Coverage for tests/test_fitcycle.py: 26%

Shortcuts 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

48 statements  

1# See COPYRIGHT file at the top of the source tree. 

2# 

3# This file is part of fgcmcal. 

4# 

5# Developed for the LSST Data Management System. 

6# This product includes software developed by the LSST Project 

7# (https://www.lsst.org). 

8# See the COPYRIGHT file at the top-level directory of this distribution 

9# for details of code ownership. 

10# 

11# This program is free software: you can redistribute it and/or modify 

12# it under the terms of the GNU General Public License as published by 

13# the Free Software Foundation, either version 3 of the License, or 

14# (at your option) any later version. 

15# 

16# This program is distributed in the hope that it will be useful, 

17# but WITHOUT ANY WARRANTY; without even the implied warranty of 

18# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 

19# GNU General Public License for more details. 

20# 

21# You should have received a copy of the GNU General Public License 

22# along with this program. If not, see <https://www.gnu.org/licenses/>. 

23"""Test the fitcycle configurations 

24""" 

25 

26import unittest 

27import copy 

28 

29import lsst.fgcmcal as fgcmcal 

30import lsst.utils 

31 

32 

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

34 """ 

35 Test FgcmFitCycleConfig validation. 

36 """ 

37 def test_fgcmfitcycle_config_validation(self): 

38 """ 

39 Test the FgcmFitCycleConfig validation. 

40 """ 

41 config = fgcmcal.FgcmFitCycleConfig() 

42 

43 config.cycleNumber = 0 

44 config.utBoundary = 0.0 

45 config.latitude = 0.0 

46 config.outfileBase = 'None' 

47 config.bands = ['r', 'i'] 

48 config.fitBands = ['r', 'i'] 

49 config.requiredBands = ['r'] 

50 config.colorSplitBands = ['r', 'i'] 

51 config.superStarSubCcdDict = {'r': True, 'i': True} 

52 config.ccdGraySubCcdDict = {'r': True, 'i': True} 

53 config.expGrayPhotometricCutDict = {'r': -0.05, 'i': -0.05} 

54 config.expGrayHighCutDict = {'r': 0.10, 'i': 0.10} 

55 config.expVarGrayPhotometricCutDict = {'r': 0.0005, 'i': 0.0005} 

56 config.sigFgcmMaxEGrayDict = {'r': 0.05, 'i': 0.05} 

57 config.approxThroughputDict = {'r': 1.0, 'i': 1.0} 

58 config.useRepeatabilityForExpGrayCutsDict = {'r': False, 'i': False} 

59 

60 # Ensure that it validates 

61 config.validate() 

62 

63 self._test_misconfig(config, 'fitBands', ['r', 'i', 'z']) 

64 self._test_misconfig(config, 'requiredBands', ['r', 'i', 'z']) 

65 self._test_misconfig(config, 'colorSplitBands', ['r', 'z']) 

66 self._test_misconfig(config, 'superStarSubCcdDict', {'r': True}) 

67 self._test_misconfig(config, 'ccdGraySubCcdDict', {'r': True}) 

68 self._test_misconfig(config, 'expGrayPhotometricCutDict', {'r': -0.05}) 

69 self._test_misconfig(config, 'expGrayHighCutDict', {'r': 0.10}) 

70 self._test_misconfig(config, 'expVarGrayPhotometricCutDict', {'r': 0.0005}) 

71 self._test_misconfig(config, 'sigFgcmMaxEGrayDict', {'r': 0.05}) 

72 self._test_misconfig(config, 'approxThroughputDict', {'r': 1.0}) 

73 self._test_misconfig(config, 'useRepeatabilityForExpGrayCutsDict', {'r': False}) 

74 

75 def _test_misconfig(self, config, field, value): 

76 """ 

77 Test misconfigured field. 

78 """ 

79 config2 = copy.copy(config) 

80 config2.update(**{field: value}) 

81 with self.assertRaises(ValueError): 

82 config2.validate() 

83 

84 

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

86 pass 

87 

88 

89def setup_module(module): 

90 lsst.utils.tests.init() 

91 

92 

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

94 lsst.utils.tests.init() 

95 unittest.main()