Coverage for tests/test_fitcycle.py: 22%

54 statements  

« prev     ^ index     » next       coverage.py v6.5.0, created at 2022-11-08 23:34 -0800

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 config.defaultCameraOrientation = 0.0 

60 

61 # Ensure that it validates 

62 config.validate() 

63 

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

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

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

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

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

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

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

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

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

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

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

75 

76 config.doComputeDeltaAperMap = True 

77 self._test_misconfig(config, 'deltaAperInnerRadiusArcsec', 0.0) 

78 config.deltaAperInnerRadiusArcsec = 1.0 

79 self._test_misconfig(config, 'deltaAperOuterRadiusArcsec', 0.0) 

80 self._test_misconfig(config, 'deltaAperOuterRadiusArcsec', 1.0) 

81 

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

83 """ 

84 Test misconfigured field. 

85 """ 

86 config2 = copy.copy(config) 

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

88 with self.assertRaises(ValueError): 

89 config2.validate() 

90 

91 

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

93 pass 

94 

95 

96def setup_module(module): 

97 lsst.utils.tests.init() 

98 

99 

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

101 lsst.utils.tests.init() 

102 unittest.main()