diff --git a/pyfstat/__init__.py b/pyfstat/__init__.py index 9e6c40f0a2abebfbc522115f6fbf37e25508ed30..d1c4da564ee45d48d0915b6f32c78e553a1c5897 100644 --- a/pyfstat/__init__.py +++ b/pyfstat/__init__.py @@ -3,4 +3,5 @@ from __future__ import division from .core import BaseSearchClass, ComputeFstat, Writer from .mcmc_based_searches import * from .grid_based_searches import * +from .helper_functions import texify_float diff --git a/pyfstat/grid_based_searches.py b/pyfstat/grid_based_searches.py index e05318d39e4c839a16d771ec8a5a53f77ebaff49..b59c478b583e218b15c2539e951bb7fe0ed00c44 100644 --- a/pyfstat/grid_based_searches.py +++ b/pyfstat/grid_based_searches.py @@ -18,8 +18,8 @@ class GridSearch(BaseSearchClass): """ Gridded search using ComputeFstat """ @helper_functions.initializer def __init__(self, label, outdir, sftfilepath, F0s=[0], F1s=[0], F2s=[0], - Alphas=[0], Deltas=[0], tref=None, minStartTime=None, nsegs=1, - maxStartTime=None, BSGL=False, minCoverFreq=None, + Alphas=[0], Deltas=[0], tref=None, minStartTime=None, + maxStartTime=None, nsegs=1, BSGL=False, minCoverFreq=None, maxCoverFreq=None, earth_ephem=None, sun_ephem=None, detectors=None): """ diff --git a/pyfstat/helper_functions.py b/pyfstat/helper_functions.py index 31503ea595386d8477fb8ef0d6946dc3ca200828..c153915b218b1c5e82572b2d4c57dcaaf1d059f2 100644 --- a/pyfstat/helper_functions.py +++ b/pyfstat/helper_functions.py @@ -94,6 +94,8 @@ def round_to_n(x, n): def texify_float(x, d=2): + if x == 0: + return 0 if type(x) == str: return x x = round_to_n(x, d) diff --git a/pyfstat/mcmc_based_searches.py b/pyfstat/mcmc_based_searches.py index 836bee1c373b110528485dac31b322fbf31e3542..066c70c986b282374a8364963b2bcbef036d1179 100644 --- a/pyfstat/mcmc_based_searches.py +++ b/pyfstat/mcmc_based_searches.py @@ -95,6 +95,12 @@ class MCMCSearch(core.BaseSearchClass): if args.clean and os.path.isfile(self.pickle_path): os.rename(self.pickle_path, self.pickle_path+".old") + self.symbol_dictionary = dict( + F0='$f$', F1='$\dot{f}$', F2='$\ddot{f}$', alpha=r'$\alpha$', + delta='$\delta$') + self.unit_dictionary = dict( + F0='Hz', F1='Hz/s', F2='Hz/s$^2$', alpha=r'rad', delta='rad') + self.log_input() def log_input(self): @@ -1028,6 +1034,35 @@ class MCMCSearch(core.BaseSearchClass): for key, val in max_twoF_d.iteritems(): f.write('{} = {:1.16e}\n'.format(key, val)) + def write_prior_table(self): + with open('{}/{}_prior.tex'.format(self.outdir, self.label), 'w') as f: + f.write(r"\begin{tabular}{c l c} \hline" + '\n' + r"Parameter & & & \\ \hhline{====}") + + for key, prior in self.theta_prior.iteritems(): + if type(prior) is dict: + Type = prior['type'] + if Type == "unif": + a = prior['lower'] + b = prior['upper'] + line = r"{} & $\mathrm{{Unif}}$({}, {}) & {}\\" + elif Type == "norm": + a = prior['loc'] + b = prior['scale'] + line = r"{} & $\mathcal{{N}}$({}, {}) & {}\\" + elif Type == "halfnorm": + a = prior['loc'] + b = prior['scale'] + line = r"{} & $|\mathcal{{N}}$({}, {})| & {}\\" + + u = self.unit_dictionary[key] + s = self.symbol_dictionary[key] + f.write("\n") + a = helper_functions.texify_float(a) + b = helper_functions.texify_float(b) + f.write(" " + line.format(s, a, b, u) + r" \\") + f.write("\n\end{tabular}\n") + def print_summary(self): max_twoFd, max_twoF = self.get_max_twoF() median_std_d = self.get_median_stds() @@ -1231,6 +1266,13 @@ class MCMCGlitchSearch(MCMCSearch): os.rename(self.pickle_path, self.pickle_path+".old") self.old_data_is_okay_to_use = self.check_old_data_is_okay_to_use() + self.symbol_dictionary = dict( + F0='$f$', F1='$\dot{f}$', F2='$\ddot{f}$', alpha=r'$\alpha$', + delta='$\delta$', delta_F0='$\delta f$', + delta_F1='$\delta \dot{f}$', tglitch='$t_\mathrm{glitch}$') + self.unit_dictionary = dict( + F0='Hz', F1='Hz/s', F2='Hz/s$^2$', alpha=r'rad', delta='rad', + delta_F0='Hz', delta_F1='Hz/s', tglitch='s') self.log_input() def initiate_search_object(self): @@ -1779,6 +1821,14 @@ class MCMCFollowUpSearch(MCMCSemiCoherentSearch): class MCMCTransientSearch(MCMCSearch): """ MCMC search for a transient signal using the ComputeFstat """ + symbol_dictionary = dict( + F0='$f$', F1='$\dot{f}$', F2='$\ddot{f}$', + alpha=r'$\alpha$', delta='$\delta$', tstart='$t_\mathrm{start}$', + tend='$t_\mathrm{end}$') + unit_dictionary = dict( + F0='Hz', F1='Hz/s', F2='Hz/s$^2$', alpha=r'rad', delta='rad', + tstart='s', tend='s') + def initiate_search_object(self): logging.info('Setting up search object') self.search = core.ComputeFstat(