Coverage for tests/test_getInstcal.py: 31%
67 statements
« prev ^ index » next coverage.py v6.4, created at 2022-05-26 03:00 -0700
« prev ^ index » next coverage.py v6.4, created at 2022-05-26 03:00 -0700
1#
2# LSST Data Management System
3# Copyright 2016 LSST Corporation.
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 <http://www.lsstcorp.org/LegalNotices/>.
21#
23import math
24import os
25import warnings
26import unittest
28import lsst.utils.tests
29from lsst.utils import getPackageDir
31import lsst.daf.persistence as dafPersist
32from lsst.geom import arcseconds, radians
34from test_getRaw import visit229388_info
37class GetInstcalTestCase(lsst.utils.tests.TestCase):
39 def setUp(self):
40 try:
41 datadir = getPackageDir("testdata_decam")
42 except LookupError:
43 message = "testdata_decam not setup. Skipping."
44 warnings.warn(message)
45 raise unittest.SkipTest(message)
47 self.repoPath = os.path.join(datadir, "cpData")
48 self.butler = dafPersist.Butler(root=self.repoPath)
49 self.size = (2046, 4094)
50 self.dataId = {'visit': 229388, 'ccdnum': 1}
51 self.filter = "z"
53 def tearDown(self):
54 del self.butler
56 def testInstcal(self):
57 """Test retrieval of community pipeline-processed image"""
58 exp = self.butler.get("instcal", self.dataId, immediate=True)
60 self.assertEqual(exp.getWidth(), self.size[0])
61 self.assertEqual(exp.getHeight(), self.size[1])
62 self.assertEqual(exp.getDetector().getId(), self.dataId["ccdnum"])
63 self.assertEqual(exp.getFilter().getCanonicalName(), self.filter)
64 self.assertTrue(exp.hasWcs())
65 magZero = 2.5 * math.log10(exp.getPhotoCalib().getInstFluxAtZeroMagnitude())
66 self.assertAlmostEqual(magZero, 28.957)
68 visitInfo = exp.getInfo().getVisitInfo()
69 self.assertEqual(visitInfo.getDate(), visit229388_info['dateAvg'])
70 self.assertEqual(visitInfo.getExposureTime(), visit229388_info['exposureTime'])
71 self.assertEqual(visitInfo.getDarkTime(), visit229388_info['darkTime'])
72 self.assertEqual(exp.info.id, int("%07d%02d" % (229388, 1)))
73 self.assertAnglesAlmostEqual(visitInfo.getEra(), visit229388_info['era'],
74 maxDiff=0.0001*radians)
75 self.assertSpherePointsAlmostEqual(visitInfo.getBoresightRaDec(), visit229388_info['boresightRaDec'],
76 maxSep=0.1*arcseconds)
77 self.assertSpherePointsAlmostEqual(visitInfo.getBoresightAzAlt(), visit229388_info['boresightAzAlt'])
78 self.assertAlmostEqual(visitInfo.getBoresightAirmass(), visit229388_info['boresightAirmass'])
79 self.assertEqual(visitInfo.getBoresightRotAngle(), visit229388_info['boresightRotAngle'])
80 self.assertEqual(visitInfo.getRotType(), visit229388_info['rotType'])
81 observatory = visitInfo.getObservatory()
82 self.assertAnglesAlmostEqual(observatory.getLongitude(), visit229388_info['obs_longitude'])
83 self.assertAnglesAlmostEqual(observatory.getLatitude(), visit229388_info['obs_latitude'])
84 self.assertAlmostEqual(observatory.getElevation(), visit229388_info['obs_elevation'])
85 weather = visitInfo.getWeather()
86 self.assertAlmostEqual(weather.getAirTemperature(), visit229388_info['weath_airTemperature'])
87 self.assertAlmostEqual(weather.getAirPressure(), visit229388_info['weath_airPressure'])
88 self.assertAlmostEqual(weather.getHumidity(), visit229388_info['weath_humidity'])
90 # Metadata should not contain WCS or TPV headers.
91 # This is not an exhaustive list.
92 wcs_keywords = ("PV1_1", "PV2_1", "CRPIX1", "CD2_1", "CRVAL2", "LTV1")
93 for keyword in wcs_keywords:
94 self.assertNotIn(keyword, exp.getMetadata().paramNames())
96 def testCcdName(self):
97 """Verify that we get the proper CCD for a specified ccdnum."""
98 dataId = {'visit': 229388, 'ccdnum': 62}
99 exp = self.butler.get("instcal", dataId, immediate=True)
100 self.assertEqual(exp.getDetector().getName(), "N31")
101 self.assertEqual(exp.info.id, int("%07d%02d" % (229388, 62)))
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()