Coverage for tests/test_sdss.py : 29%

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#!/usr/bin/env python
3#
4# LSST Data Management System
5# Copyright 2008, 2009, 2010 LSST Corporation.
6#
7# This product includes software developed by the
8# LSST Project (http://www.lsst.org/).
9#
10# This program is free software: you can redistribute it and/or modify
11# it under the terms of the GNU General Public License as published by
12# the Free Software Foundation, either version 3 of the License, or
13# (at your option) any later version.
14#
15# This program is distributed in the hope that it will be useful,
16# but WITHOUT ANY WARRANTY; without even the implied warranty of
17# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18# GNU General Public License for more details.
19#
20# You should have received a copy of the LSST License Statement and
21# the GNU General Public License along with this program. If not,
22# see <http://www.lsstcorp.org/LegalNotices/>.
23#
24import os
25import unittest
27import lsst.utils
28import lsst.utils.tests
29import lsst.daf.persistence as dafPersist
30from lsst.daf.base import DateTime
31import lsst.afw.image
32from lsst.afw.geom import SkyWcs
33import lsst.afw.detection
34from lsst.geom import SpherePoint, degrees
37class SdssMapperTestCase(lsst.utils.tests.TestCase):
38 """A test case for the SdssMapper."""
40 def testGetDR7(self):
41 obsSdssDir = lsst.utils.getPackageDir('obs_sdss')
42 butler = dafPersist.Butler(
43 root=os.path.join(obsSdssDir, "tests", "data", "dr7", "runs"))
44 sub = butler.subset("fpC", run=5754, camcol=3, field=280, filter="r")
45 self.assertEqual(len(sub), 1)
46 for ref in sub:
47 im = ref.get("fpC")
48 w, h = im.getWidth(), im.getHeight()
49 self.assertEqual(im.__class__, lsst.afw.image.ExposureU)
50 self.assertEqual(w, 2048)
51 self.assertEqual(h, 1489)
53 im_md = ref.get("fpC_md")
54 self.assertEqual(im_md.getScalar("RUN"), 5754)
55 self.assertEqual(im_md.getScalar("FRAME"), 280)
56 self.assertEqual(im_md.getScalar("STRIPE"), 82)
58 msk = ref.get("fpM")
59 w, h = msk.getWidth(), msk.getHeight()
60 self.assertEqual(msk.__class__, lsst.afw.image.Mask[lsst.afw.image.MaskPixel])
61 self.assertEqual(w, 2048)
62 self.assertEqual(h, 1489)
64 psf = ref.get("psField")
65 k = psf.getKernel()
66 w, h = k.getWidth(), k.getHeight()
67 self.assertEqual(psf.__class__, lsst.meas.algorithms.PcaPsf)
68 self.assertEqual(w, 31)
69 self.assertEqual(h, 31)
71 wcs = ref.get("asTrans")
72 self.assertIsInstance(wcs, SkyWcs)
73 self.assertFalse(wcs.isFlipped)
74 # comparison is to results from lsst.afw.image.TanWcs class
75 self.assertSpherePointsAlmostEqual(wcs.pixelToSky(700, 1000),
76 SpherePoint(343.6507738304687, -0.3509870420713227, degrees))
78 tsField = ref.get("tsField")
79 self.assertAlmostEqual(tsField.gain, 4.72, 2)
80 self.assertAlmostEqual(tsField.airmass, 1.2815132857671601)
81 self.assertAlmostEqual(tsField.exptime, 53.907456)
82 predDateStart = DateTime(53664.226070589997, DateTime.MJD, DateTime.TAI)
83 predDateAvg = DateTime(predDateStart.nsecs(DateTime.TAI) + int(0.5e9*tsField.exptime),
84 DateTime.TAI)
85 self.assertAlmostEqual(tsField.dateAvg.get(), predDateAvg.get())
88class TestMemory(lsst.utils.tests.MemoryTestCase):
89 pass
92def setup_module(module):
93 lsst.utils.tests.init()
96if __name__ == "__main__": 96 ↛ 97line 96 didn't jump to line 97, because the condition on line 96 was never true
97 lsst.utils.tests.init()
98 unittest.main()