def testLoadMLT(self): """Test SED loading algorithm by making sure SEDs are all accounted for""" #Test Matching to mlt SEDs loadTestMLT = matchStar(mltDir = self.testMLTDir) testSEDs = loadTestMLT.loadmltSEDs() #Read in a list of the SEDs in the mlt test sed directory testMLTList = os.listdir(self.testMLTDir) #First make sure that all SEDs are correctly accounted for if no subset provided testNames = [] for testSED in testSEDs: testNames.append(testSED.name) self.assertItemsEqual(testMLTList, testNames) #Next make sure that correct subset loads if subset is provided testSubsetList = testMLTList[0:2] testSEDsubset = loadTestMLT.loadmltSEDs(subset = testSubsetList) testSubsetNames = [] for testSED in testSEDsubset: testSubsetNames.append(testSED.name) self.assertItemsEqual(testSubsetList, testSubsetNames) #Test that attributes have been assigned for testSED in testSEDsubset: self.assertIsNotNone(testSED.name)
def testLoadKurucz(self): """Test SED loading algorithm by making sure SEDs are all accounted for """ # Test Matching to Kurucz SEDs loadTestKurucz = matchStar(kuruczDir = self.testKDir) testSEDs = loadTestKurucz.loadKuruczSEDs() # Read in a list of the SEDs in the kurucz test sed directory testKuruczList = os.listdir(self.testKDir) # First make sure that all SEDs are correctly accounted for if no subset provided testNames = [] for testSED in testSEDs: testNames.append(testSED.name) # Python 3 replaces assertItemsEqual() with assertCountEqual() if hasattr(self, 'assertItemsEqual'): self.assertItemsEqual(testKuruczList, testNames) else: self.assertCountEqual(testKuruczList, testNames) # Test same condition if subset is provided testSubsetList = ['km01_7000.fits_g40_7140.gz', 'kp01_7000.fits_g40_7240.gz'] testSEDsSubset = loadTestKurucz.loadKuruczSEDs(subset = testSubsetList) # Next make sure that correct subset loads if subset is provided testSubsetNames = [] testSubsetLogZ = [] testSubsetLogG = [] testSubsetTemp = [] for testSED in testSEDsSubset: testSubsetNames.append(testSED.name) testSubsetLogZ.append(testSED.logZ) testSubsetLogG.append(testSED.logg) testSubsetTemp.append(testSED.temp) # Python 3 replaces assertItemsEqual() with assertCountEqual() if hasattr(self, 'assertItemsEqual'): self.assertItemsEqual(testSubsetList, testSubsetNames) else: self.assertCountEqual(testSubsetList, testSubsetNames) self.assertEqual(testSubsetLogZ, [-0.1, 0.1]) # Test both pos. and neg. get in right self.assertEqual(testSubsetLogG, [4.0, 4.0]) # Test storage of logg and temp self.assertEqual(testSubsetTemp, [7140, 7240]) # Test that attributes have been assigned for testSED in testSEDsSubset: self.assertIsNotNone(testSED.name) self.assertIsNotNone(testSED.logZ) self.assertIsNotNone(testSED.logg) self.assertIsNotNone(testSED.temp)
def testLoadWD(self): """Test SED loading algorithm by making sure SEDs are all accounted for and that there are separate lists for H and HE.""" # Test Matching to WD SEDs loadTestWD = matchStar(wdDir = self.testWDDir) testSEDsH, testSEDsHE = loadTestWD.loadwdSEDs() # Add extra step because WD SEDs are separated into helium and hydrogen testNames = [] for testH in testSEDsH: testNames.append(testH.name) for testHE in testSEDsHE: testNames.append(testHE.name) # Read in a list of the SEDs in the wd test sed directory testWDList = os.listdir(self.testWDDir) # First make sure that all SEDs are correctly accounted for if no subset provided # Python 3 replaces assertItemsEqual() with assertCountEqual() if hasattr(self, 'assertItemsEqual'): self.assertItemsEqual(testNames, testWDList) else: self.assertCountEqual(testNames, testWDList) # Test same condition if subset is provided testSubsetList = ['bergeron_10000_75.dat_10100.gz', 'bergeron_He_9000_80.dat_9400.gz'] testSEDsSubsetH, testSEDsSubsetHE = selectStarSED(wdDir= self.testWDDir).loadwdSEDs(subset= testSubsetList) testNamesSubset = [] for testH in testSEDsSubsetH: testNamesSubset.append(testH.name) for testHE in testSEDsSubsetHE: testNamesSubset.append(testHE.name) # Next make sure that correct subset loads if subset is provided # Python 3 replaces assertItemsEqual() with assertCountEqual() if hasattr(self, 'assertItemsEqual'): self.assertItemsEqual(testNamesSubset, testSubsetList) else: self.assertCountEqual(testNamesSubset, testSubsetList) # Make sure that the names get separated into correct wd type self.assertEqual(testSEDsSubsetH[0].name, testSubsetList[0]) self.assertEqual(testSEDsSubsetHE[0].name, testSubsetList[1])
def testLoadKurucz(self): """Test SED loading algorithm by making sure SEDs are all accounted for """ #Test Matching to Kurucz SEDs loadTestKurucz = matchStar(kuruczDir = self.testKDir) testSEDs = loadTestKurucz.loadKuruczSEDs() #Read in a list of the SEDs in the kurucz test sed directory testKuruczList = os.listdir(self.testKDir) #First make sure that all SEDs are correctly accounted for if no subset provided testNames = [] for testSED in testSEDs: testNames.append(testSED.name) self.assertItemsEqual(testKuruczList, testNames) #Test same condition if subset is provided testSubsetList = ['km01_7000.fits_g40_7140.gz', 'kp01_7000.fits_g40_7240.gz'] testSEDsSubset = loadTestKurucz.loadKuruczSEDs(subset = testSubsetList) #Next make sure that correct subset loads if subset is provided testSubsetNames = [] testSubsetLogZ = [] testSubsetLogG = [] testSubsetTemp = [] for testSED in testSEDsSubset: testSubsetNames.append(testSED.name) testSubsetLogZ.append(testSED.logZ) testSubsetLogG.append(testSED.logg) testSubsetTemp.append(testSED.temp) self.assertItemsEqual(testSubsetList, testSubsetNames) self.assertEqual(testSubsetLogZ, [-0.1, 0.1]) #Test both pos. and neg. get in right self.assertEqual(testSubsetLogG, [4.0, 4.0]) #Test storage of logg and temp self.assertEqual(testSubsetTemp, [7140, 7240]) #Test that attributes have been assigned for testSED in testSEDsSubset: self.assertIsNotNone(testSED.name) self.assertIsNotNone(testSED.logZ) self.assertIsNotNone(testSED.logg) self.assertIsNotNone(testSED.temp)
def testLoadWD(self): """Test SED loading algorithm by making sure SEDs are all accounted for and that there are separate lists for H and HE.""" #Test Matching to WD SEDs loadTestWD = matchStar(wdDir = self.testWDDir) testSEDsH, testSEDsHE = loadTestWD.loadwdSEDs() #Add extra step because WD SEDs are separated into helium and hydrogen testNames = [] for testH in testSEDsH: testNames.append(testH.name) for testHE in testSEDsHE: testNames.append(testHE.name) #Read in a list of the SEDs in the wd test sed directory testWDList = os.listdir(self.testWDDir) #First make sure that all SEDs are correctly accounted for if no subset provided self.assertItemsEqual(testNames, testWDList) #Test same condition if subset is provided testSubsetList = ['bergeron_10000_75.dat_10100.gz', 'bergeron_He_9000_80.dat_9400.gz'] testSEDsSubsetH, testSEDsSubsetHE = selectStarSED().loadwdSEDs(subset = testSubsetList) testNamesSubset = [] for testH in testSEDsSubsetH: testNamesSubset.append(testH.name) for testHE in testSEDsSubsetHE: testNamesSubset.append(testHE.name) #Next make sure that correct subset loads if subset is provided self.assertItemsEqual(testNamesSubset, testSubsetList) #Make sure that the names get separated into correct wd type self.assertEqual(testSEDsSubsetH[0].name, testSubsetList[0]) self.assertEqual(testSEDsSubsetHE[0].name, testSubsetList[1])
def testDefaults(self): """Make sure that if there are Nones for the init that they load the correct dirs""" loadTest = matchStar() self.assertEqual(loadTest.kuruczDir, self.kDir) self.assertEqual(loadTest.mltDir, self.mltDir) self.assertEqual(loadTest.wdDir, self.wdDir)