Skip to content
Snippets Groups Projects
Commit c7936a4b authored by Kipp Cannon's avatar Kipp Cannon
Browse files

plotfar.py: rewrite plot_horizon_distance_vs_time()

- do not use linspace for x co-cordinates, use actual times of measurements to ensure that all features are reproduced on the plot
- get colours from plotutils
- change x axis to time from reference rather than absolute time to clean up the presentation
- explain what masses the horizon distance is for in the title
- change x axis major ticks to 1/2 hour intervals (human units)
- increase density of y axis ticks to help facilitate visual estimates of the values
parent fc09e4a0
No related branches found
No related tags found
No related merge requests found
......@@ -228,7 +228,7 @@ for gid in gid_list:
fig.savefig(os.path.join(options.output_path, filename))
fig = plotfar.plot_horizon_distance_vs_time(coinc_param_distributions, (coinc_inspiral.end - 14400., coinc_inspiral.end), 241)
fig = plotfar.plot_horizon_distance_vs_time(coinc_param_distributions, (coinc_inspiral.end - 14400., coinc_inspiral.end), tref = coinc_inspiral.end)
filename = "%s_horizon_distances.png" % gid
if not options.no_upload:
lvalert_helper.upload_fig(fig, gracedb_client, gid, filename = filename, log_message = "Horizon Distances", tagname = "psd")
......
......@@ -338,23 +338,29 @@ def plot_likelihood_ratio_ccdf(fapfar, (xlo, xhi), observed_ln_likelihood_ratios
fig.tight_layout(pad = .8)
return fig
def plot_horizon_distance_vs_time(coinc_param_distributions, (tlo,thi), tbins, colours = {"H1": "r", "H2": "b", "L1": "g", "V1": "m"}):
tlo, thi = float(tlo), float(thi)
horizon_history = coinc_param_distributions.horizon_history
def plot_horizon_distance_vs_time(coinc_param_distributions, (tlo, thi), masses = (1.4, 1.4), tref = None):
fig, axes = init_plot((8., 8. / plotutil.golden_ratio))
t = numpy.linspace(tlo, thi, tbins)
yhi = 0
for ifo in horizon_history.keys():
y = numpy.array([horizon_history[ifo][seg] for seg in t])
axes.plot(t, y, color = colours[ifo], label = '%s' % ifo)
yhi = max(y.max()+5., yhi)
axes.set_ylim((0,yhi))
axes.set_xlim((round(tlo), round(thi)))
axes.xaxis.set_major_locator(matplotlib.ticker.MultipleLocator(1800.))
axes.yaxis.set_minor_locator(matplotlib.ticker.MultipleLocator(5.))
axes.yaxis.set_major_locator(matplotlib.ticker.MultipleLocator(50.))
yhi = 1.
for instrument, history in coinc_param_distributions.horizon_history.items():
x = numpy.array([t for t in history.keys() if tlo <= t < thi])
y = list(map(history.__getitem__, x))
if tref is not None:
x -= float(tref)
axes.plot(x, y, color = plotutil.colour_from_instruments([instrument]), label = '%s' % instrument)
yhi = max(max(y), yhi)
if tref is not None:
axes.set_xlabel('Time From GPS %.2f (s)' % float(tref))
else:
axes.set_xlim((math.floor(tlo), math.ceil(thi)))
axes.set_xlabel('GPS Time (s)')
axes.set_ylim((0., math.ceil(yhi / 10.) * 10.))
axes.set_ylabel('Horizon Distance (Mpc)')
axes.set_xlabel('GPS Time (s)')
axes.set_title('Horizon Distance vs.\ Time')
axes.set_title(r'Horizon Distance for $%.3g\,\mathrm{M}_{\odot}$--$%.3g\,\mathrm{M}_{\odot}$ vs.\ Time' % masses)
axes.grid(which = "major", linestyle = "-", linewidth = 0.2)
axes.legend(loc = "lower left")
fig.tight_layout(pad = .8)
return fig
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment