コード例 #1
0
    query = '''SELECT longitude, latitude FROM sim_inspiral AS si
               INNER JOIN coinc_event_map AS cm1
               ON (si.simulation_id = cm1.event_id)
               INNER JOIN coinc_event_map AS cm2
               ON (cm1.coinc_event_id = cm2.coinc_event_id)
               WHERE cm2.event_id = ?'''
    (ra, dec), = opts.inj_database.execute(
        query, (metadata['objid'],)).fetchall()
    radecs.append([ra, dec])

# Add markers (e.g., for injections or external triggers).
for ra, dec in radecs:
    # Convert the right ascension to either a reference angle from -pi to pi
    # or a wrapped angle from 0 to 2 pi.
    if opts.geo:
        ra = plot.reference_angle(ra + dlon)
    else:
        ra = plot.wrapped_angle(ra + dlon)
    ax.plot(ra, dec, '*', markerfacecolor='white', markeredgecolor='black', markersize=10)

# If we are using a new enough version of matplotlib, then
# add a white outline to all text to make it stand out from the background.
plot.outline_text(ax)

# Make transparent.
if opts.transparent:
    fig.patch.set_alpha(0.)
    ax.patch.set_alpha(0.)
    ax.set_alpha(0.)

# Show or save output.
コード例 #2
0
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)

# Add markers (e.g., for injections or external triggers).
for ra, dec in np.deg2rad(opts.radec):
    # Convert the right ascension to either a reference angle from -pi to pi
    # or a wrapped angle from 0 to 2 pi, depending on the version of Matplotlib.
    # FIXME: Remove this after all Matplotlib monkeypatches are obsolete.
    if opts.geo or plot.mpl_version < '1.2.0':
        ra = plot.reference_angle(ra + dlon)
    else:
        ra = plot.wrapped_angle(ra + dlon)
    ax.plot(ra, dec, '*', markerfacecolor='white', markeredgecolor='black', markersize=10)

# If we are using a new enough version of matplotlib, then
# add a white outline to all text to make it stand out from the background.
plot.outline_text(ax)

if opts.transparent:
    fig.patch.set_alpha(0.)
    ax.patch.set_alpha(0.)
    ax.set_alpha(0.)

if opts.output is None:
    plt.show()