From 1191ecc214c6dfc8cdfedf63fe8863c906ad67f8 Mon Sep 17 00:00:00 2001 From: "gregory.ashton" <gregory.ashton@ligo.org> Date: Fri, 21 Apr 2017 17:16:07 +0200 Subject: [PATCH] Minor improvements to general running 1) Adds check if the truths are not of the correct length (to prevent corner.corner error) 2) Improve sliding window labels 3) Adds option to plot gps seconds on the sliding window --- pyfstat/grid_based_searches.py | 15 +++++++++++---- pyfstat/mcmc_based_searches.py | 4 ++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/pyfstat/grid_based_searches.py b/pyfstat/grid_based_searches.py index ea078e8..6ed2963 100644 --- a/pyfstat/grid_based_searches.py +++ b/pyfstat/grid_based_searches.py @@ -399,7 +399,7 @@ class FrequencySlidingWindow(GridSearch): self.input_data = np.array(input_data) def plot_sliding_window(self, F0=None, ax=None, savefig=True, - colorbar=True): + colorbar=True, timestamps=False): data = self.data if ax is None: ax = plt.subplot() @@ -411,7 +411,7 @@ class FrequencySlidingWindow(GridSearch): dts = (tmids - self.minStartTime) / 86400. if F0: frequencies = frequencies - F0 - ax.set_ylabel('Frequency - $f_0$ [Hz]') + ax.set_ylabel('Frequency - $f_0$ [Hz] \n $f_0={:0.2f}$'.format(F0)) else: ax.set_ylabel('Frequency [Hz]') twoF = twoF.reshape((len(tmids), len(frequencies))) @@ -421,10 +421,17 @@ class FrequencySlidingWindow(GridSearch): cb = plt.colorbar(pax, ax=ax) cb.set_label('$2\mathcal{F}$') ax.set_xlabel( - r'Days from $t_\mathrm{{start}}$={}'.format(self.minStartTime)) + r'Mid-point (days after $t_\mathrm{{start}}$={})'.format( + self.minStartTime)) ax.set_title( 'Sliding window length = {} days in increments of {} days' - .format(self.window_size/86400, self.window_delta/86400)) + .format(self.window_size/86400, self.window_delta/86400), + ) + if timestamps: + axT = ax.twiny() + axT.set_xlim(tmids[0]*1e-9, tmids[-1]*1e-9) + axT.set_xlabel('Mid-point timestamp [GPS $10^{9}$ s]') + ax.set_title(ax.get_title(), y=1.18) if savefig: plt.tight_layout() plt.savefig( diff --git a/pyfstat/mcmc_based_searches.py b/pyfstat/mcmc_based_searches.py index 29892cc..9acd2fa 100644 --- a/pyfstat/mcmc_based_searches.py +++ b/pyfstat/mcmc_based_searches.py @@ -544,6 +544,10 @@ class MCMCSearch(core.BaseSearchClass): """ + if 'truths' in kwargs and len(kwargs['truths']) != self.ndim: + logging.warning('len(Truths) != ndim, Truths will be ignored') + kwargs['truths'] = None + if self.ndim < 2: with plt.rc_context(rc_context): if fig_and_axes is None: -- GitLab