diff --git a/Paper/Examples/transient_search_using_MCMC.py b/Paper/Examples/transient_search_using_MCMC.py index b45fcf545819dc63d21792e55358caefe929f944..c115edbf01bb975a1d33fa129d1a250048e135d0 100644 --- a/Paper/Examples/transient_search_using_MCMC.py +++ b/Paper/Examples/transient_search_using_MCMC.py @@ -16,7 +16,7 @@ data_tstart = tstart - duration data_tend = data_tstart + 3*duration tref = .5*(data_tstart+data_tend) -h0 = 3e-24 +h0 = 4e-24 sqrtSX = 1e-22 transient = pyfstat.Writer( @@ -56,8 +56,11 @@ mcmc = pyfstat.MCMCSearch( log10temperature_min=log10temperature_min) mcmc.run() fig, ax = plt.subplots() +mcmc.write_par() +mcmc.generate_loudest() mcmc.plot_cumulative_max(ax=ax) ax.set_xlabel('Days from $t_\mathrm{start}$') +ax.legend_.remove() fig.savefig('data/transient_search_initial_stage_twoFcumulative') mcmc.print_summary() diff --git a/Paper/transient_search_initial_stage_twoFcumulative.png b/Paper/transient_search_initial_stage_twoFcumulative.png index 85fb01c8e8d865d7262a9b0102ec2798cf221b4e..a08cb6e9137e84f55be5dd1d29f39fd893a3c54a 100644 Binary files a/Paper/transient_search_initial_stage_twoFcumulative.png and b/Paper/transient_search_initial_stage_twoFcumulative.png differ diff --git a/pyfstat/core.py b/pyfstat/core.py index 9bb8cf603b4d6a41fcb7bd81b06b842433299a6d..80fa75ec975b6d4132d5a232465eff1ed7c5f6a2 100755 --- a/pyfstat/core.py +++ b/pyfstat/core.py @@ -512,7 +512,6 @@ class ComputeFstat(object): minfraction=0.01, maxfraction=1): """ Calculate the cumulative twoF along the obseration span """ duration = tend - tstart - tstart = tstart + minfraction*duration taus = np.linspace(minfraction*duration, maxfraction*duration, npoints) twoFs = [] if self.transient is False: @@ -526,12 +525,15 @@ class ComputeFstat(object): return taus, np.array(twoFs) - def calculatate_pfs(self, label, outdir, N=15, IFO=None): - if os.path.isfile('{}/{}.loudest'.format(outdir, label)) is False: - raise ValueError('Need a loudest file to add the predicted Fstat') - loudest = read_par(label, outdir, suffix='loudest') - pfs_input = {key: loudest[key] for key in - ['h0', 'cosi', 'psi', 'Alpha', 'Delta', 'Freq']} + def calculate_pfs(self, label, outdir, N=15, IFO=None, pfs_input=None): + + if pfs_input is None: + if os.path.isfile('{}/{}.loudest'.format(outdir, label)) is False: + raise ValueError( + 'Need a loudest file to add the predicted Fstat') + loudest = read_par(label, outdir, suffix='loudest') + pfs_input = {key: loudest[key] for key in + ['h0', 'cosi', 'psi', 'Alpha', 'Delta', 'Freq']} times = np.linspace(self.minStartTime, self.maxStartTime, N+1)[1:] times = np.insert(times, 0, self.minStartTime + 86400/2.) out = [predict_fstat(minStartTime=self.minStartTime, maxStartTime=t, @@ -560,14 +562,15 @@ class ComputeFstat(object): self.detector_names = detector_names if add_pfs: - times, pfs, pfs_sigma = self.calculatate_pfs(label, outdir, N=N) + times, pfs, pfs_sigma = self.calculate_pfs(label, outdir, N=N) ax.fill_between( (times-self.minStartTime)/86400., pfs-pfs_sigma, pfs+pfs_sigma, - color=c, label='Predicted $2\mathcal{F}$ 1-$\sigma$ band', + color=c, + label=r'Predicted $\langle 2\mathcal{F} \rangle\pm $ 1-$\sigma$ band', zorder=-10, alpha=0.2) if len(self.detector_names) > 1: for d in self.detector_names: - times, pfs, pfs_sigma = self.calculatate_pfs( + times, pfs, pfs_sigma = self.calculate_pfs( label, outdir, IFO=d.upper(), N=N) ax.fill_between( (times-self.minStartTime)/86400., pfs-pfs_sigma, @@ -585,7 +588,7 @@ class ComputeFstat(object): else: ax.set_ylabel(r'$\widetilde{2\mathcal{F}}_{\rm cumulative}$') ax.set_xlim(0, taus[-1]/86400) - ax.legend(frameon=False) + ax.legend(frameon=False, loc=2, fontsize=6) if title: ax.set_title(title) if savefig: diff --git a/pyfstat/grid_based_searches.py b/pyfstat/grid_based_searches.py index 6ed2963a740914b036a0738f0be18c4f38b976d6..cced059125cb0dad9e1b5feb935d81a86f18a4e0 100644 --- a/pyfstat/grid_based_searches.py +++ b/pyfstat/grid_based_searches.py @@ -75,8 +75,11 @@ class GridSearch(BaseSearchClass): def get_array_from_tuple(self, x): if len(x) == 1: return np.array(x) + elif len(x) == 3: + return np.arange(x[0], x[1], x[2]) else: - return np.arange(x[0], x[1]*(1+1e-15), x[2]) + logging.info('Using tuple as is') + return np.array(x) def get_input_data_array(self): arrays = []