當前位置: 首頁>>代碼示例>>Python>>正文


Python Sed.multiplySED方法代碼示例

本文整理匯總了Python中lsst.sims.photUtils.Sed.Sed.multiplySED方法的典型用法代碼示例。如果您正苦於以下問題:Python Sed.multiplySED方法的具體用法?Python Sed.multiplySED怎麽用?Python Sed.multiplySED使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在lsst.sims.photUtils.Sed.Sed的用法示例。


在下文中一共展示了Sed.multiplySED方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: read_asteroids_reflectance

# 需要導入模塊: from lsst.sims.photUtils.Sed import Sed [as 別名]
# 或者: from lsst.sims.photUtils.Sed.Sed import multiplySED [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.multiplySED方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。