Example #1
0
	else:
		raise ValueError, "detector=%s not understood"%arg

###############################################################################
####################### initialize network and priors ########################

nfreqs = len(freqs)
ndet = len(detectors)
print 'Number of detectors = ', ndet

if opts.verbose:
	print "building prior objects"
	if opts.time: to = time.time()

hprior_amplitudes, hprior_means, hprior_covariance = priors.hpri_neg4(len_freqs=nfreqs, seg_len=seg_len, num_pol=num_pol, num_gaus=num_gaus)
hprior = priors.hPrior(freqs=freqs, means=hprior_means, covariance=hprior_covariance, amplitudes=hprior_amplitudes, num_gaus=num_gaus, num_pol=num_pol)
angprior = priors.angPrior(nside_exp=nside_exp)

if opts.verbose and opts.time:
	print "\t", time.time()-to

if opts.verbose: 
	print "building network"
	if opts.time: to=time.time()

network = utils.Network(detectors=[detectors[i] for i in detectors], freqs=freqs, Np = num_pol)

if opts.verbose:
	print network
	if opts.time: print "\t", time.time()-to
Example #2
0
	print "\n----------------------------------\n"
	print "building hPrior"
	if opts.time:
		to = time.time()

pareto_a=config.getfloat("hPrior","pareto_a")
n_gaus_per_dec=config.getfloat("hPrior","n_gaus_per_dec")
log10_min=np.log10(config.getfloat("hPrior","min"))
log10_max=np.log10(config.getfloat("hPrior","max"))
n_gaus = max(1, int(round((log10_max-log10_min)*n_gaus_per_dec,0)))

variances=np.logspace(log10_min, log10_max, n_gaus)**2

pareto_means, pareto_covariance, pareto_amps = priors.pareto(pareto_a, analysis_n_freqs, n_pol, variances)

hprior = priors.hPrior(analysis_freqs, pareto_means, pareto_covariance, amplitudes=pareto_amps, n_gaus=n_gaus, n_pol=n_pol)

if opts.time:
	print "\t", time.time()-to

#=================================================
### build posterior_obj
#=================================================
if opts.verbose: 
	print "\n----------------------------------\n"
	print "building posterior"

posterior = posteriors.Posterior(network=network, hPrior=hprior, angPrior=angprior, seglen=seglen)

if config.has_option("posterior","num_proc"):
	posterior_num_proc=config.getint("posterior","num_proc")
	pickle.dump(theta_inj, file_obj)
	pickle.dump(phi_inj, file_obj)
	pickle.dump(psi_inj, file_obj)
	pickle.dump(hrss_inj, file_obj)
	pickle.dump(snrs_inj, file_obj)
	file_obj.close()

#=================================================
# PRIORS
#=================================================
import priors

print "hPrior"
to=time.time()
pareto_means, pareto_covariance, pareto_amps = priors.pareto(a, n_freqs, n_pol, variances)
hprior_obj = priors.hPrior(freqs, pareto_means, pareto_covariance, amplitudes=pareto_amps, n_gaus=n_gaus, n_pol=n_pol, byhand=True)
print "\t", time.time()-to

print "angPrior"
to=time.time()
angprior_obj = priors.angPrior(nside_exp, prior_type=prior_type)
print "\t", time.time()-to

#=================================================
# POSTERIORS
#=================================================
import posteriors

print "posterior.__init__()"
to=time.time()
posterior_obj = posteriors.Posterior(network=network, hPrior=hprior_obj, angPrior=angprior_obj, seglen=seglen, data=None)