def testStandAloneStellarPhotometry(self): """ Test that it is possible to run PhotometryStars.calculate_magnitudes outside of the context of an InstanceCatalog """ objectID = ['1','2','3'] sedNames = ['km20_5750.fits_g40_5790','m2.0Full.dat', 'bergeron_6500_85.dat_6700'] magNorm = [28.5, 23.0, 21.0] dummyId = ['1', '2'] dummySed = ['km20_5750.fits_g40_5790','m2.0Full.dat'] dummyMagNorm = [28.5, 23.0] bandpassNames = ['u','g','r','i','z','y'] phot = PhotometryStars() phot.loadTotalBandpassesFromFiles(bandpassNames) self.assertRaises(RuntimeError, phot.calculate_magnitudes, objectID=dummyId, sedNames=sedNames, magNorm=magNorm) self.assertRaises(RuntimeError, phot.calculate_magnitudes, objectID=objectID, sedNames=dummySed, magNorm=magNorm) self.assertRaises(RuntimeError, phot.calculate_magnitudes, objectID=objectID, sedNames=sedNames, magNorm=dummyMagNorm) magnitudes = phot.calculate_magnitudes(objectID=objectID, sedNames=sedNames, magNorm=magNorm) for n in objectID: self.assertTrue(len(magnitudes[n])==len(bandpassNames)) #to make sure we calculated all the magnitudes
def testPhotometricIndicesRaw(self): """ Use manMagCalc_list with specified indices on an Sed. Make sure that the appropriate magnitudes are or are not Nan """ starName = os.path.join(lsst.utils.getPackageDir('sims_sed_library'),defaultSpecMap['km20_5750.fits_g40_5790']) starPhot = PhotometryStars() starPhot.loadTotalBandpassesFromFiles() testSed = Sed() testSed.readSED_flambda(starName) indices = [1,3] mags = starPhot.manyMagCalc_list(testSed, indices=indices) self.assertTrue(numpy.isnan(mags[0])) self.assertFalse(numpy.isnan(mags[1])) self.assertTrue(numpy.isnan(mags[2])) self.assertFalse(numpy.isnan(mags[3])) self.assertTrue(numpy.isnan(mags[4])) self.assertTrue(numpy.isnan(mags[5])) self.assertTrue(len(mags)==6)