Coverage for tests/testPhoSimVariability.py : 51%

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
testGalaxyBulgeDBObj, testGalaxyAgnDBObj) PhoSimCatalogZPoint)
lsst.utils.tests.init()
""" This class will test that variability gets correctly propagated into PhoSim catalogs """
def setUpClass(cls): cls.dbName = tempfile.mktemp(dir=ROOT, prefix='PhoSimVariabilityDatabase-', suffix='.db') cls.obs_metadata = makePhoSimTestDB(size=10, filename=cls.dbName) cls.obs_metadata.mjd = ModifiedJulianDate(TAI=60000.0)
cls.bulgeDB = testGalaxyBulgeDBObj(driver='sqlite', database=cls.dbName) cls.diskDB = testGalaxyDiskDBObj(driver='sqlite', database=cls.dbName) cls.agnDB = testGalaxyAgnDBObj(driver='sqlite', database=cls.dbName) cls.starDB = testStarsDBObj(driver='sqlite', database=cls.dbName)
def tearDownClass(cls): sims_clean_up() del cls.bulgeDB del cls.diskDB del cls.agnDB del cls.starDB if os.path.exists(cls.dbName): os.unlink(cls.dbName)
""" Test that variability is correctly added to PhoSim Agn catalogs by outputting both a variable PhoSim catalog and a control catalog and making sure that the magNorm column in the PhoSim catalog is equal to the sum of the magNorm column in the control plus the detla_mag column from Variability. """ baseline = AgnControlCatalog(self.agnDB, obs_metadata=self.obs_metadata) test = PhoSimZPointVariable(self.agnDB, obs_metadata=self.obs_metadata)
for bb, tt in zip(baseline.iter_catalog(), test.iter_catalog()): msg = 'baseline mag %.6e; delta %.6e' % (bb[0], bb[1]) self.assertAlmostEqual(bb[0] + bb[1], tt[4], 10, msg=msg) self.assertGreater(np.abs(bb[1]), 0.0)
""" Test that variability is correctly added to PhoSim star catalogs by outputting both a variable PhoSim catalog and a control catalog and making sure that the magNorm column in the PhoSim catalog is equal to the sum of the magNorm column in the control plus the detla_mag column from Variability. """ baseline = StarControlCatalog(self.starDB, obs_metadata=self.obs_metadata) test = PhoSimPointVariable(self.starDB, obs_metadata=self.obs_metadata)
for bb, tt in zip(baseline.iter_catalog(), test.iter_catalog()): msg = 'baseline mag %.6e; delta %.6e' % (bb[0], bb[1]) self.assertAlmostEqual(bb[0] + bb[1], tt[4], 10, msg=msg) self.assertGreater(np.abs(bb[1]), 0.0)
""" Make sure that the magNorm output to PhoSim catalogs that lack variability is the same as the column 'magNorm' taken from the database """ baseline = BulgeControlCatalog(self.bulgeDB, obs_metadata=self.obs_metadata) test = PhoSimCatalogSersic2D(self.bulgeDB, obs_metadata=self.obs_metadata)
for bb, tt in zip(baseline.iter_catalog(), test.iter_catalog()): self.assertAlmostEqual(bb[0], tt[4], 10)
baseline = DiskControlCatalog(self.diskDB, obs_metadata=self.obs_metadata) test = PhoSimCatalogSersic2D(self.diskDB, obs_metadata=self.obs_metadata)
for bb, tt in zip(baseline.iter_catalog(), test.iter_catalog()): self.assertAlmostEqual(bb[0], tt[4], 10)
lsst.utils.tests.init() unittest.main() |