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


Python Sed.setupCCMab方法代码示例

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


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

示例1: SNObjectSED

# 需要导入模块: from lsst.sims.photUtils.Sed import Sed [as 别名]
# 或者: from lsst.sims.photUtils.Sed.Sed import setupCCMab [as 别名]
    def SNObjectSED(self, time, wavelen=None, bandpass=None,
                    applyExtinction=True):
        '''
        return a `lsst.sims.photUtils.sed` object from the SN model at the
        requested time and wavelengths with or without extinction from MW
        according to the SED extinction methods. The wavelengths may be
        obtained from a `lsst.sims.Bandpass` object or a `lsst.sims.BandpassDict`
        object instead. (Currently, these have the same wavelengths). See notes
        for details on handling of exceptions.

        If the sed is requested at times outside the validity range of the
        model, the flux density is returned as 0. If the time is within the
        range of validity of the model, but the wavelength range requested
        is outside the range, then the returned fluxes are np.nan outside
        the range, and the model fluxes inside

        Parameters
        ----------
        time: float
            time of observation
        wavelen: `np.ndarray` of floats, optional, defaults to None
            array containing wavelengths in nm
        bandpass: `lsst.sims.photUtils.Bandpass` object or
            `lsst.sims.photUtils.BandpassDict`, optional, defaults to `None`.
            Using the dict assumes that the wavelength sampling and range
            is the same for all elements of the dict.

            if provided, overrides wavelen input and the SED is
            obtained at the wavelength values native to bandpass
            object.


        Returns
        -------
        `sims_photutils.sed` object containing the wavelengths and SED
        values from the SN at time time in units of ergs/cm^2/sec/nm


        .. note: If both wavelen and bandpassobject are `None` then exception,
                 will be raised.
        Examples
        --------
        >>> sed = SN.SNObjectSED(time=0., wavelen=wavenm)
        '''

        if wavelen is None and bandpass is None:
            raise ValueError('A non None input to either wavelen or\
                              bandpassobject must be provided')

        # if bandpassobject present, it overrides wavelen
        if bandpass is not None:
            if isinstance(bandpass, BandpassDict):
                firstfilter = bandpass.keys()[0]
                bp = bandpass[firstfilter]
            else:
                bp = bandpass
            # remember this is in nm
            wavelen = bp.wavelen

        flambda = np.zeros(len(wavelen))

        # self.mintime() and self.maxtime() are properties describing
        # the ranges of SNCosmo.Model in time.

        # Set SED to 0 beyond the model phase range, will change this if
        # SNCosmo includes a more sensible decay later.
        if (time > self.mintime()) & (time < self.maxtime()):

            # If SNCosmo is requested a SED value beyond the model range
            # it will crash. Try to prevent that by returning np.nan for
            # such wavelengths. This will still not help band flux calculations
            # but helps us get past this stage.

            flambda = flambda * np.nan

            # Convert to Ang
            wave = wavelen * 10.0
            mask1 = wave > self.minwave()
            mask2 = wave < self.maxwave()
            mask = mask1 & mask2
            wave = wave[mask]

            # flux density dE/dlambda returned from SNCosmo in
            # ergs/cm^2/sec/Ang, convert to ergs/cm^2/sec/nm

            flambda[mask] = self.flux(time=time, wave=wave)
            flambda[mask] = flambda[mask] * 10.0

        SEDfromSNcosmo = Sed(wavelen=wavelen, flambda=flambda)

        if not applyExtinction:
            return SEDfromSNcosmo

        # Apply LSST extinction
        ax, bx = SEDfromSNcosmo.setupCCMab()

        if self.ebvofMW is None:
            raise ValueError('ebvofMW attribute cannot be None Type and must'
                             ' be set by hand using set_MWebv before this'
                             'stage, or by using setcoords followed by'
#.........这里部分代码省略.........
开发者ID:jonathansick-shadow,项目名称:sims_catUtils,代码行数:103,代码来源:snObject.py


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