def testTable(self):
     """Test config.table
     """
     config = SelectSdssImagesTask.ConfigClass()
     config.table = "Bad_table_name_JutmgQEXm76O38VDtcNAICLrtQiSQ64y"
     task = SelectSdssImagesTask(config=config)
     for coordList in [
             None, getCoordList(333.746, -0.63606, 334.522, -0.41341)
     ]:
         filter = "g"
         with self.assertRaises(Exception):
             task.run(coordList, filter)
 def testFilterValidation(self):
     """Test filter name validation
     """
     coordList = getCoordList(333.7,-0.6,333.71,-0.59)
     config = SelectSdssImagesTask.ConfigClass()
     config.database = Database
     task = SelectSdssImagesTask(config=config)
     for charVal in range(ord("a"), ord("z")+1):
         filter = chr(charVal)
         if filter in ("u", "g", "r", "i", "z"):
             task.run(coordList=coordList, filter=filter)
         else:
             self.assertRaises(Exception, task.run, coordList, filter)
 def testFilterValidation(self):
     """Test filter name validation
     """
     coordList = getCoordList(333.7, -0.6, 333.71, -0.59)
     config = SelectSdssImagesTask.ConfigClass()
     config.database = Database
     task = SelectSdssImagesTask(config=config)
     for charVal in range(ord("a"), ord("z") + 1):
         filter = chr(charVal)
         if filter in ("u", "g", "r", "i", "z"):
             task.run(coordList=coordList, filter=filter)
         else:
             with self.assertRaises(Exception):
                 task.run(coordList, filter)
 def testMaxSky(self):
     """Test config.maxSky
     """
     for maxSky in (5.0e-9, 1.0e-8):
         config = SelectSdssImagesTask.ConfigClass()
         config.database = Database
         config.maxSky = maxSky
         task = SelectSdssImagesTask(config=config)
         coordList = getCoordList(333.746,-0.63606,334.522,-0.41341)
         filter = "g"
         expInfoList = task.run(coordList=coordList, filter=filter).exposureInfoList
         self.assertEqual(tuple(expInfo for expInfo in expInfoList if expInfo.sky > maxSky), ())
 def testMaxAirmass(self):
     """Test config.maxAirmass
     """
     for maxAirmass in (1.2, 1.3):
         config = SelectSdssImagesTask.ConfigClass()
         config.database = Database
         config.maxAirmass = maxAirmass
         task = SelectSdssImagesTask(config=config)
         coordList = getCoordList(333.746,-0.63606,334.522,-0.41341)
         filter = "g"
         expInfoList = task.run(coordList=coordList, filter=filter).exposureInfoList
         self.assertEqual(tuple(expInfo for expInfo in expInfoList if expInfo.airmass > maxAirmass), ())
 def testMaxExposures(self):
     """Test config.maxExposures
     """
     for maxExposures in (0, 6):
         config = SelectSdssImagesTask.ConfigClass()
         config.database = Database
         config.maxExposures = maxExposures
         task = SelectSdssImagesTask(config=config)
         coordList = getCoordList(333.746,-0.63606,334.522,-0.41341)
         filter = "g"
         expInfoList = task.run(coordList=coordList, filter=filter).exposureInfoList
         self.assertEqual(len(expInfoList), maxExposures)
 def testQuality(self):
     """Test config.quality
     """
     for quality in (1, 2, 3):
         config = SelectSdssImagesTask.ConfigClass()
         config.database = Database
         config.quality = quality
         task = SelectSdssImagesTask(config=config)
         coordList = getCoordList(333.746,-0.63606,334.522,-0.41341)
         filter = "g"
         expInfoList = task.run(coordList=coordList, filter=filter).exposureInfoList
         self.assertEqual(tuple(expInfo for expInfo in expInfoList if expInfo.quality < quality), ())
 def testCamcols(self):
     """Test config.camcols
     """
     for camcols in ((1, 3, 4), (2,)):
         config = SelectSdssImagesTask.ConfigClass()
         config.database = Database
         config.camcols = camcols
         task = SelectSdssImagesTask(config=config)
         coordList = getCoordList(333.746,-0.63606,334.522,-0.41341)
         filter = "g"
         expInfoList = task.run(coordList=coordList, filter=filter).exposureInfoList
         self.assertEqual(tuple(expInfo for expInfo in expInfoList if expInfo.dataId["camcol"] not in camcols), ())
 def testMaxExposures(self):
     """Test config.maxExposures
     """
     for maxExposures in (0, 6):
         config = SelectSdssImagesTask.ConfigClass()
         config.database = Database
         config.maxExposures = maxExposures
         task = SelectSdssImagesTask(config=config)
         coordList = getCoordList(333.746, -0.63606, 334.522, -0.41341)
         filter = "g"
         expInfoList = task.run(coordList=coordList,
                                filter=filter).exposureInfoList
         self.assertEqual(len(expInfoList), maxExposures)
 def testMaxRuns(self):                
     """Test config.maxRuns
     """
     for maxRuns in (0, 2):
         config = SelectSdssImagesTask.ConfigClass()
         config.database = Database
         config.maxRuns = maxRuns
         task = SelectSdssImagesTask(config=config)
         coordList = getCoordList(333.746,-0.63606,334.522,-0.41341)
         filter = "g"
         expInfoList = task.run(coordList=coordList, filter=filter).exposureInfoList
         runSet = set(expInfo.dataId["run"] for expInfo in expInfoList)
         self.assertEqual(len(runSet), maxRuns)
Ejemplo n.º 11
0
 def testMaxRuns(self):
     """Test config.maxRuns
     """
     for maxRuns in (0, 2):
         config = SelectSdssImagesTask.ConfigClass()
         config.database = Database
         config.maxRuns = maxRuns
         task = SelectSdssImagesTask(config=config)
         coordList = getCoordList(333.746, -0.63606, 334.522, -0.41341)
         filter = "g"
         expInfoList = task.run(coordList=coordList,
                                filter=filter).exposureInfoList
         runSet = set(expInfo.dataId["run"] for expInfo in expInfoList)
         self.assertEqual(len(runSet), maxRuns)
Ejemplo n.º 12
0
 def testMaxAirmass(self):
     """Test config.maxAirmass
     """
     for maxAirmass in (1.2, 1.3):
         config = SelectSdssImagesTask.ConfigClass()
         config.database = Database
         config.maxAirmass = maxAirmass
         task = SelectSdssImagesTask(config=config)
         coordList = getCoordList(333.746, -0.63606, 334.522, -0.41341)
         filter = "g"
         expInfoList = task.run(coordList=coordList,
                                filter=filter).exposureInfoList
         self.assertEqual(
             tuple(expInfo for expInfo in expInfoList
                   if expInfo.airmass > maxAirmass), ())
Ejemplo n.º 13
0
 def testCamcols(self):
     """Test config.camcols
     """
     for camcols in ((1, 3, 4), (2, )):
         config = SelectSdssImagesTask.ConfigClass()
         config.database = Database
         config.camcols = camcols
         task = SelectSdssImagesTask(config=config)
         coordList = getCoordList(333.746, -0.63606, 334.522, -0.41341)
         filter = "g"
         expInfoList = task.run(coordList=coordList,
                                filter=filter).exposureInfoList
         self.assertEqual(
             tuple(expInfo for expInfo in expInfoList
                   if expInfo.dataId["camcol"] not in camcols), ())
Ejemplo n.º 14
0
 def testMaxSky(self):
     """Test config.maxSky
     """
     for maxSky in (5.0e-9, 1.0e-8):
         config = SelectSdssImagesTask.ConfigClass()
         config.database = Database
         config.maxSky = maxSky
         task = SelectSdssImagesTask(config=config)
         coordList = getCoordList(333.746, -0.63606, 334.522, -0.41341)
         filter = "g"
         expInfoList = task.run(coordList=coordList,
                                filter=filter).exposureInfoList
         self.assertEqual(
             tuple(expInfo for expInfo in expInfoList
                   if expInfo.sky > maxSky), ())
Ejemplo n.º 15
0
 def testQuality(self):
     """Test config.quality
     """
     for quality in (1, 2, 3):
         config = SelectSdssImagesTask.ConfigClass()
         config.database = Database
         config.quality = quality
         task = SelectSdssImagesTask(config=config)
         coordList = getCoordList(333.746, -0.63606, 334.522, -0.41341)
         filter = "g"
         expInfoList = task.run(coordList=coordList,
                                filter=filter).exposureInfoList
         self.assertEqual(
             tuple(expInfo for expInfo in expInfoList
                   if expInfo.quality < quality), ())
 def testWholeSky(self):
     """Test whole-sky search (slow so don't do much)
     """
     config = SelectSdssImagesTask.ConfigClass()
     config.database = Database
     config.camcols = (2,)
     config.quality = 1
     config.rejectWholeRuns = False
     task = SelectSdssImagesTask(config=config)
     coordList = None
     filter = "g"
     expInfoList = task.run(coordList=coordList, filter=filter).exposureInfoList
     self.assertEqual(tuple(expInfo for expInfo in expInfoList if expInfo.quality < config.quality), ())
     print "found %s exposures" % (len(expInfoList),)
     self.assertEqual(tuple(expInfo for expInfo in expInfoList \
         if expInfo.dataId["camcol"] not in config.camcols), ())
 def testStrip(self):
     """Test config.strip
     """
     for strip in ("S", "N", "Auto", "Both"):
         config = SelectSdssImagesTask.ConfigClass()
         config.database = Database
         config.strip = strip
         task = SelectSdssImagesTask(config=config)
         coordList = getCoordList(333.746,-0.63606,334.522,-0.41341)
         dataId = {"filter": "g", "patch": "20,5"}
         runArgDict = task._runArgDictFromDataId(dataId)
         expInfoList = task.run(coordList=coordList, **runArgDict).exposureInfoList
         if strip in ("S","N"):
             self.assertEqual(tuple(expInfo for expInfo in expInfoList if expInfo.strip != strip), ())
         elif strip =="Auto":
             self.assertEqual(tuple(expInfo for expInfo in expInfoList if expInfo.strip != 'N'), ())
 def testCullBlacklisted(self):
     """Test config.cullBlacklisted
     """
     for cullBlacklisted in (False, True):
         config = SelectSdssImagesTask.ConfigClass()
         config.database = Database
         config.quality = 1
         config.cullBlacklisted = cullBlacklisted
         task = SelectSdssImagesTask(config=config)
         coordList = getCoordList(300,-0.63606,302,-0.41341)
         filter = "g"
         expInfoList = task.run(coordList=coordList, filter=filter).exposureInfoList
         blacklistedList = tuple(expInfo for expInfo in expInfoList if expInfo.isBlacklisted)
         if cullBlacklisted:
             self.assertEqual(blacklistedList, ())
         else:
             self.assertGreater(len(blacklistedList), 0)
 def testQScore(self):
     """Test QScore sorting
     """
     config = SelectSdssImagesTask.ConfigClass()
     config.database = Database
     config.quality = 1
     config.rejectWholeRuns = False
     task = SelectSdssImagesTask(config=config)
     coordList = getCoordList(333.746,-0.63606,334.522,-0.41341)
     filter = "g"
     expInfoList = task.run(coordList=coordList, filter=filter).exposureInfoList
     qscoreList = list(expInfo.qscore for expInfo in expInfoList)
     self.assertEqual(qscoreList, sorted(qscoreList))
     bestExp = expInfoList[0]
     worstExp = expInfoList[-1]
     self.assertGreater(worstExp.fwhm, bestExp.fwhm)
     self.assertGreater(worstExp.sky, bestExp.sky)
     self.assertGreater(bestExp.quality, worstExp.quality)
     self.assertEqual(bestExp.quality, 3)
Ejemplo n.º 20
0
 def testCullBlacklisted(self):
     """Test config.cullBlacklisted
     """
     for cullBlacklisted in (False, True):
         config = SelectSdssImagesTask.ConfigClass()
         config.database = Database
         config.quality = 1
         config.cullBlacklisted = cullBlacklisted
         task = SelectSdssImagesTask(config=config)
         coordList = getCoordList(300, -0.63606, 302, -0.41341)
         filter = "g"
         expInfoList = task.run(coordList=coordList,
                                filter=filter).exposureInfoList
         blacklistedList = tuple(expInfo for expInfo in expInfoList
                                 if expInfo.isBlacklisted)
         if cullBlacklisted:
             self.assertEqual(blacklistedList, ())
         else:
             self.assertGreater(len(blacklistedList), 0)
Ejemplo n.º 21
0
 def testWholeSky(self):
     """Test whole-sky search (slow so don't do much)
     """
     config = SelectSdssImagesTask.ConfigClass()
     config.database = Database
     config.camcols = (2, )
     config.quality = 1
     config.rejectWholeRuns = False
     task = SelectSdssImagesTask(config=config)
     coordList = None
     filter = "g"
     expInfoList = task.run(coordList=coordList,
                            filter=filter).exposureInfoList
     self.assertEqual(
         tuple(expInfo for expInfo in expInfoList
               if expInfo.quality < config.quality), ())
     print("found %s exposures" % (len(expInfoList), ))
     self.assertEqual(
         tuple(expInfo for expInfo in expInfoList
               if expInfo.dataId["camcol"] not in config.camcols), ())
Ejemplo n.º 22
0
 def testQScore(self):
     """Test QScore sorting
     """
     config = SelectSdssImagesTask.ConfigClass()
     config.database = Database
     config.quality = 1
     config.rejectWholeRuns = False
     task = SelectSdssImagesTask(config=config)
     coordList = getCoordList(333.746, -0.63606, 334.522, -0.41341)
     filter = "g"
     expInfoList = task.run(coordList=coordList,
                            filter=filter).exposureInfoList
     qscoreList = list(expInfo.qscore for expInfo in expInfoList)
     self.assertEqual(qscoreList, sorted(qscoreList))
     bestExp = expInfoList[0]
     worstExp = expInfoList[-1]
     self.assertGreater(worstExp.fwhm, bestExp.fwhm)
     self.assertGreater(worstExp.sky, bestExp.sky)
     self.assertGreater(bestExp.quality, worstExp.quality)
     self.assertEqual(bestExp.quality, 3)
Ejemplo n.º 23
0
 def testStrip(self):
     """Test config.strip
     """
     for strip in ("S", "N", "Auto", "Both"):
         config = SelectSdssImagesTask.ConfigClass()
         config.database = Database
         config.strip = strip
         task = SelectSdssImagesTask(config=config)
         coordList = getCoordList(333.746, -0.63606, 334.522, -0.41341)
         dataId = {"filter": "g", "patch": "20,5"}
         runArgDict = task._runArgDictFromDataId(dataId)
         expInfoList = task.run(coordList=coordList,
                                **runArgDict).exposureInfoList
         if strip in ("S", "N"):
             self.assertEqual(
                 tuple(expInfo for expInfo in expInfoList
                       if expInfo.strip != strip), ())
         elif strip == "Auto":
             self.assertEqual(
                 tuple(expInfo for expInfo in expInfoList
                       if expInfo.strip != 'N'), ())
 def testRejectWholeRuns(self):
     """Test config.rejectWholeRuns
     """
     config = SelectSdssImagesTask.ConfigClass()
     config.database = Database
     config.maxFwhm = 1.25 # make sure to cut out some partial runs due to bad exposures
     config.rejectWholeRuns = True
     task = SelectSdssImagesTask(config=config)
     minRa = 333.746
     maxRa = 334.522
     coordList = getCoordList(minRa,-0.63606,maxRa,-0.41341)
     filter = "g"
     expInfoList = task.run(coordList=coordList, filter=filter).exposureInfoList
     runExpInfoDict = dict()
     for expInfo in expInfoList:
         run = expInfo.dataId["run"]
         if run in runExpInfoDict:
             runExpInfoDict[run].append(expInfo)
         else:
             runExpInfoDict[run] = [expInfo]
     
     self.checkExpList(minRa, maxRa, runExpInfoDict)
 def testAcrossWrap(self):
     """Test rejectWholeRuns across the RA 0/360 boundary
     """
     config = SelectSdssImagesTask.ConfigClass()
     config.database = Database
     config.rejectWholeRuns = True
     task = SelectSdssImagesTask(config=config)
     minRa = 359
     maxRa = 1
     coordList = getCoordList(minRa,-0.63606,maxRa,-0.41341)
     filter = "g"
     expInfoList = task.run(coordList=coordList, filter=filter).exposureInfoList
     runExpInfoDict = dict()
     for expInfo in expInfoList:
         run = expInfo.dataId["run"]
         if run in runExpInfoDict:
             runExpInfoDict[run].append(expInfo)
         else:
             runExpInfoDict[run] = [expInfo]
     
     self.assertEqual(len(runExpInfoDict), 6)
     self.checkExpList(minRa, maxRa, runExpInfoDict)
Ejemplo n.º 26
0
    def testAcrossWrap(self):
        """Test rejectWholeRuns across the RA 0/360 boundary
        """
        config = SelectSdssImagesTask.ConfigClass()
        config.database = Database
        config.rejectWholeRuns = True
        task = SelectSdssImagesTask(config=config)
        minRa = 359
        maxRa = 1
        coordList = getCoordList(minRa, -0.63606, maxRa, -0.41341)
        filter = "g"
        expInfoList = task.run(coordList=coordList,
                               filter=filter).exposureInfoList
        runExpInfoDict = dict()
        for expInfo in expInfoList:
            run = expInfo.dataId["run"]
            if run in runExpInfoDict:
                runExpInfoDict[run].append(expInfo)
            else:
                runExpInfoDict[run] = [expInfo]

        self.assertEqual(len(runExpInfoDict), 6)
        self.checkExpList(minRa, maxRa, runExpInfoDict)
Ejemplo n.º 27
0
    def testRejectWholeRuns(self):
        """Test config.rejectWholeRuns
        """
        config = SelectSdssImagesTask.ConfigClass()
        config.database = Database
        config.maxFwhm = 1.25  # make sure to cut out some partial runs due to bad exposures
        config.rejectWholeRuns = True
        task = SelectSdssImagesTask(config=config)
        minRa = 333.746
        maxRa = 334.522
        coordList = getCoordList(minRa, -0.63606, maxRa, -0.41341)
        filter = "g"
        expInfoList = task.run(coordList=coordList,
                               filter=filter).exposureInfoList
        runExpInfoDict = dict()
        for expInfo in expInfoList:
            run = expInfo.dataId["run"]
            if run in runExpInfoDict:
                runExpInfoDict[run].append(expInfo)
            else:
                runExpInfoDict[run] = [expInfo]

        self.checkExpList(minRa, maxRa, runExpInfoDict)