Skip to content
Snippets Groups Projects
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
No related branches found
No related tags found
No related merge requests found
...@@ -16,7 +16,7 @@ data_tstart = tstart - duration ...@@ -16,7 +16,7 @@ data_tstart = tstart - duration
data_tend = data_tstart + 3*duration data_tend = data_tstart + 3*duration
tref = .5*(data_tstart+data_tend) tref = .5*(data_tstart+data_tend)
h0 = 3e-24 h0 = 4e-24
sqrtSX = 1e-22 sqrtSX = 1e-22
transient = pyfstat.Writer( transient = pyfstat.Writer(
...@@ -56,8 +56,11 @@ mcmc = pyfstat.MCMCSearch( ...@@ -56,8 +56,11 @@ mcmc = pyfstat.MCMCSearch(
log10temperature_min=log10temperature_min) log10temperature_min=log10temperature_min)
mcmc.run() mcmc.run()
fig, ax = plt.subplots() fig, ax = plt.subplots()
mcmc.write_par()
mcmc.generate_loudest()
mcmc.plot_cumulative_max(ax=ax) mcmc.plot_cumulative_max(ax=ax)
ax.set_xlabel('Days from $t_\mathrm{start}$') ax.set_xlabel('Days from $t_\mathrm{start}$')
ax.legend_.remove()
fig.savefig('data/transient_search_initial_stage_twoFcumulative') fig.savefig('data/transient_search_initial_stage_twoFcumulative')
mcmc.print_summary() mcmc.print_summary()
......
Paper/transient_search_initial_stage_twoFcumulative.png

43.1 KiB | W: | H:

Paper/transient_search_initial_stage_twoFcumulative.png

46.9 KiB | W: | H:

Paper/transient_search_initial_stage_twoFcumulative.png
Paper/transient_search_initial_stage_twoFcumulative.png
Paper/transient_search_initial_stage_twoFcumulative.png
Paper/transient_search_initial_stage_twoFcumulative.png
  • 2-up
  • Swipe
  • Onion skin
...@@ -512,7 +512,6 @@ class ComputeFstat(object): ...@@ -512,7 +512,6 @@ class ComputeFstat(object):
minfraction=0.01, maxfraction=1): minfraction=0.01, maxfraction=1):
""" Calculate the cumulative twoF along the obseration span """ """ Calculate the cumulative twoF along the obseration span """
duration = tend - tstart duration = tend - tstart
tstart = tstart + minfraction*duration
taus = np.linspace(minfraction*duration, maxfraction*duration, npoints) taus = np.linspace(minfraction*duration, maxfraction*duration, npoints)
twoFs = [] twoFs = []
if self.transient is False: if self.transient is False:
...@@ -526,9 +525,12 @@ class ComputeFstat(object): ...@@ -526,9 +525,12 @@ class ComputeFstat(object):
return taus, np.array(twoFs) return taus, np.array(twoFs)
def calculatate_pfs(self, label, outdir, N=15, IFO=None): 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: if os.path.isfile('{}/{}.loudest'.format(outdir, label)) is False:
raise ValueError('Need a loudest file to add the predicted Fstat') raise ValueError(
'Need a loudest file to add the predicted Fstat')
loudest = read_par(label, outdir, suffix='loudest') loudest = read_par(label, outdir, suffix='loudest')
pfs_input = {key: loudest[key] for key in pfs_input = {key: loudest[key] for key in
['h0', 'cosi', 'psi', 'Alpha', 'Delta', 'Freq']} ['h0', 'cosi', 'psi', 'Alpha', 'Delta', 'Freq']}
...@@ -560,14 +562,15 @@ class ComputeFstat(object): ...@@ -560,14 +562,15 @@ class ComputeFstat(object):
self.detector_names = detector_names self.detector_names = detector_names
if add_pfs: 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( ax.fill_between(
(times-self.minStartTime)/86400., pfs-pfs_sigma, pfs+pfs_sigma, (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) zorder=-10, alpha=0.2)
if len(self.detector_names) > 1: if len(self.detector_names) > 1:
for d in self.detector_names: 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) label, outdir, IFO=d.upper(), N=N)
ax.fill_between( ax.fill_between(
(times-self.minStartTime)/86400., pfs-pfs_sigma, (times-self.minStartTime)/86400., pfs-pfs_sigma,
...@@ -585,7 +588,7 @@ class ComputeFstat(object): ...@@ -585,7 +588,7 @@ class ComputeFstat(object):
else: else:
ax.set_ylabel(r'$\widetilde{2\mathcal{F}}_{\rm cumulative}$') ax.set_ylabel(r'$\widetilde{2\mathcal{F}}_{\rm cumulative}$')
ax.set_xlim(0, taus[-1]/86400) ax.set_xlim(0, taus[-1]/86400)
ax.legend(frameon=False) ax.legend(frameon=False, loc=2, fontsize=6)
if title: if title:
ax.set_title(title) ax.set_title(title)
if savefig: if savefig:
......
...@@ -75,8 +75,11 @@ class GridSearch(BaseSearchClass): ...@@ -75,8 +75,11 @@ class GridSearch(BaseSearchClass):
def get_array_from_tuple(self, x): def get_array_from_tuple(self, x):
if len(x) == 1: if len(x) == 1:
return np.array(x) return np.array(x)
elif len(x) == 3:
return np.arange(x[0], x[1], x[2])
else: 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): def get_input_data_array(self):
arrays = [] arrays = []
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment