【问题标题】:Using healpy.anafast on gamma ray maps在伽马射线图上使用healpy.anafast
【发布时间】:2013-11-19 19:18:17
【问题描述】:

我有一个适合格式的伽马射线图(具有表面亮度的图像)以及由 Aladin 转换器输出的 .hpx。

我希望计算角功率谱。如何创建一个可读的文件 healpy.anafast? 我似乎弄错了数据格式 (TypeErrors)。

我尝试的伽马射线图像之一是费米银河漫射。文件 是一个名为 gll_iem_v02_P6_V11_DIFFUSE.fit 的公共 LAT 银河漫反射图:

http://fermi.gsfc.nasa.gov/ssc/data/access/lat/BackgroundModels.html

我在使用时粘贴了下面的代码,但它本质上是astroml 上名为plot_wmap_power_spectra 的脚本:

    """
    WMAP power spectrum analysis with HealPy
    ----------------------------------------

    This demonstrates how to plot and take a power spectrum of the WMAP data
    using healpy, the python wrapper for healpix.  Healpy is available for
    download at the `github site <https://github.com/healpy/healpy>`_
    """
    # Author: Jake VanderPlas <vanderplas@astro.washington.edu>
    # License: BSD
    #   The figure is an example from astroML: see http://astroML.github.com
    import numpy as np
    from matplotlib import pyplot as plt

    # warning: due to a bug in healpy, importing it before pylab can cause
    #  a segmentation fault in some circumstances.
    import pylab
    import healpy as hp
    ###
    from astroML.datasets import fetch_wmap_temperatures
    ###

    #------------------------------------------------------------
    # Fetch the data
    ###
    wmap_unmasked = fetch_wmap_temperatures(masked=False)

    #PredictedSurfaceFluxFromModelMap =           np.arange(hp.read_map('PredictedSurfaceFluxFromModelMap.hpx[1]'))
    PredictedSurfaceFluxFromModelMap =   hp.read_map('gll_iem_v02_p6_V11_DIFFUSE.fit',dtype=np.float,verbose=True)
    #PredictedSurfaceFluxFromModelMap = hp.read_map('all.fits',dtype=np.float,verbose=True)
    #cl_out =  hp.read_cl('PredictedSurfaceFluxFromModelMap.hpx',dtype=np.float)#,verbose=True)
    wmap_masked = fetch_wmap_temperatures(masked=True)
    ###
    white_noise = np.ma.asarray(np.random.normal(0, 0.062, wmap_masked.shape))
    len(cl_out)

    #------------------------------------------------------------
    # plot the unmasked map
    fig = plt.figure(1)
    #hp.mollview(wmap_unmasked, min=-1, max=1, title='Unmasked map',
    #            fig=1, unit=r'$\Delta$T (mK)')
    ########----------------
    ##hp.mollview(PredictedSurfaceFluxFromModelMap, min=-1, max=1, title='Unmasked map',
    ##            fig=1, unit=r'$\Delta$T (mK)')
    ########----------------
    #------------------------------------------------------------
    # plot the masked map
    #  filled() fills the masked regions with a null value.
    ########----------------
    #fig = plt.figure(2)
    #hp.mollview(wmap_masked.filled(), title='Masked map',
    #            fig=2, unit=r'$\Delta$T (mK)')

    ########----------------
    #------------------------------------------------------------
    # compute and plot the power spectrum
    ########----------------
    #cl = hp.anafast(wmap_masked.filled(), lmax=1024)
    cl = hp.anafast(PredictedSurfaceFluxFromModelMap, lmax=1024)
    #cl = cl_out
    ########----------------
    ell = np.arange(len(cl))

    cl_white = hp.anafast(white_noise, lmax=1024)

    fig = plt.figure(3)
    ax = fig.add_subplot(111)
    ax.scatter(ell, ell * (ell + 1) * cl,
       s=4, c='black', lw=0,
       label='data')
     ax.scatter(ell, ell * (ell + 1) * cl_white,
       s=4, c='gray', lw=0,
       label='white noise')

     ax.set_xlabel(r'$\ell$')
     ax.set_ylabel(r'$\ell(\ell+1)C_\ell$')
     ax.set_title('Angular Power (not mask corrected)')
     ax.legend(loc='upper right')
     ax.grid()
     ax.set_xlim(0, 1100)

     plt.show()

【问题讨论】:

  • 我检查了gll_iem_v02_p6_V11_DIFFUSE.fit,它不是HEALPIx格式,所以你不能直接使用它。如果您设法使用 Aladin 将其转换为 HEALPIx,请将其发布到网上(也许是 figshare?),我们可以尝试一下。
  • 我拥有的文件是一个 .hpx 文件。我不确定figshare。我认为保管箱链接现在应该可以使用。 dropbox.com/s/m812luj8vdo47h1/gll_iem_v02_p6_V11_DIFFUSE.hpx

标签: python healpy


【解决方案1】:

I have uploaded your map also to Figshare,未来可能会在哪里提供。

获得 HEALPIx 格式的地图后,只需使用healpy 即可轻松阅读:

import healpy as hp
m = hp.ma(hp.read_map("gll_iem_v02_p6_V11_DIFFUSE.hpx"))

屏蔽 NaN 像素:

m.mask = np.isnan(m)

绘制它:

hp.mollview(m, min=-1e-5, max=1e-5, xsize=2000)
title("gll_iem_v02_p6_V11_DIFFUSE")

计算并绘制角功率谱:

plt.loglog(hp.anafast(m))

另见 IPython 笔记本:http://nbviewer.ipython.org/7553252

【讨论】:

    最近更新 更多