当前位置: 首页>>代码示例>>Python>>正文


Python BandpassDict.loadTotalBandpassesFromFiles方法代码示例

本文整理汇总了Python中lsst.sims.photUtils.BandpassDict.loadTotalBandpassesFromFiles方法的典型用法代码示例。如果您正苦于以下问题:Python BandpassDict.loadTotalBandpassesFromFiles方法的具体用法?Python BandpassDict.loadTotalBandpassesFromFiles怎么用?Python BandpassDict.loadTotalBandpassesFromFiles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在lsst.sims.photUtils.BandpassDict的用法示例。


在下文中一共展示了BandpassDict.loadTotalBandpassesFromFiles方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testLoadTotalBandpassesFromFiles

# 需要导入模块: from lsst.sims.photUtils import BandpassDict [as 别名]
# 或者: from lsst.sims.photUtils.BandpassDict import loadTotalBandpassesFromFiles [as 别名]
    def testLoadTotalBandpassesFromFiles(self):
        """
        Test that the class method loadTotalBandpassesFromFiles produces the
        expected result
        """

        bandpassDir = os.path.join(getPackageDir('sims_photUtils'), 'tests', 'cartoonSedTestData')
        bandpassNames = ['g', 'r', 'u']
        bandpassRoot = 'test_bandpass_'

        bandpassDict = BandpassDict.loadTotalBandpassesFromFiles(bandpassNames=bandpassNames,
                                                                 bandpassDir=bandpassDir,
                                                                 bandpassRoot = bandpassRoot)

        controlBandpassList = []
        for bpn in bandpassNames:
            dummyBp = Bandpass()
            dummyBp.readThroughput(os.path.join(bandpassDir,bandpassRoot+bpn+'.dat'))
            controlBandpassList.append(dummyBp)

        wMin = controlBandpassList[0].wavelen[0]
        wMax = controlBandpassList[0].wavelen[-1]
        wStep = controlBandpassList[0].wavelen[1]-controlBandpassList[0].wavelen[0]

        for bp in controlBandpassList:
            bp.resampleBandpass(wavelen_min=wMin, wavelen_max=wMax, wavelen_step=wStep)

        for test, control in zip(bandpassDict.values(), controlBandpassList):
            numpy.testing.assert_array_almost_equal(test.wavelen, control.wavelen, 19)
            numpy.testing.assert_array_almost_equal(test.sb, control.sb, 19)
开发者ID:jonathansick-shadow,项目名称:sims_photUtils,代码行数:32,代码来源:testBandpassDict.py

示例2: testLSSTmags

# 需要导入模块: from lsst.sims.photUtils import BandpassDict [as 别名]
# 或者: from lsst.sims.photUtils.BandpassDict import loadTotalBandpassesFromFiles [as 别名]
    def testLSSTmags(self):
        """
        Test that PhotometrySSM properly calculates LSST magnitudes
        """
        cat = LSST_SSM_photCat(self.photDB)

        dtype = np.dtype([('id', np.int), ('u', np.float), ('g', np.float),
                          ('r', np.float), ('i', np.float), ('z', np.float),
                          ('y', np.float)])

        with lsst.utils.tests.getTempFilePath('.txt') as catName:
            cat.write_catalog(catName)
            testData = np.genfromtxt(catName, dtype=dtype, delimiter=',')
        self.assertGreater(len(testData), 0)

        controlData = np.genfromtxt(self.dbFile, dtype=self.dtype)
        self.assertGreater(len(controlData), 0)

        LSSTbandpasses = BandpassDict.loadTotalBandpassesFromFiles()
        controlSedList = SedList(controlData['sedFilename'], controlData['magNorm'],
                                 wavelenMatch=LSSTbandpasses.wavelenMatch,
                                 fileDir=getPackageDir('sims_sed_library'),
                                 specMap=defaultSpecMap)

        controlMags = LSSTbandpasses.magListForSedList(controlSedList)

        for ii in range(len(controlMags)):
            for jj, bpName in enumerate(['u', 'g', 'r', 'i', 'z', 'y']):
                self.assertAlmostEqual(controlMags[ii][jj], testData[bpName][ii], 10)
开发者ID:lsst,项目名称:sims_catUtils,代码行数:31,代码来源:testSSMmixins.py

示例3: get_test_disk_mags

# 需要导入模块: from lsst.sims.photUtils import BandpassDict [as 别名]
# 或者: from lsst.sims.photUtils.BandpassDict import loadTotalBandpassesFromFiles [as 别名]
    def get_test_disk_mags(self):

        if not hasattr(self, 'testBandpassDict'):
            self.testBandpassDict = BandpassDict.loadTotalBandpassesFromFiles()

        return self._magnitudeGetter('disk', self.testBandpassDict,
                                     self.get_test_disk_mags._colnames)
开发者ID:jonathansick-shadow,项目名称:sims_catUtils,代码行数:9,代码来源:testVariabilityInfrastructure.py

示例4: testLSSTmags

# 需要导入模块: from lsst.sims.photUtils import BandpassDict [as 别名]
# 或者: from lsst.sims.photUtils.BandpassDict import loadTotalBandpassesFromFiles [as 别名]
    def testLSSTmags(self):
        """
        Test that PhotometrySSM properly calculates LSST magnitudes
        """
        catName = os.path.join(getPackageDir('sims_catUtils'), 'tests', 'scratchSpace', 'lsstSsmPhotCat.txt')

        cat=LSST_SSM_photCat(self.photDB)
        cat.write_catalog(catName)

        dtype = np.dtype([('id', np.int), ('u', np.float), ('g', np.float),
                          ('r', np.float), ('i', np.float), ('z', np.float),
                          ('y', np.float)])

        testData = np.genfromtxt(catName, dtype=dtype, delimiter=',')
        self.assertGreater(len(testData), 0)

        controlData = np.genfromtxt(self.dbFile, dtype=self.dtype)
        self.assertGreater(len(controlData), 0)

        LSSTbandpasses = BandpassDict.loadTotalBandpassesFromFiles()
        controlSedList = SedList(controlData['sedFilename'], controlData['magNorm'],
                                 wavelenMatch=LSSTbandpasses.wavelenMatch)

        controlMags = LSSTbandpasses.magListForSedList(controlSedList)

        for ii in range(len(controlMags)):
            for jj, bpName in enumerate(['u', 'g', 'r', 'i', 'z', 'y']):
                self.assertAlmostEqual(controlMags[ii][jj], testData[bpName][ii], 10)

        if os.path.exists(catName):
            os.unlink(catName)
开发者ID:jonathansick-shadow,项目名称:sims_catUtils,代码行数:33,代码来源:testSSMmixins.py

示例5: get_quiescent_lsst_magnitudes

# 需要导入模块: from lsst.sims.photUtils import BandpassDict [as 别名]
# 或者: from lsst.sims.photUtils.BandpassDict import loadTotalBandpassesFromFiles [as 别名]
    def get_quiescent_lsst_magnitudes(self):

        if not hasattr(self, 'lsstBandpassDict'):
            self.lsstBandpassDict = BandpassDict.loadTotalBandpassesFromFiles()

        return self._quiescentMagnitudeGetter(self.lsstBandpassDict,
                                              self.get_quiescent_lsst_magnitudes._colnames)
开发者ID:lsst,项目名称:sims_catUtils,代码行数:9,代码来源:PhotometryMixin.py

示例6: get_lsst_magnitudes

# 需要导入模块: from lsst.sims.photUtils import BandpassDict [as 别名]
# 或者: from lsst.sims.photUtils.BandpassDict import loadTotalBandpassesFromFiles [as 别名]
    def get_lsst_magnitudes(self):
        """
        getter for LSST magnitudes of solar system objects
        """
        if not hasattr(self, 'lsstBandpassDict'):
            self.lsstBandpassDict = BandpassDict.loadTotalBandpassesFromFiles()

        return self._quiescentMagnitudeGetter(self.lsstBandpassDict, self.get_lsst_magnitudes._colnames)
开发者ID:lsst,项目名称:sims_catUtils,代码行数:10,代码来源:PhotometryMixin.py

示例7: get_test_mags

# 需要导入模块: from lsst.sims.photUtils import BandpassDict [as 别名]
# 或者: from lsst.sims.photUtils.BandpassDict import loadTotalBandpassesFromFiles [as 别名]
    def get_test_mags(self):
        if not hasattr(self, 'variabilitybandpassDict'):
            self.variabilityBandpassDict = BandpassDict.loadTotalBandpassesFromFiles()

        self._loadSedList(self.variabilityBandpassDict.wavelenMatch)
        if not hasattr(self, '_sedList'):
            return numpy.ones((6,0))

        return self._magnitudeGetter(self.variabilityBandpassDict, self.get_test_mags._colnames)
开发者ID:jonathansick-shadow,项目名称:sims_catUtils,代码行数:11,代码来源:testVariabilityInfrastructure.py

示例8: get_test_agn_mags

# 需要导入模块: from lsst.sims.photUtils import BandpassDict [as 别名]
# 或者: from lsst.sims.photUtils.BandpassDict import loadTotalBandpassesFromFiles [as 别名]
    def get_test_agn_mags(self):

        if not hasattr(self, 'testBandpassDict'):
            self.testBandpassDict = BandpassDict.loadTotalBandpassesFromFiles()

        mag = self._quiescentMagnitudeGetter('agn', self.testBandpassDict,
                                             self.get_test_agn_mags._colnames)
        mag += self._variabilityGetter(self.get_test_agn_mags._colnames)
        return mag
开发者ID:lsst,项目名称:sims_catUtils,代码行数:11,代码来源:testVariabilityInfrastructure.py

示例9: testManyMagSystems

# 需要导入模块: from lsst.sims.photUtils import BandpassDict [as 别名]
# 或者: from lsst.sims.photUtils.BandpassDict import loadTotalBandpassesFromFiles [as 别名]
    def testManyMagSystems(self):
        """
        Test that the SSM photometry mixin can simultaneously calculate magnitudes
        in multiple bandpass systems
        """
        catName = os.path.join(getPackageDir('sims_catUtils'), 'tests', 'scratchSpace', 'compoundSsmPhotCat.txt')

        cat=Compound_SSM_photCat(self.photDB)
        cat.write_catalog(catName)

        dtype = np.dtype([('id', np.int), ('lsst_u', np.float), ('lsst_g', np.float),
                          ('lsst_r', np.float), ('lsst_i', np.float), ('lsst_z', np.float),
                          ('lsst_y', np.float),
                          ('cartoon_u', np.float), ('cartoon_g', np.float),
                          ('cartoon_r', np.float), ('cartoon_i', np.float),
                          ('cartoon_z', np.float)])

        testData = np.genfromtxt(catName, dtype=dtype, delimiter=',')
        self.assertGreater(len(testData), 0)

        controlData = np.genfromtxt(self.dbFile, dtype=self.dtype)
        self.assertGreater(len(controlData), 0)

        LSSTbandpasses = BandpassDict.loadTotalBandpassesFromFiles()
        cartoonBandpasses = BandpassDict.loadTotalBandpassesFromFiles(
                                  ['u', 'g', 'r', 'i', 'z'],
                                  bandpassDir = os.path.join(getPackageDir('sims_photUtils'), 'tests', 'cartoonSedTestData'),
                                  bandpassRoot = 'test_bandpass_'
                                  )

        controlSedList = SedList(controlData['sedFilename'], controlData['magNorm'],
                                 wavelenMatch=LSSTbandpasses.wavelenMatch)

        controlLsstMags = LSSTbandpasses.magListForSedList(controlSedList)
        controlCartoonMags = cartoonBandpasses.magListForSedList(controlSedList)

        for ii in range(len(controlLsstMags)):
            for jj, bpName in enumerate(['lsst_u', 'lsst_g', 'lsst_r', 'lsst_i', 'lsst_z', 'lsst_y']):
                self.assertAlmostEqual(controlLsstMags[ii][jj], testData[bpName][ii], 10)
            for jj, bpName in enumerate(['cartoon_u', 'cartoon_g', 'cartoon_r', 'cartoon_i', 'cartoon_z']):
                self.assertAlmostEqual(controlCartoonMags[ii][jj], testData[bpName][ii], 10)

        if os.path.exists(catName):
            os.unlink(catName)
开发者ID:jonathansick-shadow,项目名称:sims_catUtils,代码行数:46,代码来源:testSSMmixins.py

示例10: get_cartoon_mags

# 需要导入模块: from lsst.sims.photUtils import BandpassDict [as 别名]
# 或者: from lsst.sims.photUtils.BandpassDict import loadTotalBandpassesFromFiles [as 别名]
    def get_cartoon_mags(self):
        if not hasattr(self, 'cartoonBandpassDict'):

            bandpassDir = os.path.join(getPackageDir('sims_photUtils'), 'tests', 'cartoonSedTestData')

            self.cartoonBandpassDict = \
            BandpassDict.loadTotalBandpassesFromFiles(bandpassNames = ['u', 'g', 'r', 'i', 'z'],
                                                      bandpassDir = bandpassDir,
                                                      bandpassRoot = 'test_bandpass_')

        return self._quiescentMagnitudeGetter(self.cartoonBandpassDict, self.get_cartoon_mags._colnames)
开发者ID:lsst,项目名称:sims_catUtils,代码行数:13,代码来源:testArbitraryUncertaintyGetters.py

示例11: get_magnitudes

# 需要导入模块: from lsst.sims.photUtils import BandpassDict [as 别名]
# 或者: from lsst.sims.photUtils.BandpassDict import loadTotalBandpassesFromFiles [as 别名]
    def get_magnitudes(self):
        """
        Example photometry getter for alternative (i.e. non-LSST) bandpasses
        """
        if not hasattr(self, 'cartoonBandpassDict'):
            bandpassNames = ['u','g','r','i','z']
            bandpassDir = os.path.join(getPackageDir('sims_photUtils'), 'tests', 'cartoonSedTestData')
            self.cartoonBandpassDict = BandpassDict.loadTotalBandpassesFromFiles(bandpassNames,bandpassDir = bandpassDir,
                                                                    bandpassRoot = 'test_bandpass_')

        return self._quiescentMagnitudeGetter(self.cartoonBandpassDict, self.get_magnitudes._colnames)
开发者ID:lsst,项目名称:sims_catUtils,代码行数:13,代码来源:CatalogTestUtils.py

示例12: testAlternateBandpassesStars

# 需要导入模块: from lsst.sims.photUtils import BandpassDict [as 别名]
# 或者: from lsst.sims.photUtils.BandpassDict import loadTotalBandpassesFromFiles [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)
开发者ID:mpwiesner,项目名称:sims_photUtils,代码行数:56,代码来源:testPhotometry.py

示例13: testMatchToRestFrame

# 需要导入模块: from lsst.sims.photUtils import BandpassDict [as 别名]
# 或者: from lsst.sims.photUtils.BandpassDict import loadTotalBandpassesFromFiles [as 别名]
    def testMatchToRestFrame(self):
        """Test that Galaxies with no effects added into catalog mags are matched correctly."""
        np.random.seed(42)
        galPhot = BandpassDict.loadTotalBandpassesFromFiles()

        imSimBand = Bandpass()
        imSimBand.imsimBandpass()

        testMatching = selectGalaxySED(galDir = self.testSpecDir)
        testSEDList = testMatching.loadBC03()

        testSEDNames = []
        testMags = []
        testMagNormList = []
        magNormStep = 1

        for testSED in testSEDList:

            getSEDMags = Sed()
            testSEDNames.append(testSED.name)
            getSEDMags.setSED(wavelen = testSED.wavelen, flambda = testSED.flambda)
            testMagNorm = np.round(np.random.uniform(20.0,22.0),magNormStep)
            testMagNormList.append(testMagNorm)
            fluxNorm = getSEDMags.calcFluxNorm(testMagNorm, imSimBand)
            getSEDMags.multiplyFluxNorm(fluxNorm)
            testMags.append(galPhot.magListForSed(getSEDMags))

        #Also testing to make sure passing in non-default bandpasses works
        #Substitute in nan values to simulate incomplete data.
        testMags[0][1] = np.nan
        testMags[0][2] = np.nan
        testMags[0][4] = np.nan
        testMags[1][1] = np.nan
        testMatchingResults = testMatching.matchToRestFrame(testSEDList, testMags,
                                                            bandpassDict = galPhot)
        self.assertEqual(None, testMatchingResults[0][0])
        self.assertEqual(testSEDNames[1:], testMatchingResults[0][1:])
        self.assertEqual(None, testMatchingResults[1][0])
        np.testing.assert_almost_equal(testMagNormList[1:], testMatchingResults[1][1:], decimal = magNormStep)

        #Test Match Errors
        errMags = np.array((testMags[2], testMags[2], testMags[2], testMags[2]))
        errMags[1,1] += 1. #Total MSE will be 2/(5 colors) = 0.4
        errMags[2, 0:2] = np.nan
        errMags[2, 3] += 1. #Total MSE will be 2/(3 colors) = 0.667
        errMags[3, :] = None
        errSED = testSEDList[2]
        testMatchingResultsErrors = testMatching.matchToRestFrame([errSED], errMags,
                                                                  bandpassDict = galPhot)
        np.testing.assert_almost_equal(np.array((0.0, 0.4, 2./3.)), testMatchingResultsErrors[2][0:3],
                                       decimal = 3)
        self.assertEqual(None, testMatchingResultsErrors[2][3])
开发者ID:jonathansick-shadow,项目名称:sims_photUtils,代码行数:54,代码来源:testMatchSEDs.py

示例14: setUpClass

# 需要导入模块: from lsst.sims.photUtils import BandpassDict [as 别名]
# 或者: from lsst.sims.photUtils.BandpassDict import loadTotalBandpassesFromFiles [as 别名]
    def setUpClass(cls):
        cls.scratchDir = os.path.join(getPackageDir('sims_GalSimInterface'), 'tests', 'scratchSpace')
        cls.obs = ObservationMetaData(pointingRA=122.0, pointingDec=-29.1,
                                      mjd=57381.2, rotSkyPos=43.2)


        cls.camera = camTestUtils.CameraWrapper().camera

        cls.dbFileName = os.path.join(cls.scratchDir, 'allowed_chips_test_db.txt')
        if os.path.exists(cls.dbFileName):
            os.unlink(cls.dbFileName)

        cls.controlSed = Sed()
        cls.controlSed.readSED_flambda(os.path.join(getPackageDir('sims_sed_library'),
                                               'flatSED','sed_flat.txt.gz'))
        cls.magNorm = 18.1
        imsim = Bandpass()
        imsim.imsimBandpass()
        ff = cls.controlSed.calcFluxNorm(cls.magNorm, imsim)
        cls.controlSed.multiplyFluxNorm(ff)
        a_x, b_x = cls.controlSed.setupCCMab()
        cls.controlSed.addCCMDust(a_x, b_x, A_v=0.1, R_v=3.1)
        bpd = BandpassDict.loadTotalBandpassesFromFiles()
        pp = PhotometricParameters()
        cls.controlADU = cls.controlSed.calcADU(bpd['u'], pp)
        cls.countSigma = np.sqrt(cls.controlADU/pp.gain)

        cls.x_pix = 50
        cls.y_pix = 50

        x_list = []
        y_list = []
        name_list = []
        for dd in cls.camera:
            x_list.append(cls.x_pix)
            y_list.append(cls.y_pix)
            name_list.append(dd.getName())

        x_list = np.array(x_list)
        y_list = np.array(y_list)

        ra_list, dec_list = raDecFromPixelCoords(x_list, y_list, name_list,
                                                 camera=cls.camera, obs_metadata=cls.obs,
                                                 epoch=2000.0)

        dra_list = 3600.0*(ra_list-cls.obs.pointingRA)
        ddec_list = 3600.0*(dec_list-cls.obs.pointingDec)

        create_text_catalog(cls.obs, cls.dbFileName, dra_list, ddec_list,
                            mag_norm=[cls.magNorm]*len(dra_list))

        cls.db = allowedChipsFileDBObj(cls.dbFileName, runtable='test')
开发者ID:jonathansick-shadow,项目名称:sims_GalSimInterface,代码行数:54,代码来源:testAllowedChips.py

示例15: get_lsst_agn_mags

# 需要导入模块: from lsst.sims.photUtils import BandpassDict [as 别名]
# 或者: from lsst.sims.photUtils.BandpassDict import loadTotalBandpassesFromFiles [as 别名]
    def get_lsst_agn_mags(self):
        """
        Getter for AGN magnitudes in the LSST bandpasses
        """

        # load a BandpassDict of LSST bandpasses, if not done already
        if not hasattr(self, 'lsstBandpassDict'):
            self.lsstBandpassDict = BandpassDict.loadTotalBandpassesFromFiles()

        # actually calculate the magnitudes
        mag = self._quiescentMagnitudeGetter('agn', self.lsstBandpassDict,
                                             self.get_lsst_agn_mags._colnames)

        mag += self._variabilityGetter(self.get_lsst_agn_mags._colnames)
        return mag
开发者ID:lsst,项目名称:sims_catUtils,代码行数:17,代码来源:PhotometryMixin.py


注:本文中的lsst.sims.photUtils.BandpassDict.loadTotalBandpassesFromFiles方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。