Coverage for tests/nopytest_test_processCcd.py : 44%

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#
2# LSST Data Management System
3# Copyright 2016 AURA/LSST.
4#
5# This product includes software developed by the
6# LSST Project (http://www.lsst.org/).
7#
8# This program is free software: you can redistribute it and/or modify
9# it under the terms of the GNU General Public License as published by
10# the Free Software Foundation, either version 3 of the License, or
11# (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the LSST License Statement and
19# the GNU General Public License along with this program. If not,
20# see <https://www.lsstcorp.org/LegalNotices/>.
21#
23import os
24import shutil
25import tempfile
26import unittest
27import warnings
29import lsst.utils.tests
30import lsst.afw.image as afwImage
31import lsst.geom as geom
32import lsst.pex.exceptions as pexExcept
33from lsst.pipe.tasks.processCcd import ProcessCcdTask
34from lsst.utils import getPackageDir
35from lsst.base import disableImplicitThreading
37OutputName = None # Specify a name (as a string) to save the output repository
40class ProcessCcdTestCase(lsst.utils.tests.TestCase):
41 """Tests to run processCcd or tests with processed data"""
42 @classmethod
43 def setUpClass(cls):
44 """Runs ProcessCcdTask so the test* methods can inspect the results."""
45 try:
46 cls.datadir = getPackageDir("testdata_decam")
47 except pexExcept.NotFoundError:
48 message = "testdata_decam not setup. Skipping."
49 warnings.warn(message)
50 raise unittest.SkipTest(message)
52 cls.outPath = tempfile.mkdtemp() if OutputName is None else OutputName
53 cls.dataId = {'visit': 229388, 'ccdnum': 1}
54 configPath = os.path.join(getPackageDir("obs_decam"), "config")
55 argsList = [os.path.join(cls.datadir, "rawData"), "--output", cls.outPath, "--id"]
56 argsList += ["%s=%s" % (key, val) for key, val in cls.dataId.items()]
57 argsList += ["--calib", os.path.join(cls.datadir, "rawData/cpCalib")]
58 argsList += ["--config", "calibrate.doPhotoCal=False", "calibrate.doAstrometry=False",
59 # This test uses CP-MasterCal calibration products
60 "-C", "%s/processCcdCpIsr.py" % configPath]
61 argsList.append('--doraise')
62 disableImplicitThreading() # avoid contention with other processes
63 fullResult = ProcessCcdTask.parseAndRun(args=argsList, doReturnResults=True)
64 cls.butler = fullResult.parsedCmd.butler
65 cls.config = fullResult.parsedCmd.config
67 @classmethod
68 def tearDownClass(cls):
69 del cls.butler
70 if OutputName is None:
71 shutil.rmtree(cls.outPath)
72 else:
73 print("testProcessCcd.py's output data saved to %r" % (OutputName,))
75 def testProcessRaw(self):
76 """Sanity check of running processCcd with raw data"""
77 exp = self.butler.get("calexp", self.dataId, immediate=True)
78 self.assertIsInstance(exp, afwImage.ExposureF)
79 self.assertEqual(exp.getWidth(), 2048)
80 self.assertEqual(exp.getHeight(), 4096)
82 def testCcdKey(self):
83 """Test to retrieve calexp using ccd as the ccd key"""
84 exp = self.butler.get("calexp", visit=229388, ccd=1, immediate=True)
85 self.assertIsInstance(exp, afwImage.ExposureF)
87 def testWcsPostIsr(self):
88 """Test the wcs of postISRCCD products
90 The postISRCCD wcs should be the same as the raw wcs
91 after adding camera distortion and
92 adjustment of overscan/prescan trimming. Test DM-4859.
93 """
94 if not self.config.isr.doWrite or not self.config.isr.assembleCcd.doTrim:
95 return
96 expRaw = self.butler.get("raw", self.dataId, immediate=True)
97 expPost = self.butler.get("postISRCCD", self.dataId, immediate=True)
98 self.assertIsInstance(expPost, afwImage.ExposureF)
99 wcsRaw = expRaw.getWcs()
100 wcsPost = expPost.getWcs()
101 # Shift WCS for trimming the prescan and overscan region
102 # ccdnum 1 is S29, with overscan in the bottom
103 wcsRaw = wcsRaw.copyAtShiftedPixelOrigin(geom.Extent2D(-56, -50))
104 self.assertWcsAlmostEqualOverBBox(wcsRaw, wcsPost, expPost.getBBox())
107class MemoryTester(lsst.utils.tests.MemoryTestCase):
108 pass
111def setup_module(module):
112 lsst.utils.tests.init()
115if __name__ == "__main__": 115 ↛ 116line 115 didn't jump to line 116, because the condition on line 115 was never true
116 lsst.utils.tests.init()
117 unittest.main()