from six.moves import map
    else:
        try:
            from emcee.interruptible_pool import InterruptiblePool as Pool
        except ImportError:
            from multiprocessing import Pool
        map = Pool(
            opts.jobs, startup,
            (command.sqlite_get_filename(db), contours, modes, areas)).imap

    colnames = ([
        'coinc_event_id', 'simulation_id', 'far', 'snr', 'searched_area',
        'searched_prob', 'searched_prob_dist', 'searched_vol',
        'searched_prob_vol', 'offset', 'runtime', 'distmean', 'diststd',
        'log_bci', 'log_bsn'
    ] + ['area({0:g})'.format(_)
         for _ in contours] + ['prob({0:g})'.format(_) for _ in areas] +
                ['dist({0:g})'.format(_) for _ in contours] +
                ['vol({0:g})'.format(_) for _ in contours])
    if modes:
        colnames += ['searched_modes']
        colnames += ["modes({0:g})".format(p) for p in contours]
    print(*colnames, sep="\t", file=opts.output)

    count_records = 0
    progress.max = len(opts.fitsfilenames)
    for record in map(process, opts.fitsfilenames):
        count_records += 1
        progress.update(count_records, record[0])
        print(*record, sep="\t", file=opts.output)
    if opts.jobs == 1:
        from six.moves import map
    else:
        try:
            from emcee.interruptible_pool import InterruptiblePool as Pool
        except ImportError:
            from multiprocessing import Pool
        map = Pool(
            opts.jobs, startup,
            (command.sqlite_get_filename(db), contours, modes, areas)
            ).imap_unordered

    progress.update(-1, 'obtaining filenames of sky maps')
    fitsfilenames = tuple(command.chainglob(opts.fitsfileglobs))

    colnames = (
        ['coinc_event_id', 'simulation_id', 'far', 'snr', 'searched_area',
        'searched_prob', 'offset', 'runtime', 'distmean', 'diststd'] +
        ["area({0:g})".format(p) for p in contours] +
        ["prob({0:g})".format(a) for a in areas])
    if modes:
        colnames += ['searched_modes'] + ["modes({0:g})".format(p) for p in contours]
    print(*colnames, sep="\t", file=opts.output)

    count_records = 0
    progress.max = len(fitsfilenames)
    for record in map(process, fitsfilenames):
        count_records += 1
        progress.update(count_records, record[0])
        print(*record, sep="\t", file=opts.output)
示例#3
0
    bin_edges = 10.**log10_far
    bin_names = ['far_1e{0}'.format(e) for e in log10_far]
    bin_titles = [
        r'$\mathrm{{FAR}} \leq 10^{{{0}}}$ Hz'.format(e) for e in log10_far
    ]
elif opts.group_by == 'snr':
    combined = np.concatenate([dataset['snr'] for dataset in datasets_])
    min_snr = int(np.floor(np.min(combined)))
    max_snr = int(np.floor(np.max(combined)))
    bin_edges = np.arange(min_snr, max_snr + 1)
    bin_names = ['snr_{0}'.format(e) for e in bin_edges]
    bin_titles = [r'$\mathrm{{SNR}} \geq {0}$'.format(e) for e in bin_edges]

# Set maximum range of progress bar: one tick for each of 5 figures, for each
# false alarm rate bin.
pb.max = len(bin_edges) * 4

if opts.cumulative:
    histlabel = 'cumulative '
else:
    histlabel = ''
if opts.normed:
    histlabel += 'fraction'
else:
    histlabel += 'number'
histlabel += ' of injections'

# Loop over false alarm rate bins.
for i, (bin_edge, subdir,
        title) in enumerate(zip(bin_edges, bin_names, bin_titles)):
    pb.update(text=subdir)
    log10_far = np.arange(log10_min_far, log10_max_far + 1)
    bin_edges = 10.**log10_far
    bin_names = ['far_1e{0}'.format(e) for e in log10_far]
    bin_titles = [r'$\mathrm{{FAR}} \leq 10^{{{0}}}$ Hz'.format(e) for e in log10_far]
elif opts.group_by == 'snr':
    combined = np.concatenate([dataset['snr'] for dataset in datasets_])
    min_snr = int(np.floor(np.min(combined)))
    max_snr = int(np.floor(np.max(combined)))
    bin_edges = np.arange(min_snr, max_snr + 1)
    bin_names = ['snr_{0}'.format(e) for e in bin_edges]
    bin_titles = [r'$\mathrm{{SNR}} \geq {0}$'.format(e) for e in bin_edges]


# Set maximum range of progress bar: one tick for each of 5 figures, for each
# false alarm rate bin.
pb.max = len(bin_edges) * 4

if opts.cumulative:
    histlabel = 'cumulative '
else:
    histlabel = ''
if opts.normed:
    histlabel += 'fraction'
else:
    histlabel += 'number'
histlabel += ' of injections'

# Loop over false alarm rate bins.
for i, (bin_edge, subdir, title) in enumerate(zip(bin_edges, bin_names, bin_titles)):
    pb.update(text=subdir)
示例#5
0
import healpy as hp
import lal
from lalinference.io import fits
from lalinference import plot
from glue.text_progress_bar import ProgressBar

fig = plt.figure(frameon=False)
ax = plt.axes(projection='mollweide')
ax.grid()

progress = ProgressBar()

progress.update(-1, 'obtaining filenames of sky maps')
fitsfilenames = tuple(command.chainglob(opts.fitsfileglobs))

progress.max = len(fitsfilenames)

matplotlib.rc('path', simplify=True, simplify_threshold=1)

if opts.colormap is None:
    colors = ['k'] * len(fitsfilenames)
else:
    colors = matplotlib.cm.get_cmap(opts.colormap)
    colors = colors(np.linspace(0, 1, len(fitsfilenames)))
for count_records, (color,
                    fitsfilename) in enumerate(zip(colors, fitsfilenames)):
    progress.update(count_records, fitsfilename)
    skymap, metadata = fits.read_sky_map(fitsfilename, nest=None)
    nside = hp.npix2nside(len(skymap))
    gmst = lal.GreenwichMeanSiderealTime(metadata['gps_time']) % (2 * np.pi)
    else:
        try:
            from emcee.interruptible_pool import InterruptiblePool as Pool
        except ImportError:
            from multiprocessing import Pool
        map = Pool(
            opts.jobs, startup,
            (command.sqlite_get_filename(db), contours, modes, areas)
            ).imap

    colnames = (
        ['coinc_event_id', 'simulation_id', 'far', 'snr', 'searched_area',
         'searched_prob', 'searched_prob_dist', 'searched_vol',
         'searched_prob_vol', 'offset', 'runtime', 'distmean', 'diststd',
         'log_bci', 'log_bsn'] +
        ['area({0:g})'.format(_) for _ in contours] +
        ['prob({0:g})'.format(_) for _ in areas] +
        ['dist({0:g})'.format(_) for _ in contours] +
        ['vol({0:g})'.format(_) for _ in contours])
    if modes:
        colnames += ['searched_modes']
        colnames += ["modes({0:g})".format(p) for p in contours]
    print(*colnames, sep="\t", file=opts.output)

    count_records = 0
    progress.max = len(opts.fitsfilenames)
    for record in map(process, opts.fitsfilenames):
        count_records += 1
        progress.update(count_records, record[0])
        print(*record, sep="\t", file=opts.output)