コード例 #1
0
ファイル: gDrawRef.py プロジェクト: mahmoud-lsw/GRATools
def main():
    """Test module
    """
    plt.figure()
    leg, lab = ref_igrb_band()
    igrb, lab2 = ref_igrb_noFGsub()
    plt.xscale('log')
    plt.yscale('log')
    plt.legend([leg, igrb], [lab, lab2])
    plt.show()
コード例 #2
0
def main():
    """
    """
    cl_f = 'output/output_pol/mask_check_cl.txt'
    cov_f = 'output/output_pol/mask_check_cov.fits'
    l, cl = pol_cl_parse(cl_f)
    clerr = pol_cov_parse(cov_f)
    #plt.errorbar(l, cl, fmt='o', markersize=3, elinewidth=1, yerr=clerr)
    plt.plot(l, cl, 'o', markersize=3)
    plt.xscale('log')
    plt.yscale('log')
    #plt.ylim(-1e-15, 1e-15)
    plt.show()
コード例 #3
0
ファイル: gFTools.py プロジェクト: mahmoud-lsw/GRATools
def main():
    """
    crbkg_PSF1_file =  os.path.join(GRATOOLS_CONFIG, 
                                    'ascii/p8r2_bkg_flux_t8.txt')
    crbkg_PSF1 = get_crbkg(crbkg_PSF1_file)
    crbkg_PSF1.plot(show=False)
    x = crbkg_PSF1.x
    xx = x**2
    print x
    y1 =  crbkg_PSF1.y
    crbkg_PSF2_file =  os.path.join(GRATOOLS_CONFIG, 
                                    'ascii/p8r2_bkg_flux_t16.txt')
    crbkg_PSF2 = get_crbkg(crbkg_PSF2_file)
    crbkg_PSF2.plot(show=False)
    y2 =  crbkg_PSF2(x)
    crbkg_PSF3_file =  os.path.join(GRATOOLS_CONFIG, 
                                    'ascii/p8r2_bkg_flux_t32.txt')
    crbkg_PSF3 = get_crbkg(crbkg_PSF3_file)
    crbkg_PSF3.plot(show=False)
    y3 =  crbkg_PSF2(x)
    y = (y1/x+y2/x+y3/x)*x
    print y
    plt.yscale('log')
    plt.xscale('log')
    plt.show()
    
    fore_files_list = [os.path.join(GRATOOLS_CONFIG, \
                                        'fits/gll_iem_v06_hp512_146647.fits'),
                       os.path.join(GRATOOLS_CONFIG, \
                                        'fits/gll_iem_v06_hp512_200561.fits'),
                       os.path.join(GRATOOLS_CONFIG, \
                                        'fits/gll_iem_v06_hp512_274296.fits'),
                       os.path.join(GRATOOLS_CONFIG, \
                                        'fits/gll_iem_v06_hp512_375138.fits'),
                       os.path.join(GRATOOLS_CONFIG, \
                                        'fits/gll_iem_v06_hp512_513056.fits'),
                       ]
    e_min, e_max = 524807.00, 575439.00
    get_foreground_integral_flux_map(fore_files_list, e_min, e_max)"""
    from scipy.optimize import curve_fit
    ClFORE_FILE = os.path.join(GRATOOLS_OUT, 'fore_polspicecls.txt')
    min1, emax1, clsfore = clfore_parse(ClFORE_FILE)
    l = np.arange(len(clsfore[0]))
    clsfore_spline = xInterpolatedUnivariateSplineLinear(l, clsfore[0])
    clsfore_spline.plot(show=False)
    plt.xscale('log')
    plt.yscale('log')
    plt.show()
コード例 #4
0
ファイル: gDrawRef.py プロジェクト: nmik/GRATools
def main():
    """Test module
    """
    leg, lab = ref_cp_band()
    plt.legend()
    plt.xscale('log')
    plt.yscale('log')
    plt.show()
    
    plt.figure()
    leg, lab = ref_igrb_band()
    igrb, lab2 = ref_igrb_noFGsub()
    plt.xscale('log')       
    plt.yscale('log')
    plt.legend([leg, igrb], [lab, lab2])
    plt.show()
コード例 #5
0
ファイル: gMasks.py プロジェクト: mahmoud-lsw/GRATools
def main():
    """Simple test unit
    """
    from GRATools.utils.gWindowFunc import get_psf_ref
    psf_ref_file = os.path.join(GRATOOLS_CONFIG, 'ascii/PSF_UCV_PSF1.txt')
    psf_ref = get_psf_ref(psf_ref_file)
    energy = np.array([
        743.73, 1340.69, 2208.67, 3692.56, 6416.93, 11151.34, 18370.95,
        30713.33, 53373.66, 92752.78, 152802.88, 255462.38, 443942.75
    ])
    psf_en = psf_ref(energy)
    psf_min, psf_max = psf_ref.y[5], psf_ref.y[-1]
    norm_min, norm_max = 1, 0.3
    norm = norm_min + psf_en*((norm_max - norm_min)/(psf_max - psf_min)) -\
        psf_min*((norm_max - norm_min)/(psf_max - psf_min))
    plt.title('Normalization Factor')
    plt.plot(energy, norm, 'ro--', ms=5, alpha=0.75)
    #plt.plot((1e-12, 1e-5), (2, 2), '-', color='silver', linewidth=1.0)
    plt.xlabel('Energy [MeV]')
    plt.ylabel('Normalization factor')
    plt.yscale('log')
    plt.xscale('log')
    plt.ylim(0.09, 2)
    plt.show()

    nside = 512
    SRC_CATALOG_FILE = os.path.join(FT_DATA_FOLDER, 'catalogs/gll_psc_v16.fit')
    bad_pix = mask_src_weighted(SRC_CATALOG_FILE, 10000, nside)
    bad_pix += mask_gp(30, nside)
    npix = hp.nside2npix(nside)
    mask = np.ones(npix)
    for bpix in np.unique(bad_pix):
        mask[bpix] = 0
    fsky = 1 - (len(np.unique(bad_pix)) / float(npix))
    title = 'f$_{sky}$ = %.3f' % fsky
    hp.mollview(mask, title=title, coord='G')
    plt.show()
コード例 #6
0
ファイル: drawsame_Cls.py プロジェクト: mahmoud-lsw/GRATools
                np.sqrt(len(cls_tocompare[j][i][_index]))
            _cls_rebin.append(clmean)
            _clerrs_rebin.append(clmeanerr)
        _l_rebin = np.array(_l_rebin)
        l_range_fit = np.where(np.logical_and(_l_rebin>=l_min, _l_rebin<l_max))
        _cls_rebin = np.array(_cls_rebin)
        _clerrs_rebin = np.array(_clerrs_rebin)
        cp =  np.polyfit(_l_rebin[l_range_fit], _cls_rebin[l_range_fit], 0, 
                         w=1/_clerrs_rebin[l_range_fit])
        lab = os.path.basename(f).replace('_13bins_cls.txt', '')
        plt.errorbar(_l_rebin, _cls_rebin, fmt='o', markersize=3, \
                         elinewidth=1, xerr=[xerrL, xerrR], \
                         yerr=_clerrs_rebin, label=lab )
        plt.plot([1, 1000], [cp[0], cp[0]], '-', linewidth=1, label='Fit '+lab)
    plt.plot([l_max, l_max], [-5e-15, 5e-15], '--', color='silver')
    plt.plot([l_min, l_min], [-5e-15, 5e-15], '--', color='silver')
    plt.xlim(1, _l[-1])
    plt.ylim(ymin, ymax)
    plt.xscale('log')
    #plt.yscale('log', nonposy='clip')
    plt.xlabel('$l$')
    plt.ylabel('$C_{sig,l}$')
    plt.title('%.2f - %.2f MeV'%(emin[i], emax[i]))
    plt.legend(loc=4, fontsize=10)
    save_current_figure(OUT_LABEL+'_%i-%i.png'%(emin[i], emax[i]))
    ymin = ymin + abs(ymin/(1.5+0.01*i))
    ymax = ymax - abs(ymax/(1.5+0.01*i))

    

コード例 #7
0
ファイル: drawsame_flux.py プロジェクト: nmik/GRATools
FLUX_LABELS = ['UCV (t56) w/o Foreground sub', 'UCV (t56) w/ Foreground sub']
#OUT_LABEL = 'Flux_t56_srcmask2_Rm-Rp'
#OUT_LABEL = 'Flux_types_srcmask2'
#OUT_LABEL = 'Flux_t56_srcmask2-1p5-weighted'
#OUT_LABEL = 'Flux_t56_maskweight_north-south'
#OUT_LABEL = 'Flux_t56_maskweight_east-west'
OUT_LABEL = 'Flux_t56_maskweight'

plt.figure(figsize=(10, 7), dpi=80)
from GRATools.utils.gDrawRef import ref_igrb_band
from GRATools.utils.gDrawRef import ref_igrb_noFGsub
leg, lab = ref_igrb_band()
igrb, lab_igrb = ref_igrb_noFGsub()
flux = []
for f in FLUX_FILES:
    from GRATools.utils.gFTools import get_cl_param
    _emin, _emax, _emean, _f, _ferr, _cn, fsky = get_cl_param(f)
    
    spec = plt.errorbar(_emean, _f*_emean, fmt='o', markersize=3, \
                     elinewidth=1, xerr=(_emax-_emin)/2, yerr=_ferr*_emean)
    label = os.path.basename(f).replace('_parameters.txt', '')
    flux.append(spec)
plt.xscale("log")
plt.yscale("log")
plt.xlabel('Energy [MeV]')
plt.ylabel('E$^{2}$ $\cdot$ Flux [MeV cm$^{-2}$ s$^{-1}$ sr$^{-1}$]')
plt.title(' Energy Spectrum')
plt.legend([igrb, leg]+flux, [lab_igrb, lab]+FLUX_LABELS, loc=3)
#overlay_tag()
save_current_figure(OUT_LABEL+'_ESpec.png')
コード例 #8
0
ファイル: drawsame_flux.py プロジェクト: mahmoud-lsw/GRATools
FLUX_LABELS = ['UCV (t56) w/o Foreground sub', 'UCV (t56) w/ Foreground sub']
#OUT_LABEL = 'Flux_t56_srcmask2_Rm-Rp'
#OUT_LABEL = 'Flux_types_srcmask2'
#OUT_LABEL = 'Flux_t56_srcmask2-1p5-weighted'
#OUT_LABEL = 'Flux_t56_maskweight_north-south'
#OUT_LABEL = 'Flux_t56_maskweight_east-west'
OUT_LABEL = 'Flux_t56_maskweight'

plt.figure(figsize=(10, 7), dpi=80)
from GRATools.utils.gDrawRef import ref_igrb_band
from GRATools.utils.gDrawRef import ref_igrb_noFGsub
leg, lab = ref_igrb_band()
igrb, lab_igrb = ref_igrb_noFGsub()
flux = []
for f in FLUX_FILES:
    from GRATools.utils.gFTools import get_cl_param
    _emin, _emax, _emean, _f, _ferr, _cn, fsky = get_cl_param(f)

    spec = plt.errorbar(_emean, _f*_emean, fmt='o', markersize=3, \
                     elinewidth=1, xerr=(_emax-_emin)/2, yerr=_ferr*_emean)
    label = os.path.basename(f).replace('_parameters.txt', '')
    flux.append(spec)
plt.xscale("log")
plt.yscale("log")
plt.xlabel('Energy [MeV]')
plt.ylabel('E$^{2}$ $\cdot$ Flux [MeV cm$^{-2}$ s$^{-1}$ sr$^{-1}$]')
plt.title(' Energy Spectrum')
plt.legend([igrb, leg] + flux, [lab_igrb, lab] + FLUX_LABELS, loc=3)
#overlay_tag()
save_current_figure(OUT_LABEL + '_ESpec.png')