示例#1
0
				plt.close(fig)
				if opts.verbose and opts.time: print "\t\t", time.time()-to, "sec"

			### compute basic statistics about the reconstruction
			if opts.stats:
				if opts.verbose: 
					print "\tcomputing statistics"
					if opts.time: to=time.time()
				statsfilename = "%s/stats-%d%s.txt"%(opts.output_dir, toa_ind, opts.tag)
			
				### angular offset between max of the posterior and injection
				cosDtheta = stats.cos_dtheta(est_theta, est_phi, inj_theta, inj_phi)

				### searched area
				p_value = stats.p_value(posterior, inj_theta, inj_phi, nside=nside)
				searched_area = stats.searched_area(posterior, inj_theta, inj_phi, degrees=True)

				### num_mode
				num_mode = stats.num_modes(posterior, inj_theta, inj_phi, nside=nside)

				### min{cosDtheta}
				min_cosDtheta = stats.min_cos_dtheta(posterior, inj_theta, inj_phi, nside=nside)

				### entropy
				entropy = stats.entropy(posterior)
		
				### information
				info = stats.information(posterior)

				statsfile = open(statsfilename, "w")
				print >> statsfile, "cos(ang_offset) = %.6f\nsearched_area = %.6f deg2\np_value = %.6f\nnum_mode = %d\nmin{cos(ang_offset)} = %.6f\nentropy = %.6f\ninformation = %.6f"%(cosDtheta, searched_area, p_value, num_mode, min_cosDtheta, entropy, info)
		fitsnames.append(fits)

	#=================================================
	# COMPUTE STATISTICS
	#=================================================
	if not opts.zero_data:
		print "\tp_value"
		to=time.time()
		p_value[inj_id] = stats.p_value(posterior, theta, phi, nside=nside)
		print "\t\t", p_value[inj_id]
		print "\t\t", time.time()-to

		print "\tsearched_area"
		to=time.time()
		searched_area[inj_id] = stats.searched_area(posterior, theta, phi, nside=nside, degrees=True)
		print "\t\t", searched_area[inj_id]
		print "\t\t", time.time()-to

		print "\tcos_dtheta"
		to=time.time()
		cos_dtheta[inj_id] = stats.est_cos_dtheta(posterior, theta, phi)
		print "\t\t", cos_dtheta[inj_id]
		print "\t\t", time.time()-to

	### write a tool that will compute moments of frequency given a model (and log_posterior_elements?)

#=================================================
# ENSEMBLE AVERAGES
#=================================================
if not opts.zero_data:
示例#3
0
    print "    pixarea=%.6f %s" % (pixarea, areaunit)

    ### compute statistics and report them
    if opts.pvalue:
        if opts.Verbose:
            print "        pvalue"
        pvalue = stats.p_value(post, theta, phi, nside=nside)
        messages.append("cdf(%s) = %.3f %s" % (opts.pvalue, pvalue * 100, "%"))

    if opts.searched_area:
        if opts.Verbose:
            print "        searched_area"
        sa = stats.searched_area(post,
                                 stheta,
                                 sphi,
                                 nside=nside,
                                 degrees=opts.degrees)
        messages.append("searched_area(%s) = %.3f %s" %
                        (opts.searched_area, sa, areaunit))

    # entropy -> size
    if opts.entropy:
        if opts.Verbose:
            print "        entropy"
        entropy = pixarea * 2**(stats.entropy(post, base=2.0))
        messages.append("entropy = %.3f %s" % (entropy, areaunit))

    # CR -> size, max(dtheta)
    if opts.Verbose:
        print "        Credible Regions"