Exemplo n.º 1
0
# Plot sky map.
vmax = probperdeg2.max()
plot.healpix_heatmap(probperdeg2,
                     dlon=dlon,
                     nest=metadata['nest'],
                     vmin=0.,
                     vmax=vmax)

# Add colorbar.
if opts.colorbar:
    cb = plot.colorbar()
    cb.set_label(r'prob. per deg$^2$')

# Add contours.
if opts.contour:
    cls = 100 * postprocess.find_greedy_credible_levels(skymap)
    cs = plot.healpix_contour(cls,
                              dlon=dlon,
                              nest=metadata['nest'],
                              colors='k',
                              linewidths=0.5,
                              levels=opts.contour)
    fmt = r'%g\%%' if rcParams['text.usetex'] else '%g%%'
    plt.clabel(cs, fmt=fmt, fontsize=6, inline=True)

# Add continents.
if opts.geo:
    geojson_filename = os.path.join(os.path.dirname(plot.__file__),
                                    'ne_simplified_coastline.json')
    with open(geojson_filename, 'r') as geojson_file:
        geojson = json.load(geojson_file)
# Convert sky map from probability to probability per square degree.
probperdeg2 = skymap / hp.nside2pixarea(nside, degrees=True)

# Plot sky map.
vmax = probperdeg2.max()
plot.healpix_heatmap(
    probperdeg2, dlon=dlon, nest=metadata['nest'], vmin=0., vmax=vmax)

# Add colorbar.
if opts.colorbar:
    cb = plot.colorbar()
    cb.set_label(r'prob. per deg$^2$')

# Add contours.
if opts.contour:
    cls = 100 * postprocess.find_greedy_credible_levels(skymap)
    cs = plot.healpix_contour(
        cls, dlon=dlon, nest=metadata['nest'],
        colors='k', linewidths=0.5, levels=opts.contour)
    fmt = r'%g\%%' if rcParams['text.usetex'] else '%g%%'
    plt.clabel(cs, fmt=fmt, fontsize=6, inline=True)

# Add continents.
if opts.geo:
    geojson_filename = os.path.join(os.path.dirname(plot.__file__),
        'ne_simplified_coastline.json')
    with open(geojson_filename, 'r') as geojson_file:
        geojson = json.load(geojson_file)
    for shape in geojson['geometries']:
        verts = np.deg2rad(shape['coordinates'])
        plt.plot(verts[:, 0], verts[:, 1], color='0.5', linewidth=0.5)
Exemplo n.º 3
0
    CDELT2=1./deg_per_pix,
    CTYPE1='RA---AIT',
    CTYPE2='DEC--AIT',
    RADESYS='ICRS'))
wcs = WCS(header)

fig = pl.figure(figsize=[8,6])
ax = pl.axes(projection=wcs, frame_class=RectangularFrame, aspect=1)
world_transform = ax.get_transform('world')
ax.set_xlim((180 - args.size) * deg_per_pix,
            (180 + args.size) * deg_per_pix)
ax.set_ylim((90 - args.size) * deg_per_pix,
            (90 + args.size) * deg_per_pix)


cls = postprocess.find_greedy_credible_levels(optprob)
cls, _ = reproject_from_healpix((cls, 'icrs'), header)
cs = ax.contour(cls, levels=[0.5, 0.9], colors='C0')
ax.plot([],[], '-', color='C0', label='Exact masses')


## Work on the suboptimal skymap

prob, _ = read_sky_map(args.fits_file, nest=False, distances=False)
nside = hp.npix2nside(len(prob))
deg2perpix = hp.nside2pixarea(nside, degrees=True)

radec = [float(x) for x in args.radec]

deg_per_pix = 4
header = Header(dict(