def test_transient_grid_search(self): search = pyfstat.TransientGridSearch( "grid_search", self.outdir, self.Writer.sftfilepath, F0s=self.F0s, F1s=[self.Writer.F1], F2s=[self.Writer.F2], Alphas=[self.Writer.Alpha], Deltas=[self.Writer.Delta], tref=self.tref, minStartTime=self.Writer.tstart, maxStartTime=self.Writer.tend, transientWindowType="rect", t0Band=self.Writer.duration - 2 * self.Writer.Tsft, tauBand=self.Writer.duration, outputTransientFstatMap=True, tCWFstatMapVersion="lal", ) search.run() self.assertTrue(os.path.isfile(search.out_file)) max2F_point = search.get_max_twoF() self.assertTrue(np.all(max2F_point["twoF"] >= search.data["twoF"])) tCWfile = search.get_transient_fstat_map_filename(max2F_point) tCW_out = pyfstat.helper_functions.read_txt_file_with_header( tCWfile, comments="#") max2Fidx = np.argmax(tCW_out["2F"]) self.assertTrue( np.isclose(max2F_point["twoF"], tCW_out["2F"][max2Fidx], rtol=1e-6, atol=0)) self.assertTrue(max2F_point["t0"] == tCW_out["t0s"][max2Fidx]) self.assertTrue(max2F_point["tau"] == tCW_out["taus"][max2Fidx])
Alphas=Alphas, Deltas=Deltas, tref=data.tref, BSGL=BSGL, ) search1.run() search1.print_max_twoF() search1.plot_1D(xkey="F0", xlabel="freq [Hz]", ylabel="$2\\mathcal{F}$") print("with t0,tau bands:") search2 = pyfstat.TransientGridSearch( label="tCW" + ("_BSGL" if BSGL else ""), outdir=data.outdir, sftfilepattern=os.path.join(data.outdir, "*simulated_transient_signal*sft"), F0s=F0s, F1s=F1s, F2s=F2s, Alphas=Alphas, Deltas=Deltas, tref=data.tref, transientWindowType="rect", t0Band=data.duration - 2 * data.Tsft, tauBand=data.duration, outputTransientFstatMap=True, tCWFstatMapVersion="lal", BSGL=BSGL, ) search2.run() search2.print_max_twoF() search2.plot_1D(xkey="F0", xlabel="freq [Hz]", ylabel="$2\\mathcal{F}$")
) search1.run() search1.print_max_twoF() search1.plot_1D(xkey="F0", xlabel="freq [Hz]", ylabel="$2\mathcal{F}$") print("with t0,tau bands:") search2 = pyfstat.TransientGridSearch( label="tCW", outdir=datadir, sftfilepattern=os.path.join(datadir, "*simulated_transient_signal*sft"), F0s=F0s, F1s=F1s, F2s=F2s, Alphas=Alphas, Deltas=Deltas, tref=tref, minStartTime=minStartTime, maxStartTime=maxStartTime, transientWindowType="rect", t0Band=Tspan - 2 * Tsft, tauBand=Tspan, BSGL=False, outputTransientFstatMap=True, tCWFstatMapVersion="lal", ) search2.run() search2.print_max_twoF() search2.plot_1D(xkey="F0", xlabel="freq [Hz]", ylabel="$2\mathcal{F}$")