def testApplyIGM(self): """Test application of IGM from Lookup Tables to SED objects""" #Test that a warning comes up if input redshift is out of range and that no changes occurs to SED testSed = Sed() testSed.readSED_flambda(os.environ['SIMS_SED_LIBRARY_DIR'] + '/galaxySED/Inst.80E09.25Z.spec.gz') testFlambda = [] for fVal in testSed.flambda: testFlambda.append(fVal) testIGM = ApplyIGM() testIGM.initializeIGM() with warnings.catch_warnings(record=True) as wa: testIGM.applyIGM(1.1, testSed) self.assertEqual(len(wa), 1) self.assertTrue('IGM Lookup tables' in str(wa[-1].message)) np.testing.assert_equal(testFlambda, testSed.flambda) #Test that lookup table is read in correctly testTable15 = np.genfromtxt(str(os.environ['SIMS_SED_LIBRARY_DIR'] + '/igm/' + 'MeanLookupTable_zSource1.5.tbl')) np.testing.assert_equal(testTable15, testIGM.meanLookups['1.5']) #Test output by making sure that an incoming sed with flambda = 1.0 everywhere will return the #transmission values of the lookup table as its flambda output testSed.setSED(testSed.wavelen, flambda = np.ones(len(testSed.wavelen))) testIGM.applyIGM(1.5, testSed) testTable15Above300 = testTable15[np.where(testTable15[:,0] >= 300.0)] testSed.resampleSED(wavelen_match = testTable15Above300[:,0]) np.testing.assert_allclose(testTable15Above300[:,1], testSed.flambda, 1e-4)
def testApplyIGM(self): """Test application of IGM from Lookup Tables to SED objects""" #Test that a warning comes up if input redshift is out of range and that no changes occurs to SED testSed = Sed() testSed.readSED_flambda(os.environ['SIMS_SED_LIBRARY_DIR'] + '/galaxySED/Inst.80E09.25Z.spec.gz') testFlambda = [] for fVal in testSed.flambda: testFlambda.append(fVal) testIGM = ApplyIGM() testIGM.initializeIGM() with warnings.catch_warnings(record=True) as wa: testIGM.applyIGM(1.1, testSed) self.assertEqual(len(wa), 1) self.assertTrue('IGM Lookup tables' in str(wa[-1].message)) np.testing.assert_equal(testFlambda, testSed.flambda) #Test that lookup table is read in correctly testTable15 = np.genfromtxt( str(os.environ['SIMS_SED_LIBRARY_DIR'] + '/igm/' + 'MeanLookupTable_zSource1.5.tbl')) np.testing.assert_equal(testTable15, testIGM.meanLookups['1.5']) #Test output by making sure that an incoming sed with flambda = 1.0 everywhere will return the #transmission values of the lookup table as its flambda output testSed.setSED(testSed.wavelen, flambda=np.ones(len(testSed.wavelen))) testIGM.applyIGM(1.5, testSed) testTable15Above300 = testTable15[np.where(testTable15[:, 0] >= 300.0)] testSed.resampleSED(wavelen_match=testTable15Above300[:, 0]) np.testing.assert_allclose(testTable15Above300[:, 1], testSed.flambda, 1e-4)
def testInitializeIGM(self): "Test Initialization Method" #Make sure that if we initialize IGM with new inputs that it is initializing with them testIGM = ApplyIGM() testSed = Sed() testSed.readSED_flambda(os.environ['SIMS_SED_LIBRARY_DIR'] + '/galaxySED/Inst.80E09.25Z.spec.gz') testIGM.applyIGM(1.8, testSed) testZmin = 1.8 testZmax = 2.2 #Want new values for testing, #so make sure we are not just putting in the same values as are already there self.assertNotEqual(testZmin, testIGM.zMin) self.assertNotEqual(testZmax, testIGM.zMax) testIGM.initializeIGM(zMin = testZmin, zMax = testZmax) self.assertEqual(testZmin, testIGM.zMin) self.assertEqual(testZmax, testIGM.zMax)
def testInitializeIGM(self): "Test Initialization Method" #Make sure that if we initialize IGM with new inputs that it is initializing with them testIGM = ApplyIGM() testSed = Sed() testSed.readSED_flambda(os.environ['SIMS_SED_LIBRARY_DIR'] + '/galaxySED/Inst.80E09.25Z.spec.gz') testIGM.applyIGM(1.8, testSed) testZmin = 1.8 testZmax = 2.2 #Want new values for testing, #so make sure we are not just putting in the same values as are already there self.assertNotEqual(testZmin, testIGM.zMin) self.assertNotEqual(testZmax, testIGM.zMax) testIGM.initializeIGM(zMin=testZmin, zMax=testZmax) self.assertEqual(testZmin, testIGM.zMin) self.assertEqual(testZmax, testIGM.zMax)
def testApplyIGM(self): """Test application of IGM from Lookup Tables to SED objects""" # Test that a warning comes up if input redshift is out # of range and that no changes occurs to SED testSed = Sed() sedName = os.path.join(getPackageDir('sims_photUtils'), 'tests/cartoonSedTestData/galaxySed/') testSed.readSED_flambda(os.path.join(sedName, 'Burst.10E08.002Z.spec.gz')) testFlambda = [] for fVal in testSed.flambda: testFlambda.append(fVal) testIGM = ApplyIGM() testIGM.initializeIGM() with warnings.catch_warnings(record=True) as wa: testIGM.applyIGM(1.1, testSed) self.assertEqual(len(wa), 1) self.assertIn('IGM Lookup tables', str(wa[-1].message)) np.testing.assert_equal(testFlambda, testSed.flambda) # Test that lookup table is read in correctly testTable15 = np.genfromtxt(str(getPackageDir('sims_photUtils') + '/python/lsst/sims/photUtils/igm_tables/' + 'MeanLookupTable_zSource1.5.tbl.gz')) np.testing.assert_equal(testTable15, testIGM.meanLookups['1.5']) # Test output by making sure that an incoming sed # with flambda = 1.0 everywhere will return the # transmission values of the lookup table as its # flambda output testSed.setSED(testSed.wavelen, flambda=np.ones(len(testSed.wavelen))) testIGM.applyIGM(1.5, testSed) testTable15Above300 = testTable15[np.where(testTable15[:, 0] >= 300.0)] testSed.resampleSED(wavelen_match = testTable15Above300[:, 0]) np.testing.assert_allclose(testTable15Above300[:, 1], testSed.flambda, 1e-4)
def testInitializeIGM(self): "Test Initialization Method" # Make sure that if we initialize IGM with new inputs that it # is initializing with them testIGM = ApplyIGM() testSed = Sed() sedName = os.path.join(getPackageDir('sims_photUtils'), 'tests/cartoonSedTestData/galaxySed/') testSed.readSED_flambda(os.path.join(sedName, 'Burst.10E08.002Z.spec.gz')) testIGM.applyIGM(1.8, testSed) testZmin = 1.8 testZmax = 2.2 # Want new values for testing, # so make sure we are not just putting in the same values # as are already there self.assertNotEqual(testZmin, testIGM.zMin) self.assertNotEqual(testZmax, testIGM.zMax) testIGM.initializeIGM(zMin = testZmin, zMax = testZmax) self.assertEqual(testZmin, testIGM.zMin) self.assertEqual(testZmax, testIGM.zMax)