def process(fitsfilename):
    sky_map = fits.read_sky_map(fitsfilename, moc=True)

    coinc_event_id = sky_map.meta['objid']
    try:
        runtime = sky_map.meta['runtime']
    except KeyError:
        runtime = float('nan')

    contour_pvalues = 0.01 * np.asarray(contours)

    row = db.execute(
        """
        SELECT DISTINCT sim.simulation_id AS simulation_id,
        sim.longitude AS ra, sim.latitude AS dec, sim.distance AS distance,
        ci.combined_far AS far, ci.snr AS snr
        FROM coinc_event_map AS cem1 INNER JOIN coinc_event_map AS cem2
        ON (cem1.coinc_event_id = cem2.coinc_event_id)
        INNER JOIN sim_inspiral AS sim ON (cem1.event_id = sim.simulation_id)
        INNER JOIN coinc_inspiral AS ci ON (cem2.event_id = ci.coinc_event_id)
        WHERE cem1.table_name = 'sim_inspiral'
        AND cem2.table_name = 'coinc_event' AND cem2.event_id = ?
        """, (coinc_event_id,)).fetchone()
    if row is None:
        raise ValueError(
            "No database record found for event '{0}' in '{1}'".format(
                coinc_event_id, command.sqlite_get_filename(db)))
    simulation_id, true_ra, true_dec, true_dist, far, snr = row
    searched_area, searched_prob, offset, searched_modes, contour_areas, \
        area_probs, contour_modes, searched_prob_dist, contour_dists, \
        searched_vol, searched_prob_vol, contour_vols = find_injection_moc(
            sky_map, true_ra, true_dec, true_dist, contours=contour_pvalues,
            areas=areas, modes=modes)

    if snr is None:
        snr = np.nan
    if far is None:
        far = np.nan
    distmean = sky_map.meta.get('distmean', np.nan)
    diststd = sky_map.meta.get('diststd', np.nan)
    log_bci = sky_map.meta.get('log_bci', np.nan)
    log_bsn = sky_map.meta.get('log_bsn', np.nan)

    ret = [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] \
          + contour_areas + area_probs + contour_dists + contour_vols
    if modes:
        ret += [searched_modes] + contour_modes
    return ret
def process(fitsfilename):
    sky_map = fits.read_sky_map(fitsfilename, moc=True)

    coinc_event_id = sky_map.meta['objid']
    try:
        runtime = sky_map.meta['runtime']
    except KeyError:
        runtime = float('nan')

    contour_pvalues = 0.01 * np.asarray(contours)

    row = db.execute(
        """
        SELECT DISTINCT sim.simulation_id AS simulation_id,
        sim.longitude AS ra, sim.latitude AS dec, sim.distance AS distance,
        ci.combined_far AS far, ci.snr AS snr
        FROM coinc_event_map AS cem1 INNER JOIN coinc_event_map AS cem2
        ON (cem1.coinc_event_id = cem2.coinc_event_id)
        INNER JOIN sim_inspiral AS sim ON (cem1.event_id = sim.simulation_id)
        INNER JOIN coinc_inspiral AS ci ON (cem2.event_id = ci.coinc_event_id)
        WHERE cem1.table_name = 'sim_inspiral'
        AND cem2.table_name = 'coinc_event' AND cem2.event_id = ?
        """, (coinc_event_id, )).fetchone()
    if row is None:
        raise ValueError(
            "No database record found for event '{0}' in '{1}'".format(
                coinc_event_id, command.sqlite_get_filename(db)))
    simulation_id, true_ra, true_dec, true_dist, far, snr = row
    searched_area, searched_prob, offset, searched_modes, contour_areas, \
        area_probs, contour_modes, searched_prob_dist, contour_dists, \
        searched_vol, searched_prob_vol, contour_vols = find_injection_moc(
            sky_map, true_ra, true_dec, true_dist, contours=contour_pvalues,
            areas=areas, modes=modes)

    if snr is None:
        snr = np.nan
    if far is None:
        far = np.nan
    distmean = sky_map.meta.get('distmean', np.nan)
    diststd = sky_map.meta.get('diststd', np.nan)
    log_bci = sky_map.meta.get('log_bci', np.nan)
    log_bsn = sky_map.meta.get('log_bsn', np.nan)

    ret = [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] \
          + contour_areas + area_probs + contour_dists + contour_vols
    if modes:
        ret += [searched_modes] + contour_modes
    return ret
Beispiel #3
0
def process(fitsfilename):
    sky_map, metadata = fits.read_sky_map(fitsfilename, nest=None)

    coinc_event_id = metadata['objid']
    try:
        runtime = metadata['runtime']
    except KeyError:
        runtime = float('nan')

    row = db.execute(
        """
        SELECT DISTINCT sim.simulation_id AS simulation_id, sim.longitude AS ra, sim.latitude AS dec,
        ci.combined_far AS far, ci.snr AS snr
        FROM coinc_event_map AS cem1 INNER JOIN coinc_event_map AS cem2
        ON (cem1.coinc_event_id = cem2.coinc_event_id)
        INNER JOIN sim_inspiral AS sim ON (cem1.event_id = sim.simulation_id)
        INNER JOIN coinc_inspiral AS ci ON (cem2.event_id = ci.coinc_event_id)
        WHERE cem1.table_name = 'sim_inspiral'
        AND cem2.table_name = 'coinc_event' AND cem2.event_id = ?""",
        (coinc_event_id, )).fetchone()
    if row is None:
        raise ValueError(
            "No database record found for event '{0}' in '{1}'".format(
                coinc_event_id, command.sqlite_get_filename(db)))
    simulation_id, true_ra, true_dec, far, snr = row
    searched_area, searched_prob, offset, searched_modes, contour_areas, area_probs, contour_modes = postprocess.find_injection(
        sky_map,
        true_ra,
        true_dec,
        contours=[0.01 * p for p in contours],
        areas=areas,
        modes=modes,
        nest=metadata['nest'])

    if snr is None:
        snr = float('nan')
    if far is None:
        far = float('nan')
    distmean = metadata.get('distmean', float('nan'))
    diststd = metadata.get('diststd', float('nan'))

    ret = [
        coinc_event_id, simulation_id, far, snr, searched_area, searched_prob,
        offset, runtime, distmean, diststd
    ] + contour_areas + area_probs
    if modes:
        ret += [searched_modes] + contour_modes
    return ret
def process(fitsfilename):
    sky_map, metadata = fits.read_sky_map(fitsfilename, nest=None)

    coinc_event_id = metadata['objid']
    try:
        runtime = metadata['runtime']
    except KeyError:
        runtime = float('nan')

    row = db.execute("""
        SELECT DISTINCT sim.simulation_id AS simulation_id, sim.longitude AS ra, sim.latitude AS dec,
        ci.combined_far AS far, ci.snr AS snr
        FROM coinc_event_map AS cem1 INNER JOIN coinc_event_map AS cem2
        ON (cem1.coinc_event_id = cem2.coinc_event_id)
        INNER JOIN sim_inspiral AS sim ON (cem1.event_id = sim.simulation_id)
        INNER JOIN coinc_inspiral AS ci ON (cem2.event_id = ci.coinc_event_id)
        WHERE cem1.table_name = 'sim_inspiral'
        AND cem2.table_name = 'coinc_event' AND cem2.event_id = ?""",
        (coinc_event_id,)).fetchone()
    if row is None:
        raise ValueError(
            "No database record found for event '{0}' in '{1}'".format(
            coinc_event_id, command.sqlite_get_filename(db)))
    simulation_id, true_ra, true_dec, far, snr = row
    searched_area, searched_prob, offset, searched_modes, contour_areas, area_probs, contour_modes = postprocess.find_injection(
        sky_map, true_ra, true_dec, contours=[0.01 * p for p in contours],
        areas=areas, modes=modes, nest=metadata['nest'])

    if snr is None:
        snr = float('nan')
    if far is None:
        far = float('nan')
    distmean = metadata.get('distmean', float('nan'))
    diststd = metadata.get('diststd', float('nan'))

    ret = [coinc_event_id, simulation_id, far, snr, searched_area, searched_prob, offset, runtime, distmean, diststd] + contour_areas + area_probs
    if modes:
        ret += [searched_modes] + contour_modes
    return ret
    db = opts.db
    contours = opts.contour
    modes = opts.modes
    areas = opts.area

    progress.update(-1, 'spawning workers')
    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

    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)
    db = opts.db
    contours = opts.contour
    modes = opts.modes
    areas = opts.area

    progress.update(-1, 'spawning workers')
    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
Beispiel #7
0
    progress = ProgressBar()

    db = opts.db
    contours = opts.contour
    modes = opts.modes
    areas = opts.area

    progress.update(-1, 'spawning workers')
    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)