예제 #1
0
def test_os(nodmx_psrs,pta_model2a):
    OS = optstat.OptimalStatistic(psrs=nodmx_psrs,pta=pta_model2a)
    assert hasattr(OS,'Fmats')
    OS.compute_os()
    chain = np.zeros((10,len(pta_model2a.params)+4))
    for ii in range(10):
        entry = [par.sample() for par in pta_model2a.params]
        entry.extend([OS.pta.get_lnlikelihood(entry)-OS.pta.get_lnprior(entry),
                      OS.pta.get_lnlikelihood(entry),
                      0.5,1])
        chain[ii,:] = np.array(entry)
    OS.compute_noise_marginalized_os(chain, param_names=OS.pta.param_names, N=10)
    OS.compute_noise_maximized_os(chain, param_names=OS.pta.param_names)
예제 #2
0
def test_os_pseed(dmx_psrs, pta_pshift):
    OS = optstat.OptimalStatistic(psrs=dmx_psrs, pta=pta_pshift)
    params = {
        pnm: p.sample()
        for pnm, p in zip(pta_pshift.param_names, pta_pshift.params)
    }
    params.update({'gw_pseed': 1})
    _, _, _, A1, rho1 = OS.compute_os(params=params)
    params.update({'gw_pseed': 2})
    _, _, _, A2, rho2 = OS.compute_os(params=params)
    print(A1, A2)
    print(rho1, rho2)
    assert A1 != A2
    assert rho1 != rho2
예제 #3
0
파일: os.py 프로젝트: ark0015/pta_sim
cuts = np.linspace(57000., 66154., 10)
#cuts = [57000, 58800, 60676.,  62502.,  64328.,  66154.]

sim = Simulation(parfiles, timfiles, ephem=args.ephem, verbose=True)

cuts = cuts[::-1]
seed_gwb = args.process

sim.createGWB(A_gwb=args.A_gwb, gamma_gw=args.gamma_gw, seed=seed_gwb)

sim.init_ePulsars()

pta = model_simple(sim.psrs, gamma_common=args.gamma_gw)

OptStat = OS.OptimalStatistic(psrs=sim.psrs,
                              pta=pta,
                              bayesephem=args.bayes_ephem)

par_dict = {'log10_A_gw': np.log10(args.A_gwb)}
xi, rho, sigma, Agwb_sqr, os_sigma = OptStat.compute_os(params=par_dict)

out = [[Agwb_sqr, os_sigma, sim.last_toa, sim.seed]]
np.savetxt(args.outpath, out, fmt='%e, %e, %f, %i')

print('MJD {0} analysis complete'.format(sim.last_toa))

for mjd in cuts:
    sim.filter_by_mjd(mjd)
    pta = model_simple(sim.psrs, gamma_common=args.gamma_gw)
    OptStat = OS.OptimalStatistic(psrs=sim.psrs,
                                  pta=pta,
예제 #4
0
sim.init_ePulsars()

sim.filter_by_mjd(args.end_time)
pta = model_simple(psrs=sim.psrs,
                   psd='powerlaw',
                   components=30,
                   vary_gamma=args.vary_gamma,
                   upper_limit=args.gwb_ul,
                   efac=args.efac,
                   hd_orf=args.hd,
                   rn_dropout=args.dropout,
                   bayesephem=False,
                   select='backend',
                   red_noise=args.rednoise,
                   Tspan=args.tspan,
                   dp_threshold=args.dp_thresh)

os = OS.OptimalStatistic(sim.psrs,
                         bayesephem=False,
                         gamma_common=4.33,
                         orf='hd',
                         pta=pta)

c0 = load_Core(args.corepath)

np.save(args.outdir + 'os_max_{0}_{1}'.format(args.nyears, args.process),
        os.compute_noise_maximized_os(c0.chain))
np.save(args.outdir + 'os_marg_{0}_{1}'.format(args.nyears, args.process),
        os.compute_noise_marginalized_os(c0.chain, N=1000))