Coverage for tests/testCompoundCatalogs.py : 32%

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
GalaxyAgnObj, GalaxyTileCompoundObj, StarObj)
'componentra', 'componentdec', 'magNorm', 'sedFilename', 'majorAxis', 'minorAxis', 'positionAngle', 'halfLightRadius', 'internalExtinctionModel', 'internalAv', 'internalRv']
'componentra', 'componentdec', 'magNorm', 'sedFilename', 'variabilityParameters']
'glon', 'glat', 'magNorm', 'properMotionRa', 'properMotionDec', 'parallax', 'galacticAv', 'radialVelocity', 'variabilityParameters', 'sedFilename']
self.baseDir = tempfile.mkdtemp(dir=ROOT, prefix='compoundCatalogTest-')
if os.path.exists(self.baseDir): shutil.rmtree(self.baseDir)
"We are not connected to fatboy") def testGalaxyCatalog(self): """ Test GalaxyTileCompoundObj by creating a catalog of galaxy bulges, disks, and agns using both the 'old fashioned way' (one catalog at a time), and using CompoundInstanceCatalog """ controlFileName = os.path.join(self.baseDir, 'gal_compound_control.txt') testFileName = os.path.join(self.baseDir, 'gal_compound_test.txt')
if os.path.exists(controlFileName): os.unlink(controlFileName) if os.path.exists(testFileName): os.unlink(testFileName)
obs = ObservationMetaData(pointingRA=25.0, pointingDec=-45.0, boundType='circle', boundLength=0.05)
dbBulge = GalaxyBulgeObj() dbDisk = GalaxyDiskObj() dbAgn = GalaxyAgnObj()
catBulge = BulgeDiskCatalog(dbBulge, obs_metadata=obs) catDisk = BulgeDiskCatalog(dbDisk, obs_metadata=obs) catAgn = AgnCatalog(dbAgn, obs_metadata=obs)
catBulge.write_catalog(controlFileName, write_header=False, chunk_size=10000) catDisk.write_catalog(controlFileName, write_mode='a', write_header=False, chunk_size=10000) catAgn.write_catalog(controlFileName, write_mode='a', write_header=False, chunk_size=10000)
totalCat = CompoundInstanceCatalog([BulgeDiskCatalog, BulgeDiskCatalog, AgnCatalog], [GalaxyDiskObj, GalaxyBulgeObj, GalaxyAgnObj], obs_metadata=obs, compoundDBclass=GalaxyTileCompoundObj)
totalCat.write_catalog(testFileName, write_header=False, chunk_size=10000)
with open(controlFileName, 'r') as controlFile: control = controlFile.readlines()
with open(testFileName, 'r') as testFile: test = testFile.readlines()
for line in control: self.assertIn(line, test)
for line in test: self.assertIn(line, control)
"We are not connected to fatboy") def testGalaxyAndStarCatalog(self): """ Test GalaxyTileCompoundObj by creating a catalog of galaxy bulges, disks, agns, and stars using both the 'old fashioned way' (one catalog at a time), and using CompoundInstanceCatalog """ controlFileName = os.path.join(self.baseDir, 'galStar_compound_control.txt') testFileName = os.path.join(self.baseDir, 'galStar_compound_test.txt')
if os.path.exists(controlFileName): os.unlink(controlFileName) if os.path.exists(testFileName): os.unlink(testFileName)
obs = ObservationMetaData(pointingRA=25.0, pointingDec=-45.0, boundType='circle', boundLength=0.05)
dbBulge = GalaxyBulgeObj() dbDisk = GalaxyDiskObj() dbAgn = GalaxyAgnObj() dbStar = StarObj()
catBulge = BulgeDiskCatalog(dbBulge, obs_metadata=obs) catDisk = BulgeDiskCatalog(dbDisk, obs_metadata=obs) catAgn = AgnCatalog(dbAgn, obs_metadata=obs) catStar = StarCatalog(dbStar, obs_metadata=obs)
catBulge.write_catalog(controlFileName, write_header=False, chunk_size=10000) catDisk.write_catalog(controlFileName, write_mode='a', write_header=False, chunk_size=10000) catAgn.write_catalog(controlFileName, write_mode='a', write_header=False, chunk_size=10000) catStar.write_catalog(controlFileName, write_mode='a', write_header=False, chunk_size=10000)
totalCat = CompoundInstanceCatalog([BulgeDiskCatalog, BulgeDiskCatalog, StarCatalog, AgnCatalog], [GalaxyBulgeObj, GalaxyDiskObj, StarObj, GalaxyAgnObj], obs_metadata=obs, compoundDBclass=GalaxyTileCompoundObj)
totalCat.write_catalog(testFileName, write_header=False, chunk_size=10000)
with open(controlFileName, 'r') as controlFile: control = controlFile.readlines()
with open(testFileName, 'r') as testFile: test = testFile.readlines()
for line in control: self.assertIn(line, test)
for line in test: self.assertIn(line, control)
lsst.utils.tests.init() unittest.main() |