Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DM-5586: fix level in butler policy #21

Merged
merged 2 commits into from
Mar 28, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions policy/DecamMapper.paf
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ needCalibRegistry: true

levels: {
# Keys that are NOT relevant for a particular level
skyTile: "visit" "ccdnum"
visit: "ccdnum"
skyTile: "visit" "ccdnum" "hdu"
visit: "ccdnum" "hdu"
ccd: "none"
}
defaultLevel: "ccd"
Expand Down
4 changes: 2 additions & 2 deletions python/lsst/obs/decam/decamMapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ class DecamMapper(CameraMapper):

detectorNames = {1:'S29', 2:'S30', 3:'S31', 4:'S25', 5:'S26', 6:'S27', 7:'S28', 8:'S20', 9:'S21',
10:'S22', 11:'S23', 12:'S24', 13:'S14', 14:'S15', 15:'S16', 16:'S17', 17:'S18',
18:'S19', 19:'S8', 20:'S9', 21:'S10', 22:'S11', 23:'S12', 24:'S13', 25:'S1',
26:'S2', 27:'S3', 28:'S4', 29:'S5', 30:'S6', 32:'N1', 33:'N2', 34:'N3', 35:'N4',
18:'S19', 19:'S8', 20:'S9', 21:'S10', 22:'S11', 23:'S12', 24:'S13', 25:'S1', 26:'S2',
27:'S3', 28:'S4', 29:'S5', 30:'S6', 31:'S7', 32:'N1', 33:'N2', 34:'N3', 35:'N4',
36:'N5', 37:'N6', 38:'N7', 39:'N8', 40:'N9', 41:'N10', 42:'N11', 43:'N12', 44:'N13',
45:'N14', 46:'N15', 47:'N16', 48:'N17', 49:'N18', 50:'N19', 51:'N20', 52:'N21',
53:'N22', 54:'N23', 55:'N24', 56:'N25', 57:'N26', 58:'N27', 59:'N28', 60:'N29',
Expand Down
84 changes: 84 additions & 0 deletions tests/testButler.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#!/usr/bin/env python
from __future__ import print_function
#
# LSST Data Management System
# Copyright 2016 LSST Corporation.
#
# This product includes software developed by the
# LSST Project (http://www.lsst.org/).
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the LSST License Statement and
# the GNU General Public License along with this program. If not,
# see <http://www.lsstcorp.org/LegalNotices/>.
#

import os
import unittest
import warnings
import lsst.daf.persistence as dafPersist
import lsst.pex.exceptions as pexExcept
import lsst.utils.tests as utilsTests
from lsst.utils import getPackageDir


class ButlerTestCase(unittest.TestCase):
"""Testing butler policy setup"""

def setUp(self):
try:
datadir = getPackageDir("testdata_decam")
except pexExcept.NotFoundError:
message = "testdata_decam not setup. Skipping."
warnings.warn(message)
raise unittest.SkipTest(message)

self.repoPath = os.path.join(datadir, "rawData")
self.butler = dafPersist.Butler(root=self.repoPath)

def tearDown(self):
del self.butler

def testButlerSubsetLevel(self):
"""Test if subset is gathered correctly for the specified level"""
subset = self.butler.subset("raw", level="ccd", visit=229388, ccdnum=1)
print("ButlerSubset.cache: %s" % subset.cache)
self.assertEqual(len(subset), 1)

subset = self.butler.subset("raw", level="ccd", visit=229388)
print("ButlerSubset.cache: %s" % subset.cache)
self.assertEqual(len(subset), 2)

subset = self.butler.subset("raw", level="visit", visit=229388)
print("ButlerSubset.cache: %s" % subset.cache)
self.assertEqual(len(subset), 1)


#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

def suite():
"""Returns a suite containing all the test cases in this module."""

utilsTests.init()

suites = []
suites += unittest.makeSuite(ButlerTestCase)
suites += unittest.makeSuite(utilsTests.MemoryTestCase)
return unittest.TestSuite(suites)


def run(shouldExit=False):
"""Run the tests"""
utilsTests.run(suite(), shouldExit)

if __name__ == "__main__":
run(True)