Commit 424aae93 authored by Gregory Ashton's avatar Gregory Ashton
Browse files

Several minor updates

1) Add ability to in F0s, F1s etc in grid search directly (use tuple as (is)
2) Update cumulative legend
3) Add option to produce pfs_input directly to calculate_pfs
4) Fix spelling mistake
5) Update transient example in the paper
parent 1191ecc2
......@@ -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()
......
......@@ -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:
......
......@@ -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 = []
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment