Example #1
0
    def test_m5_exceptions(self):
        """
        Test that the correct exception is raised when you ask for a photometric
        uncertainty but do not define the required m5 value
        """
        obs = ObservationMetaData(pointingRA=25.0,
                                  pointingDec=-14.0,
                                  boundType='circle',
                                  boundLength=0.1,
                                  bandpassName=['u', 'g', 'r', 'z', 'y'],
                                  m5=[24.0] * 5,
                                  mjd=57388.0)

        with self.assertRaises(KeyError) as context:
            cat = testStars(self.star, obs_metadata=obs)
            with lsst.utils.tests.getTempFilePath('.txt') as catName:
                cat.write_catalog(catName)

        self.assertIn(
            'Is it possible your ObservationMetaData does not have the proper\nm5 values defined?',
            context.exception.args[0])

        with self.assertRaises(KeyError) as context:
            cat = testGalaxies(self.galaxy, obs_metadata=obs)
            with lsst.utils.tests.getTempFilePath('.txt') as catName:
                cat.write_catalog(catName)

        self.assertIn(
            'Is it possible your ObservationMetaData does not have the proper\nm5 values defined?',
            context.exception.args[0])
    def test_m5_exceptions(self):
        """
        Test that the correct exception is raised when you ask for a photometric
        uncertainty but do not define the required m5 value
        """
        obs = ObservationMetaData(pointingRA=25.0, pointingDec=-14.0,
                                  boundType='circle', boundLength=0.1,
                                  bandpassName=['u', 'g', 'r', 'z', 'y'],
                                  m5 = [24.0] * 5,
                                  mjd=57388.0)

        with self.assertRaises(KeyError) as context:
            cat = testStars(self.star, obs_metadata=obs)
            with lsst.utils.tests.getTempFilePath('.txt') as catName:
                cat.write_catalog(catName)

        self.assertIn('Is it possible your ObservationMetaData does not have the proper\nm5 values defined?',
                      context.exception.args[0])

        with self.assertRaises(KeyError) as context:
            cat = testGalaxies(self.galaxy, obs_metadata=obs)
            with lsst.utils.tests.getTempFilePath('.txt') as catName:
                cat.write_catalog(catName)

        self.assertIn('Is it possible your ObservationMetaData does not have the proper\nm5 values defined?',
                      context.exception.args[0])
Example #3
0
    def test_m5_exceptions(self):
        """
        Test that the correct exception is raised when you ask for a photometric
        uncertainty but do not define the required m5 value
        """

        catName = os.path.join(getPackageDir('sims_catUtils'), 'tests',
                               'scratchSpace', 'm5_exception_cat.txt')

        obs = ObservationMetaData(pointingRA=25.0,
                                  pointingDec=-14.0,
                                  boundType='circle',
                                  boundLength=0.1,
                                  bandpassName=['u', 'g', 'r', 'z', 'y'],
                                  m5=[24.0] * 5,
                                  mjd=57388.0)

        with self.assertRaises(KeyError) as context:
            cat = testStars(self.star, obs_metadata=obs)
            cat.write_catalog(catName)

        self.assertIn(
            'Is it possible your ObservationMetaData does not have the proper\nm5 values defined?',
            context.exception.args[0])

        with self.assertRaises(KeyError) as context:
            cat = testGalaxies(self.galaxy, obs_metadata=obs)
            cat.write_catalog(catName)

        self.assertIn(
            'Is it possible your ObservationMetaData does not have the proper\nm5 values defined?',
            context.exception.args[0])

        if os.path.exists(catName):
            os.unlink(catName)
 def testStarCatalog(self):
     test_cat = testStars(self.star, obs_metadata=self.obs_metadata)
     with lsst.utils.tests.getTempFilePath('.txt') as catName:
         test_cat.write_catalog(catName)
         with open(catName) as cat:
             lines = cat.readlines()
     self.assertGreater(len(lines), 1)  # to make sure we did not write an empty catalog
     results = self.star.query_columns(obs_metadata=self.obs_metadata)
     result = getOneChunk(results)
     self.assertGreater(len(result), 0)  # to make sure some results are returned
 def testStarVariability(self):
     starcat = testStars(self.star, obs_metadata=self.obs_metadata)
     results = self.star.query_columns(['varParamStr'], obs_metadata=self.obs_metadata,
                                      constraint='VarParamStr is not NULL')
     result = getOneChunk(results)
     ct = 0
     for row in result:
         ct += 1
         mags=starcat.applyVariability(row['varParamStr'])
     self.assertTrue(ct>0) #to make sure that the test was actually performed
 def testStarVariability(self):
     starcat = testStars(self.star, obs_metadata=self.obs_metadata)
     results = self.star.query_columns(['varParamStr'], obs_metadata=self.obs_metadata,
                                       constraint='VarParamStr is not NULL')
     result = getOneChunk(results)
     ct = 0
     for row in result:
         ct += 1
         # apply variability to make sure it doesn't fall down
         starcat.applyVariability([row['varParamStr']])
     self.assertGreater(ct, 0)  # to make sure that the test was actually performed
 def testStarCatalog(self):
     test_cat=testStars(self.star, obs_metadata=self.obs_metadata)
     test_cat.write_catalog("testStarsOutput.txt")
     cat = open("testStarsOutput.txt")
     lines = cat.readlines()
     self.assertTrue(len(lines)>1) #to make sure we did not write an empty catalog
     cat.close()
     results = self.star.query_columns(obs_metadata=self.obs_metadata)
     result = getOneChunk(results)
     self.assertTrue(len(result)>0) #to make sure some results are returned
     os.unlink("testStarsOutput.txt")
Example #8
0
 def testStarCatalog(self):
     test_cat = testStars(self.star, obs_metadata=self.obs_metadata)
     with lsst.utils.tests.getTempFilePath('.txt') as catName:
         test_cat.write_catalog(catName)
         with open(catName) as cat:
             lines = cat.readlines()
     self.assertGreater(len(lines),
                        1)  # to make sure we did not write an empty catalog
     results = self.star.query_columns(obs_metadata=self.obs_metadata)
     result = getOneChunk(results)
     self.assertGreater(len(result),
                        0)  # to make sure some results are returned
Example #9
0
 def testStarVariability(self):
     starcat = testStars(self.star, obs_metadata=self.obs_metadata)
     results = self.star.query_columns(['varParamStr'],
                                       obs_metadata=self.obs_metadata,
                                       constraint='VarParamStr is not NULL')
     result = getOneChunk(results)
     ct = 0
     for row in result:
         ct += 1
         # apply variability to make sure it doesn't fall down
         starcat.applyVariability([row['varParamStr']])
     self.assertGreater(
         ct, 0)  # to make sure that the test was actually performed
Example #10
0
    def testStarCatalog(self):
        catName = os.path.join(getPackageDir('sims_catUtils'), 'tests',
                               'scratchSpace', 'testPhotMixTestStarCat.txt')

        if os.path.exists(catName):
            os.unlink(catName)

        test_cat = testStars(self.star, obs_metadata=self.obs_metadata)
        test_cat.write_catalog(catName)
        cat = open(catName)
        lines = cat.readlines()
        self.assertGreater(len(lines),
                           1)  # to make sure we did not write an empty catalog
        cat.close()
        results = self.star.query_columns(obs_metadata=self.obs_metadata)
        result = getOneChunk(results)
        self.assertGreater(len(result),
                           0)  # to make sure some results are returned
        if os.path.exists(catName):
            os.unlink(catName)