Coverage for tests/test_ingest.py : 80%

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# This file is part of obs_decam.
2#
3# Developed for the LSST Data Management System.
4# This product includes software developed by the LSST Project
5# (http://www.lsst.org).
6# See the COPYRIGHT file at the top-level directory of this distribution
7# for details of code ownership.
8#
9# This program is free software: you can redistribute it and/or modify
10# it under the terms of the GNU General Public License as published by
11# the Free Software Foundation, either version 3 of the License, or
12# (at your option) any later version.
13#
14# This program is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17# GNU General Public License for more details.
18#
19# You should have received a copy of the GNU General Public License
20# along with this program. If not, see <http://www.gnu.org/licenses/>.
22"""Unit tests for gen3 DECam raw data ingest.
23"""
25import unittest
26import os
27import lsst.utils.tests
29from lsst.daf.butler import Butler, DataCoordinate
30from lsst.obs.base.ingest_tests import IngestTestBase
31import lsst.obs.decam
33testDataPackage = "testdata_decam"
34try:
35 testDataDirectory = lsst.utils.getPackageDir(testDataPackage)
36except LookupError:
37 testDataDirectory = None
40class DecamTestBase(IngestTestBase):
42 ingestDir = os.path.dirname(__file__)
43 instrumentClassName = "lsst.obs.decam.DarkEnergyCamera"
44 rawIngestTask = "lsst.obs.decam.DecamRawIngestTask"
47@unittest.skipIf(testDataDirectory is None, "testdata_decam must be set up")
48class DecamIngestTestCase(DecamTestBase, lsst.utils.tests.TestCase):
50 curatedCalibrationDatasetTypes = ("camera", "defects")
52 # DecamRawIngestTask ingests every detector in each raw file, so we
53 # only have to specify one file here, but should get two dataIds
54 # in the output repo.
55 @property
56 def file(self):
57 return os.path.join(testDataDirectory, "rawData", "raw", "raw.fits")
59 dataIds = [dict(instrument="DECam", exposure=229388, detector=25),
60 dict(instrument="DECam", exposure=229388, detector=1)]
62 @property
63 def visits(self):
64 butler = Butler(self.root, collections=[self.outputRun])
65 return {
66 DataCoordinate.standardize(
67 instrument="DECam",
68 visit=229388,
69 universe=butler.registry.dimensions
70 ): [
71 DataCoordinate.standardize(
72 instrument="DECam",
73 exposure=229388,
74 universe=butler.registry.dimensions
75 )
76 ]
77 }
80@unittest.skipIf(testDataDirectory is None, "testdata_decam must be set up")
81class DecamIngestFullFileTestCase(DecamTestBase, lsst.utils.tests.TestCase):
82 """Test ingesting a file that contains all "normal" DECam HDUs.
83 """
85 # No need to test writeCuratedCalibrations again
86 curatedCalibrationDatasetTypes = None
88 # DecamRawIngestTask ingests every detector in each raw file, so we
89 # only have to specify one file here, but should get many dataIds
90 # in the output repo.
91 @property
92 def file(self):
93 return os.path.join(testDataDirectory, "rawData", "raw", "c4d_150227_012718_ori-stripped.fits.fz")
95 dataIds = [{"instrument": "DECam", "exposure": 415282, "detector": i} for i in range(1, 63)]
97 @property
98 def visits(self):
99 butler = Butler(self.root, collections=[self.outputRun])
100 return {
101 DataCoordinate.standardize(
102 instrument="DECam",
103 visit=415282,
104 universe=butler.registry.dimensions
105 ): [
106 DataCoordinate.standardize(
107 instrument="DECam",
108 exposure=415282,
109 universe=butler.registry.dimensions
110 )
111 ]
112 }
115@unittest.skipIf(testDataDirectory is None, "testdata_decam must be set up")
116class DecamIngestShuffledFullFileTestCase(DecamTestBase, lsst.utils.tests.TestCase):
117 """Test ingesting a file that contains all detectors in a random order.
118 """
120 # No need to test writeCuratedCalibrations again
121 curatedCalibrationDatasetTypes = None
123 # DecamRawIngestTask ingests every detector in each raw file, so we
124 # only have to specify one file here, but should get many dataIds
125 # in the output repo.
126 @property
127 def file(self):
128 return os.path.join(testDataDirectory, "rawData", "raw",
129 "c4d_150227_012718_ori-stripped-shuffled.fits.fz")
131 dataIds = [{"instrument": "DECam", "exposure": 415282, "detector": i} for i in range(1, 63)]
133 @property
134 def visits(self):
135 butler = Butler(self.root, collections=[self.outputRun])
136 return {
137 DataCoordinate.standardize(
138 instrument="DECam",
139 visit=415282,
140 universe=butler.registry.dimensions
141 ): [
142 DataCoordinate.standardize(
143 instrument="DECam",
144 exposure=415282,
145 universe=butler.registry.dimensions
146 )
147 ]
148 }
151def setup_module(module):
152 lsst.utils.tests.init()
155if __name__ == "__main__": 155 ↛ 156line 155 didn't jump to line 156, because the condition on line 155 was never true
156 lsst.utils.tests.init()
157 unittest.main()