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])
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 testGalaxyCatalog(self): test_cat = testGalaxies(self.galaxy, 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.galaxy.query_columns(obs_metadata=self.obs_metadata) result = getOneChunk(results) self.assertGreater(len(result), 0) # to make sure some results are returned
def testGalaxyVariability(self): galcat = testGalaxies(self.galaxy, obs_metadata=self.obs_metadata) results = self.galaxy.query_columns(['varParamStr'], obs_metadata=self.obs_metadata, constraint='VarParamStr is not NULL') result = getOneChunk(results) ct = 0 for row in result: mags=galcat.applyVariability(row['varParamStr']) ct += 1 self.assertTrue(ct>0) #to make sure that the test was actually performed
def testGalaxyCatalog(self): test_cat=testGalaxies(self.galaxy, obs_metadata=self.obs_metadata) test_cat.write_catalog("testGalaxiesOutput.txt") cat = open("testGalaxiesOutput.txt") lines = cat.readlines() self.assertTrue(len(lines)>1) #to make sure we did not write an empty catalog cat.close() results = self.galaxy.query_columns(obs_metadata=self.obs_metadata) result = getOneChunk(results) self.assertTrue(len(result)>0) #to make sure some results are returned os.unlink("testGalaxiesOutput.txt")
def testGalaxyVariability(self): galcat = testGalaxies(self.galaxy, obs_metadata=self.obs_metadata) results = self.galaxy.query_columns(['varParamStr'], obs_metadata=self.obs_metadata, constraint='VarParamStr is not NULL') result = getOneChunk(results) ct = 0 for row in result: # apply variability to make sure that it does not fall down galcat.applyVariability([row['varParamStr']]) ct += 1 self.assertGreater(ct, 0) # to make sure that the test was actually performed
def testGalaxyVariability(self): galcat = testGalaxies(self.galaxy, obs_metadata=self.obs_metadata) results = self.galaxy.query_columns( ['varParamStr'], obs_metadata=self.obs_metadata, constraint='VarParamStr is not NULL') result = getOneChunk(results) ct = 0 for row in result: # apply variability to make sure that it does not fall down galcat.applyVariability([row['varParamStr']]) ct += 1 self.assertGreater( ct, 0) # to make sure that the test was actually performed
def testGalaxyCatalog(self): catName = os.path.join(getPackageDir('sims_catUtils'), 'tests', 'scratchSpace', 'testPhotMixTestGalCat.txt') if os.path.exists(catName): os.unlink(catName) test_cat = testGalaxies(self.galaxy, 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.galaxy.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)