Skip to content
Snippets Groups Projects
Commit ef0b108c authored by Gregory Ashton's avatar Gregory Ashton
Browse files

Various minor changes

- Adds latex prior table writer (not found to be useful)
- Add special case of 0 to texify_float
- Expose texify_float in core
- Fix confusing argument order in GridSearch
parent a20684b8
Branches
Tags
No related merge requests found
...@@ -3,4 +3,5 @@ from __future__ import division ...@@ -3,4 +3,5 @@ from __future__ import division
from .core import BaseSearchClass, ComputeFstat, Writer from .core import BaseSearchClass, ComputeFstat, Writer
from .mcmc_based_searches import * from .mcmc_based_searches import *
from .grid_based_searches import * from .grid_based_searches import *
from .helper_functions import texify_float
...@@ -18,8 +18,8 @@ class GridSearch(BaseSearchClass): ...@@ -18,8 +18,8 @@ class GridSearch(BaseSearchClass):
""" Gridded search using ComputeFstat """ """ Gridded search using ComputeFstat """
@helper_functions.initializer @helper_functions.initializer
def __init__(self, label, outdir, sftfilepath, F0s=[0], F1s=[0], F2s=[0], def __init__(self, label, outdir, sftfilepath, F0s=[0], F1s=[0], F2s=[0],
Alphas=[0], Deltas=[0], tref=None, minStartTime=None, nsegs=1, Alphas=[0], Deltas=[0], tref=None, minStartTime=None,
maxStartTime=None, BSGL=False, minCoverFreq=None, maxStartTime=None, nsegs=1, BSGL=False, minCoverFreq=None,
maxCoverFreq=None, earth_ephem=None, sun_ephem=None, maxCoverFreq=None, earth_ephem=None, sun_ephem=None,
detectors=None): detectors=None):
""" """
......
...@@ -94,6 +94,8 @@ def round_to_n(x, n): ...@@ -94,6 +94,8 @@ def round_to_n(x, n):
def texify_float(x, d=2): def texify_float(x, d=2):
if x == 0:
return 0
if type(x) == str: if type(x) == str:
return x return x
x = round_to_n(x, d) x = round_to_n(x, d)
......
...@@ -95,6 +95,12 @@ class MCMCSearch(core.BaseSearchClass): ...@@ -95,6 +95,12 @@ class MCMCSearch(core.BaseSearchClass):
if args.clean and os.path.isfile(self.pickle_path): if args.clean and os.path.isfile(self.pickle_path):
os.rename(self.pickle_path, self.pickle_path+".old") 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() self.log_input()
def log_input(self): def log_input(self):
...@@ -1028,6 +1034,35 @@ class MCMCSearch(core.BaseSearchClass): ...@@ -1028,6 +1034,35 @@ class MCMCSearch(core.BaseSearchClass):
for key, val in max_twoF_d.iteritems(): for key, val in max_twoF_d.iteritems():
f.write('{} = {:1.16e}\n'.format(key, val)) 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): def print_summary(self):
max_twoFd, max_twoF = self.get_max_twoF() max_twoFd, max_twoF = self.get_max_twoF()
median_std_d = self.get_median_stds() median_std_d = self.get_median_stds()
...@@ -1231,6 +1266,13 @@ class MCMCGlitchSearch(MCMCSearch): ...@@ -1231,6 +1266,13 @@ class MCMCGlitchSearch(MCMCSearch):
os.rename(self.pickle_path, self.pickle_path+".old") 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.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() self.log_input()
def initiate_search_object(self): def initiate_search_object(self):
...@@ -1779,6 +1821,14 @@ class MCMCFollowUpSearch(MCMCSemiCoherentSearch): ...@@ -1779,6 +1821,14 @@ class MCMCFollowUpSearch(MCMCSemiCoherentSearch):
class MCMCTransientSearch(MCMCSearch): class MCMCTransientSearch(MCMCSearch):
""" MCMC search for a transient signal using the ComputeFstat """ """ 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): def initiate_search_object(self):
logging.info('Setting up search object') logging.info('Setting up search object')
self.search = core.ComputeFstat( self.search = core.ComputeFstat(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment