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 argsList = [os.path.join(cls.datadir, "rawData"), "--output", cls.outPath, "--id"]
55 argsList += ["%s=%s" % (key, val) for key, val in cls.dataId.items()]
56 argsList += ["--calib", os.path.join(cls.datadir, "rawData/cpCalib")]
57 argsList += ["--config", "calibrate.doPhotoCal=False", "calibrate.doAstrometry=False"]
58 argsList.append('--doraise')
59 disableImplicitThreading() # avoid contention with other processes
60 fullResult = ProcessCcdTask.parseAndRun(args=argsList, doReturnResults=True)
61 cls.butler = fullResult.parsedCmd.butler
62 cls.config = fullResult.parsedCmd.config
64 @classmethod
65 def tearDownClass(cls):
66 del cls.butler
67 if OutputName is None:
68 shutil.rmtree(cls.outPath)
69 else:
70 print("testProcessCcd.py's output data saved to %r" % (OutputName,))
72 def testProcessRaw(self):
73 """Sanity check of running processCcd with raw data"""
74 exp = self.butler.get("calexp", self.dataId, immediate=True)
75 self.assertIsInstance(exp, afwImage.ExposureF)
76 self.assertEqual(exp.getWidth(), 2048)
77 self.assertEqual(exp.getHeight(), 4096)
79 def testCcdKey(self):
80 """Test to retrieve calexp using ccd as the ccd key"""
81 exp = self.butler.get("calexp", visit=229388, ccd=1, immediate=True)
82 self.assertIsInstance(exp, afwImage.ExposureF)
84 def testWcsPostIsr(self):
85 """Test the wcs of postISRCCD products
87 The postISRCCD wcs should be the same as the raw wcs
88 after adding camera distortion and
89 adjustment of overscan/prescan trimming. Test DM-4859.
90 """
91 if not self.config.isr.doWrite or not self.config.isr.assembleCcd.doTrim:
92 return
93 expRaw = self.butler.get("raw", self.dataId, immediate=True)
94 expPost = self.butler.get("postISRCCD", self.dataId, immediate=True)
95 self.assertIsInstance(expPost, afwImage.ExposureF)
96 wcsRaw = expRaw.getWcs()
97 wcsPost = expPost.getWcs()
98 # Shift WCS for trimming the prescan and overscan region
99 # ccdnum 1 is S29, with overscan in the bottom
100 wcsRaw = wcsRaw.copyAtShiftedPixelOrigin(geom.Extent2D(-56, -50))
101 self.assertWcsAlmostEqualOverBBox(wcsRaw, wcsPost, expPost.getBBox())
104class MemoryTester(lsst.utils.tests.MemoryTestCase):
105 pass
108def setup_module(module):
109 lsst.utils.tests.init()
112if __name__ == "__main__": 112 ↛ 113line 112 didn't jump to line 113, because the condition on line 112 was never true
113 lsst.utils.tests.init()
114 unittest.main()