本文整理匯總了Python中lsst.sims.photUtils.Sed.Sed.setupPhiArray方法的典型用法代碼示例。如果您正苦於以下問題:Python Sed.setupPhiArray方法的具體用法?Python Sed.setupPhiArray怎麽用?Python Sed.setupPhiArray使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類lsst.sims.photUtils.Sed.Sed
的用法示例。
在下文中一共展示了Sed.setupPhiArray方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: testAlternateBandpassesStars
# 需要導入模塊: from lsst.sims.photUtils.Sed import Sed [as 別名]
# 或者: from lsst.sims.photUtils.Sed.Sed import setupPhiArray [as 別名]
def testAlternateBandpassesStars(self):
"""
This will test our ability to do photometry using non-LSST bandpasses.
It will first calculate the magnitudes using the getters in cartoonPhotometryStars.
It will then load the alternate bandpass files 'by hand' and re-calculate the magnitudes
and make sure that the magnitude values agree. This is guarding against the possibility
that some default value did not change and the code actually ended up loading the
LSST bandpasses.
"""
obs_metadata_pointed = ObservationMetaData(
mjd=2013.23, boundType="circle", unrefractedRA=200.0, unrefractedDec=-30.0, boundLength=1.0
)
bandpassDir = os.path.join(lsst.utils.getPackageDir("sims_photUtils"), "tests", "cartoonSedTestData")
cartoon_dict = BandpassDict.loadTotalBandpassesFromFiles(
["u", "g", "r", "i", "z"], bandpassDir=bandpassDir, bandpassRoot="test_bandpass_"
)
testBandPasses = {}
keys = ["u", "g", "r", "i", "z"]
bplist = []
for kk in keys:
testBandPasses[kk] = Bandpass()
testBandPasses[kk].readThroughput(os.path.join(bandpassDir, "test_bandpass_%s.dat" % kk))
bplist.append(testBandPasses[kk])
sedObj = Sed()
phiArray, waveLenStep = sedObj.setupPhiArray(bplist)
sedFileName = os.path.join(lsst.utils.getPackageDir("sims_sed_library"), "starSED", "kurucz")
sedFileName = os.path.join(sedFileName, "km20_5750.fits_g40_5790.gz")
ss = Sed()
ss.readSED_flambda(sedFileName)
controlBandpass = Bandpass()
controlBandpass.imsimBandpass()
ff = ss.calcFluxNorm(22.0, controlBandpass)
ss.multiplyFluxNorm(ff)
testMags = cartoon_dict.magListForSed(ss)
ss.resampleSED(wavelen_match=bplist[0].wavelen)
ss.flambdaTofnu()
mags = -2.5 * numpy.log10(numpy.sum(phiArray * ss.fnu, axis=1) * waveLenStep) - ss.zp
self.assertTrue(len(mags) == len(testMags))
self.assertTrue(len(mags) > 0)
for j in range(len(mags)):
self.assertAlmostEqual(mags[j], testMags[j], 10)
示例2: testAlternateBandpassesStars
# 需要導入模塊: from lsst.sims.photUtils.Sed import Sed [as 別名]
# 或者: from lsst.sims.photUtils.Sed.Sed import setupPhiArray [as 別名]
def testAlternateBandpassesStars(self):
"""
This will test our ability to do photometry using non-LSST bandpasses.
It will first calculate the magnitudes using the getters in cartoonPhotometryStars.
It will then load the alternate bandpass files 'by hand' and re-calculate the magnitudes
and make sure that the magnitude values agree. This is guarding against the possibility
that some default value did not change and the code actually ended up loading the
LSST bandpasses.
"""
obs_metadata_pointed = ObservationMetaData(mjd=2013.23,
boundType='circle',
pointingRA=200.0, pointingDec=-30.0,
boundLength=1.0)
test_cat = cartoonStars(self.star, obs_metadata=obs_metadata_pointed)
with lsst.utils.tests.getTempFilePath('.txt') as catName:
test_cat.write_catalog(catName)
with open(catName, 'r') as input_file:
lines = input_file.readlines()
self.assertGreater(len(lines), 1)
cartoonDir = os.path.join(getPackageDir('sims_photUtils'), 'tests', 'cartoonSedTestData')
testBandPasses = {}
keys = ['u', 'g', 'r', 'i', 'z']
bplist = []
for kk in keys:
testBandPasses[kk] = Bandpass()
testBandPasses[kk].readThroughput(os.path.join(cartoonDir, "test_bandpass_%s.dat" % kk))
bplist.append(testBandPasses[kk])
sedObj = Sed()
phiArray, waveLenStep = sedObj.setupPhiArray(bplist)
i = 0
# since all of the SEDs in the cartoon database are the same, just test on the first
# if we ever include more SEDs, this can be something like
# for ss in test_cata.sedMasterList:
ss = test_cat.sedMasterList[0]
ss.resampleSED(wavelen_match = bplist[0].wavelen)
ss.flambdaTofnu()
mags = -2.5*np.log10(np.sum(phiArray*ss.fnu, axis=1)*waveLenStep) - ss.zp
self.assertEqual(len(mags), len(test_cat.cartoonBandpassDict))
self.assertGreater(len(mags), 0)
for j in range(len(mags)):
self.assertAlmostEqual(mags[j], test_cat.magnitudeMasterList[i][j], 4)
示例3: testAlternateBandpassesStars
# 需要導入模塊: from lsst.sims.photUtils.Sed import Sed [as 別名]
# 或者: from lsst.sims.photUtils.Sed.Sed import setupPhiArray [as 別名]
def testAlternateBandpassesStars(self):
"""
This will test our ability to do photometry using non-LSST bandpasses.
It will first calculate the magnitudes using the getters in cartoonPhotometryStars.
It will then load the alternate bandpass files 'by hand' and re-calculate the magnitudes
and make sure that the magnitude values agree. This is guarding against the possibility
that some default value did not change and the code actually ended up loading the
LSST bandpasses.
"""
obs_metadata_pointed=ObservationMetaData(mjd=2013.23,
boundType='circle',unrefractedRA=200.0,unrefractedDec=-30.0,
boundLength=1.0)
test_cat=cartoonStars(self.star,obs_metadata=obs_metadata_pointed)
test_cat.write_catalog("testStarsCartoon.txt")
cartoonDir = os.getenv('SIMS_PHOTUTILS_DIR')+'/tests/cartoonSedTestData/'
testBandPasses = {}
keys = ['u','g','r','i','z']
bplist = []
for kk in keys:
testBandPasses[kk] = Bandpass()
testBandPasses[kk].readThroughput(os.path.join(cartoonDir,"test_bandpass_%s.dat" % kk))
bplist.append(testBandPasses[kk])
sedObj = Sed()
phiArray, waveLenStep = sedObj.setupPhiArray(bplist)
i = 0
#since all of the SEDs in the cartoon database are the same, just test on the first
#if we ever include more SEDs, this can be something like
#for ss in test_cata.sedMasterList:
#
ss=test_cat.sedMasterList[0]
ss.resampleSED(wavelen_match = bplist[0].wavelen)
ss.flambdaTofnu()
mags = -2.5*numpy.log10(numpy.sum(phiArray*ss.fnu, axis=1)*waveLenStep) - ss.zp
self.assertTrue(len(mags)==len(test_cat.bandpassDict))
self.assertTrue(len(mags)>0)
for j in range(len(mags)):
self.assertAlmostEqual(mags[j],test_cat.magnitudeMasterList[i][j],10)
i += 1
os.unlink("testStarsCartoon.txt")
示例4: testAlternateBandpassesGalaxies
# 需要導入模塊: from lsst.sims.photUtils.Sed import Sed [as 別名]
# 或者: from lsst.sims.photUtils.Sed.Sed import setupPhiArray [as 別名]
def testAlternateBandpassesGalaxies(self):
"""
the same as testAlternateBandpassesStars, but for galaxies
"""
obs_metadata_pointed=ObservationMetaData(mjd=50000.0,
boundType='circle',unrefractedRA=0.0,unrefractedDec=0.0,
boundLength=10.0)
test_cat=cartoonGalaxies(self.galaxy,obs_metadata=obs_metadata_pointed)
test_cat.write_catalog("testGalaxiesCartoon.txt")
cartoonDir = os.getenv('SIMS_PHOTUTILS_DIR')+'/tests/cartoonSedTestData/'
testBandPasses = {}
keys = ['u','g','r','i','z']
bplist = []
for kk in keys:
testBandPasses[kk] = Bandpass()
testBandPasses[kk].readThroughput(os.path.join(cartoonDir,"test_bandpass_%s.dat" % kk))
bplist.append(testBandPasses[kk])
sedObj = Sed()
phiArray, waveLenStep = sedObj.setupPhiArray(bplist)
components = ['Bulge', 'Disk', 'Agn']
ct = 0
for cc in components:
i = 0
for ss in test_cat.sedMasterDict[cc]:
if ss.wavelen != None:
ss.resampleSED(wavelen_match = bplist[0].wavelen)
ss.flambdaTofnu()
mags = -2.5*numpy.log10(numpy.sum(phiArray*ss.fnu, axis=1)*waveLenStep) - ss.zp
for j in range(len(mags)):
ct += 1
self.assertAlmostEqual(mags[j],test_cat.magnitudeMasterDict[cc][i][j],10)
i += 1
self.assertTrue(ct>0)
os.unlink("testGalaxiesCartoon.txt")