示例#1
0
def startup(NN=1, multi=False, **kwargs):
    n = 4
    Nexp = 10000 // NN
    NMC = 500000 // NN
    if multi:
        llh = data.multi_init(n, Nexp, NMC, ncpu=4, **kwargs)
        mc = dict([(i, data.MC(NMC)) for i in range(n)])
    else:
        llh = data.init(Nexp, NMC, ncpu=4, **kwargs)
        mc = data.MC(NMC)

    return llh, mc
示例#2
0
文件: utils.py 项目: tc1611/skylab
def startup(NN=1, multi=False, **kwargs):
    n = 4
    Nexp = 10000 // NN
    NMC = 500000 // NN
    if multi:
        llh = data.multi_init(n, Nexp, NMC, ncpu=4, **kwargs)
        mc = dict([(i, data.MC(NMC)) for i in range(n)])
    else:
        llh = data.init(Nexp, NMC, ncpu=4, **kwargs)
        mc = data.MC(NMC)

    return llh, mc
示例#3
0
import data
from skylab.psLLH import MultiPointSourceLLH

from scipy.stats import chi2
import healpy as hp
import numpy as np
import matplotlib.pyplot as plt

# convert test statistic to a p-value for a given point
pVal_func = lambda TS, dec: -np.log10(0.5 * (chi2(len(llh.params)).sf(TS) + chi2(len(llh.params)).cdf(-TS)))

if __name__ == "__main__":

    # init the llh class
    llh = data.multi_init(4, 1000, 100000, ncpu=1, energy=True)

    print(llh)

    # iterator of all-sky scan with follow up scans of most interesting points
    for i, (scan, hotspot) in enumerate(llh.all_sky_scan(nside=16, pVal=pVal_func, decRange=np.radians([-90.0, 90.0]))):
        if i > 0:
            # break after first follow up
            break

    # plot results
    hp.mollview(scan["pVal"], min=0.0, cmap=plt.cm.afmhot, rot=[-180.0, 0.0, 0.0])
    if isinstance(llh, MultiPointSourceLLH):
        for llh in llh._sams.itervalues():
            hp.projscatter(
                np.degrees(llh.exp["ra"]),
示例#4
0
# -*-coding:utf8-*-

from data import multi_init

from scipy.stats import chi2
import healpy as hp
import numpy as np
import matplotlib.pyplot as plt

# convert test statistic to a p-value for a given point
pVal_func = lambda TS, dec: -np.log10(0.5 * (chi2(1).sf(TS) + chi2(1).cdf(-TS)))

if __name__=="__main__":

    # init the llh class
    llh = multi_init(3, 1000, 10000,
                     energy=False, ncpu=4)

    print(llh)

    # iterator of all-sky scan with follow up scans of most interesting points
    for i, (scan, hotspot) in enumerate(llh.all_sky_scan(nside=32,
                                                         pVal=pVal_func)):
        if i > 0:
            # break after first follow up
            break

    # plot results
    hp.mollview(scan["pVal"], min=0., cmap=plt.cm.afmhot)
    col = plt.gca()._get_lines.color_cycle
    for enum, llh_i in llh._sams.iteritems():
        hp.projscatter(np.degrees(llh_i.exp["ra"]),