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


Python Sed.writeSED方法代码示例

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


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

示例1: read_asteroids_reflectance

# 需要导入模块: from lsst.sims.photUtils.Sed import Sed [as 别名]
# 或者: from lsst.sims.photUtils.Sed.Sed import writeSED [as 别名]
def read_asteroids_reflectance(dataDir='.'):
    # Read the sun's spectrum.
    sun = Sed()
    sun.readSED_flambda('kurucz_sun')
    # Read the asteroid reflectance spectra.
    allfiles = os.listdir(dataDir)
    
    asteroidDtype = numpy.dtype([
                                ('wavelength', numpy.float),
                                ('A', numpy.float),
                                ('A_sig', numpy.float),
                                ('B', numpy.float),
                                ('B_sig', numpy.float),
                                ('C', numpy.float),
                                ('C_sig', numpy.float),
                                ('Cb', numpy.float),
                                ('Cb_sig', numpy.float),
                                ('Cg', numpy.float),
                                ('Cg_sig', numpy.float),
                                ('Cgh', numpy.float),
                                ('Cgh_sig', numpy.float),
                                ('Ch', numpy.float),
                                ('Ch_sig', numpy.float),
                                ('D', numpy.float),
                                ('D_sig', numpy.float),
                                ('K', numpy.float),
                                ('K_sig', numpy.float),
                                ('L', numpy.float),
                                ('L_sig', numpy.float),
                                ('O', numpy.float),
                                ('O_sig', numpy.float),
                                ('Q', numpy.float),
                                ('Q_sig', numpy.float),
                                ('R', numpy.float),
                                ('R_sig', numpy.float),
                                ('S', numpy.float),
                                ('S_sig', numpy.float),
                                ('Sa', numpy.float),
                                ('Sa_sig', numpy.float),
                                ('Sq', numpy.float),
                                ('Sq_sig', numpy.float),
                                ('Sr', numpy.float),
                                ('Sr_sig', numpy.float),
                                ('Sv', numpy.float),
                                ('Sv_sig', numpy.float),
                                ('T', numpy.float),
                                ('T_sig', numpy.float),
                                ('V', numpy.float),
                                ('V_sig', numpy.float),
                                ('X', numpy.float),
                                ('X_sig', numpy.float),
                                ('Xc', numpy.float),
                                ('Xc_sig', numpy.float),
                                ('Xe', numpy.float),
                                ('Xe_sig', numpy.float),
                                ('Xk', numpy.float),
                                ('Xk_sig', numpy.float),
                                ])

    data = numpy.loadtxt(os.path.join(dataDir,'meanspectra.tab'),
                            dtype = asteroidDtype)

    data['wavelength'] *= 1000.0 #because spectra are in microns
 
    wavelen_step = min(numpy.diff(data['wavelength']).min(), numpy.diff(sun.wavelen).min())
    wavelen = numpy.arange(sun.wavelen[0], data['wavelength'][-1], wavelen_step)

    ast_reflect = {}
    for a in data.dtype.names:
        if a == 'wavelength' or a[-3:] == 'sig':
            continue

        # Read the basic reflectance data
        ast_reflect[a] = Sed(wavelen=data['wavelength'], flambda=data[a])

        # And now add an extrapolation to the blue end.
        # Binzel cuts off at 450nm.
        condition = ((ast_reflect[a].wavelen >= 450) & (ast_reflect[a].wavelen < 700))
        x = ast_reflect[a].wavelen[condition]
        y = ast_reflect[a].flambda[condition]
        p = numpy.polyfit(x, y, deg=2)
        condition = (wavelen < 450)
        flambda = numpy.zeros(len(wavelen), 'float')
        interpolated = numpy.polyval(p, wavelen[condition])
        flambda[condition] = [ii if ii > 0.0 else 0.0 for ii in interpolated]
        condition = (wavelen >= 450)
        flambda[condition] = numpy.interp(wavelen[condition], ast_reflect[a].wavelen, ast_reflect[a].flambda)
        ast_reflect[a] = Sed(wavelen, flambda)

    ast = {}
    for a in ast_reflect:
        ast[a] = sun.multiplySED(ast_reflect[a], wavelen_step=wavelen_step)

    for a in ast:
        name = a + '.dat'
        normalizedSed = Sed(wavelen=ast[a].wavelen, flambda=ast[a].flambda)
        norm = numpy.interp(500.0, normalizedSed.wavelen, normalizedSed.flambda)
        normalizedSed.multiplyFluxNorm(1.0/norm)
        normalizedSed.writeSED(name, print_header='21 April 2015; normalized to flambda=1 at 500nm')

#.........这里部分代码省略.........
开发者ID:craiglagegit,项目名称:Poisson_CCD22,代码行数:103,代码来源:astcolors.py


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