Coverage for tests/test_fitcycle.py: 31%
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
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
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"""
26import unittest
27import copy
29import lsst.fgcmcal as fgcmcal
30import lsst.utils
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()
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
61 # Ensure that it validates
62 config.validate()
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})
76 def _test_misconfig(self, config, field, value):
77 """
78 Test misconfigured field.
79 """
80 config2 = copy.copy(config)
81 config2.update(**{field: value})
82 with self.assertRaises(ValueError):
83 config2.validate()
86class TestMemory(lsst.utils.tests.MemoryTestCase):
87 pass
90def setup_module(module):
91 lsst.utils.tests.init()
94if __name__ == "__main__": 94 ↛ 95line 94 didn't jump to line 95, because the condition on line 94 was never true
95 lsst.utils.tests.init()
96 unittest.main()