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