Beispiel #1
0
				fig.savefig(figname)
				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")
	if not opts.skip_fits:
		print "\twriting posterior to file"
		fits = "%s/inj-%d%s.fits"%(opts.output_dir, inj_id, opts.tag)
		to=time.time()
        	hp.write_map(fits, posterior)
		print "\t\t", time.time()-to

		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
Beispiel #3
0
    post, header = hp.read_map(fits, h=True, verbose=False)
    NEST = (dict(header)['ORDERING'] == 'NEST')
    npix = len(post)
    nside = hp.npix2nside(npix)

    print "    nside=%d" % (nside)

    pixarea = hp.nside2pixarea(nside, degrees=opts.degrees)

    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: