def _test_plots(self, search_keys): for key in search_keys: self.search.plot_1D(xkey=key, savefig=True) if len(search_keys) == 2: self.search.plot_2D(xkey=search_keys[0], ykey=search_keys[1], colorbar=True) vals = [ np.unique(self.search.data[key]) - getattr(self.Writer, key) for key in search_keys ] twoF = self.search.data["twoF"].reshape([len(kval) for kval in vals]) corner_labels = [f"${key} - {key}_0$" for key in search_keys] corner_labels.append("2F") gridcorner_fig, gridcorner_axes = pyfstat.gridcorner( twoF, vals, projection="log_mean", labels=corner_labels, whspace=0.1, factor=1.8, ) gridcorner_fig.savefig( os.path.join(self.search.outdir, self.search.label + "_corner.png"))
tglitch_vals_days = (tglitch_vals - tstart) / 86400.0 - dtglitch / 86400.0 print("Making gridcorner plot...") twoF = search.data["twoF"].reshape( (len(F0_vals), len(F1_vals), len(delta_F0s_vals), len(tglitch_vals))) xyz = [F0_vals * 1e6, F1_vals * 1e12, delta_F0s_vals * 1e6, tglitch_vals_days] labels = [ "$f - f_\\mathrm{s}$\n[$\\mu$Hz]", "$\\dot{f} - \\dot{f}_\\mathrm{s}$\n[$p$Hz/s]", "$\\delta f-\\delta f_\\mathrm{s}$\n[$\\mu$Hz]", "$t^\\mathrm{g} - t^\\mathrm{g}_\\mathrm{s}$\n[d]", "$t^\\mathrm{g} - t^\\mathrm{g}_\\mathrm{s}$\n[d]", "$\\widehat{2\\mathcal{F}}$", ] fig, axes = pyfstat.gridcorner( twoF, xyz, projection="log_mean", labels=labels, showDvals=False, lines=[0, 0, 0, 0], label_offset=0.25, max_n_ticks=4, ) fig.savefig("{}/{}_projection_matrix.png".format(outdir, label), bbox_inches="tight") print(("Prior widths =", F0_width, F1_width)) print(("Actual run time = {}".format(dT))) print(("Actual number of grid points = {}".format(search.data.shape[0])))
for key in search_keys: gridsearch.plot_1D(xkey=key, xlabel=labels[key], ylabel=labels["2F"]) print("Making GridSearch {:s} corner plot...".format("-".join(search_keys))) vals = [np.unique(gridsearch.data[key]) - inj[key] for key in search_keys] twoF = gridsearch.data["twoF"].reshape([len(kval) for kval in vals]) corner_labels = [ "$f - f_0$ [Hz]", "$\\dot{f} - \\dot{f}_0$ [Hz/s]", ] if sky: corner_labels.append("$\\alpha - \\alpha_0$") corner_labels.append("$\\delta - \\delta_0$") corner_labels.append(labels["2F"]) gridcorner_fig, gridcorner_axes = pyfstat.gridcorner( twoF, vals, projection="log_mean", labels=corner_labels, whspace=0.1, factor=1.8 ) gridcorner_fig.savefig(os.path.join(outdir, gridsearch.label + "_corner.png")) plt.close(gridcorner_fig) print("") print("Performing MCMCSearch...") # set up priors in F0 and F1 (over)covering the grid ranges if sky: # MCMC will still be fast in 4D with wider range than grid DeltaF0 *= 50 DeltaF1 *= 50 theta_prior = { "F0": { "type": "unif", "lower": inj["F0"] - DeltaF0 / 2.0, "upper": inj["F0"] + DeltaF0 / 2.0,
tref, tstart, tend, ) search.run() print("Plotting 2F(F0)...") search.plot_1D(xkey="F0", xlabel="freq [Hz]", ylabel="$2\\mathcal{F}$") print("Plotting 2F(F1)...") search.plot_1D(xkey="F1") print("Plotting 2F(F0,F1)...") search.plot_2D(xkey="F0", ykey="F1", colorbar=True) print("Making gridcorner plot...") F0_vals = np.unique(search.data["F0"]) - F0 F1_vals = np.unique(search.data["F1"]) - F1 twoF = search.data["twoF"].reshape((len(F0_vals), len(F1_vals))) xyz = [F0_vals, F1_vals] labels = [ "$f - f_0$", "$\\dot{f} - \\dot{f}_0$", "$\\widetilde{2\\mathcal{F}}$", ] fig, axes = pyfstat.gridcorner(twoF, xyz, projection="log_mean", labels=labels, whspace=0.1, factor=1.8) fig.savefig(os.path.join(outdir, label + "_projection_matrix.png"))