'containing this much probability.')
args = parser.parse_args()

# Late imports.
import re
from astropy.table import Table
from astropy.utils.misc import NumpyRNGContext
from matplotlib import pyplot as plt
import numpy as np
from lalinference import io
import lalinference.plot
from lalinference.bayestar.postprocess import find_injection_moc
from scipy.interpolate import interp1d

# Read input.
skymap = io.read_sky_map(args.skymap.name, moc=True)
chain = io.read_samples(args.samples.name)

# If required, downselect to a smaller number of posterior samples.
if args.max_points is not None:
    chain = Table(np.random.permutation(chain)[:args.max_points])

# Calculate P-P plot.
contours = np.asarray(args.contour)
result = find_injection_moc(skymap,
                            chain['ra'],
                            chain['dec'],
                            chain['dist'],
                            contours=1e-2 * contours)

# Late imports
from matplotlib import pyplot as plt
from matplotlib import gridspec
from matplotlib import transforms
from lalinference import io
from lalinference.plot import marker
from lalinference.distance import (
    parameters_to_marginal_moments, principal_axes, volume_render, marginal_pdf)
import healpy as hp
import numpy as np
import scipy.stats

# Read input, determine input resolution.
progress.update(-1, 'Loading FITS file')
(prob, mu, sigma, norm), metadata = io.read_sky_map(
    opts.input.name, distances=True)
npix = len(prob)
nside = hp.npix2nside(npix)

progress.update(-1, 'Preparing projection')

if opts.align_to is None or opts.input.name == opts.align_to.name:
    prob2, mu2, sigma2, norm2 = prob, mu, sigma, norm
else:
    (prob2, mu2, sigma2, norm2), _ = io.read_sky_map(
        opts.align_to.name, distances=True)
if opts.max_distance is None:
    mean, std = parameters_to_marginal_moments(prob2, mu2, sigma2)
    max_distance = mean + 2.5 * std
else:
    max_distance = opts.max_distance
Esempio n. 3
0
# Late imports
from matplotlib import pyplot as plt
from matplotlib import gridspec
from matplotlib import transforms
from lalinference import io
from lalinference.plot import marker
from lalinference.bayestar.distance import (
    principal_axes, volume_render, marginal_pdf, marginal_ppf)
import healpy as hp
import numpy as np
import scipy.stats

# Read input, determine input resolution.
progress.update(-1, 'Loading FITS file')
(prob, mu, sigma, norm), metadata = io.read_sky_map(
    opts.input.name, distances=True)
npix = len(prob)
nside = hp.npix2nside(npix)

progress.update(-1, 'Preparing projection')

if opts.align_to is None or opts.input.name == opts.align_to.name:
    prob2, mu2, sigma2, norm2 = prob, mu, sigma, norm
else:
    (prob2, mu2, sigma2, norm2), _ = io.read_sky_map(
        opts.align_to.name, distances=True)
if opts.max_distance is None:
    max_distance = 2.5 * marginal_ppf(0.5, prob2, mu2, sigma2, norm2)
else:
    max_distance = opts.max_distance
R = np.ascontiguousarray(principal_axes(prob2, mu2, sigma2))

# Late imports.
import re
from astropy.table import Table
from astropy.utils.misc import NumpyRNGContext
from matplotlib import pyplot as plt
import numpy as np
from lalinference import io
import lalinference.plot
from lalinference.bayestar.postprocess import find_injection_moc
from scipy.interpolate import interp1d


# Read input.
skymap = io.read_sky_map(args.skymap.name, moc=True)
chain = io.read_samples(args.samples.name)

# If required, downselect to a smaller number of posterior samples.
if args.max_points is not None:
    chain = Table(np.random.permutation(chain)[:args.max_points])

# Calculate P-P plot.
contours = np.asarray(args.contour)
result = find_injection_moc(skymap, chain['ra'], chain['dec'], chain['dist'],
                            contours=1e-2 * contours)


def fmt(x, sigfigs, force_scientific=False):
    """Round and format a number in scientific notation."""
    places = sigfigs - int(np.floor(np.log10(x)))