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

Adds semi-coherent functionality to grid search

If nsegs > 1, a semi-coherent search is performed.
parent 5eb8713e
No related branches found
No related tags found
No related merge requests found
...@@ -10,7 +10,7 @@ import matplotlib ...@@ -10,7 +10,7 @@ import matplotlib
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
import helper_functions import helper_functions
from core import BaseSearchClass, ComputeFstat, SemiCoherentGlitchSearch from core import BaseSearchClass, ComputeFstat, SemiCoherentGlitchSearch, SemiCoherentSearch
from core import tqdm, args, earth_ephem, sun_ephem from core import tqdm, args, earth_ephem, sun_ephem
...@@ -18,7 +18,7 @@ class GridSearch(BaseSearchClass): ...@@ -18,7 +18,7 @@ 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, Alphas=[0], Deltas=[0], tref=None, minStartTime=None, nsegs=1,
maxStartTime=None, BSGL=False, minCoverFreq=None, maxStartTime=None, BSGL=False, minCoverFreq=None,
maxCoverFreq=None, earth_ephem=None, sun_ephem=None, maxCoverFreq=None, earth_ephem=None, sun_ephem=None,
detectors=None): detectors=None):
...@@ -50,6 +50,7 @@ class GridSearch(BaseSearchClass): ...@@ -50,6 +50,7 @@ class GridSearch(BaseSearchClass):
def inititate_search_object(self): def inititate_search_object(self):
logging.info('Setting up search object') logging.info('Setting up search object')
if self.nsegs == 1:
self.search = ComputeFstat( self.search = ComputeFstat(
tref=self.tref, sftfilepath=self.sftfilepath, tref=self.tref, sftfilepath=self.sftfilepath,
minCoverFreq=self.minCoverFreq, maxCoverFreq=self.maxCoverFreq, minCoverFreq=self.minCoverFreq, maxCoverFreq=self.maxCoverFreq,
...@@ -57,6 +58,19 @@ class GridSearch(BaseSearchClass): ...@@ -57,6 +58,19 @@ class GridSearch(BaseSearchClass):
detectors=self.detectors, transient=False, detectors=self.detectors, transient=False,
minStartTime=self.minStartTime, maxStartTime=self.maxStartTime, minStartTime=self.minStartTime, maxStartTime=self.maxStartTime,
BSGL=self.BSGL) BSGL=self.BSGL)
self.search.get_det_stat = self.search.run_computefstatistic_single_point
else:
self.search = SemiCoherentSearch(
label=self.label, outdir=self.outdir, tref=self.tref,
nsegs=self.nsegs, sftfilepath=self.sftfilepath,
BSGL=self.BSGL, minStartTime=self.minStartTime,
maxStartTime=self.maxStartTime, minCoverFreq=self.minCoverFreq,
maxCoverFreq=self.maxCoverFreq, detectors=self.detectors,
earth_ephem=self.earth_ephem, sun_ephem=self.sun_ephem)
def cut_out_tstart_tend(*vals):
return self.search.run_semi_coherent_computefstatistic_single_point(*vals[2:])
self.search.get_det_stat = cut_out_tstart_tend
def get_array_from_tuple(self, x): def get_array_from_tuple(self, x):
if len(x) == 1: if len(x) == 1:
...@@ -107,7 +121,7 @@ class GridSearch(BaseSearchClass): ...@@ -107,7 +121,7 @@ class GridSearch(BaseSearchClass):
data = [] data = []
for vals in tqdm(self.input_data): for vals in tqdm(self.input_data):
FS = self.search.run_computefstatistic_single_point(*vals) FS = self.search.get_det_stat(*vals)
data.append(list(vals) + [FS]) data.append(list(vals) + [FS])
data = np.array(data) data = np.array(data)
...@@ -236,7 +250,8 @@ class GridSearch(BaseSearchClass): ...@@ -236,7 +250,8 @@ class GridSearch(BaseSearchClass):
class GridUniformPriorSearch(): class GridUniformPriorSearch():
def __init__(self, theta_prior, NF0, NF1, label, outdir, sftfilepath, def __init__(self, theta_prior, NF0, NF1, label, outdir, sftfilepath,
tref, minStartTime, maxStartTime, BSGL=False, detectors=None): tref, minStartTime, maxStartTime, minCoverFreq=None,
maxCoverFreq=None, BSGL=False, detectors=None, nsegs=1):
dF0 = (theta_prior['F0']['upper'] - theta_prior['F0']['lower'])/NF0 dF0 = (theta_prior['F0']['upper'] - theta_prior['F0']['lower'])/NF0
dF1 = (theta_prior['F1']['upper'] - theta_prior['F1']['lower'])/NF1 dF1 = (theta_prior['F1']['upper'] - theta_prior['F1']['lower'])/NF1
F0s = [theta_prior['F0']['lower'], theta_prior['F0']['upper'], dF0] F0s = [theta_prior['F0']['lower'], theta_prior['F0']['upper'], dF0]
...@@ -245,7 +260,8 @@ class GridUniformPriorSearch(): ...@@ -245,7 +260,8 @@ class GridUniformPriorSearch():
label, outdir, sftfilepath, F0s=F0s, F1s=F1s, tref=tref, label, outdir, sftfilepath, F0s=F0s, F1s=F1s, tref=tref,
Alphas=[theta_prior['Alpha']], Deltas=[theta_prior['Delta']], Alphas=[theta_prior['Alpha']], Deltas=[theta_prior['Delta']],
minStartTime=minStartTime, maxStartTime=maxStartTime, BSGL=BSGL, minStartTime=minStartTime, maxStartTime=maxStartTime, BSGL=BSGL,
detectors=detectors) detectors=detectors, minCoverFreq=minCoverFreq,
maxCoverFreq=maxCoverFreq, nsegs=nsegs)
def run(self, **kwargs): def run(self, **kwargs):
self.search.run() self.search.run()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment