From 52c930537be1adfe1511ef131ac7221351d02f19 Mon Sep 17 00:00:00 2001
From: Gregory Ashton <gregory.ashton@ligo.org>
Date: Wed, 7 Jun 2017 14:13:43 +0200
Subject: [PATCH] Modifcations to the DMoff test

- Adds ability to use either a dict or a par file
- Fixes bug in which if tstart and tend aren't specificed the data
  saving mechanism breaks
---
 pyfstat/grid_based_searches.py | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/pyfstat/grid_based_searches.py b/pyfstat/grid_based_searches.py
index d4164ca..ee784be 100644
--- a/pyfstat/grid_based_searches.py
+++ b/pyfstat/grid_based_searches.py
@@ -133,7 +133,7 @@ class GridSearch(BaseSearchClass):
             FS = self.search.get_det_stat(*vals)
             data.append(list(vals) + [FS])
 
-        data = np.array(data)
+        data = np.array(data, dtype=np.float)
         if return_data:
             return data
         else:
@@ -454,15 +454,16 @@ class FrequencySlidingWindow(GridSearch):
 class DMoff_NO_SPIN(GridSearch):
     """ DMoff test using SSBPREC_NO_SPIN """
     @helper_functions.initializer
-    def __init__(self, par_file, label, outdir, sftfilepath, minStartTime=None,
+    def __init__(self, par, label, outdir, sftfilepath, minStartTime=None,
                  maxStartTime=None, minCoverFreq=None, maxCoverFreq=None,
                  earth_ephem=None, sun_ephem=None, detectors=None,
                  injectSources=None, assumeSqrtSX=None):
         """
         Parameters
         ----------
-        par_file: str
-            Path to a .par file to read in the F0, F1 etc
+        par: dict, str
+            Either a par dictionary (containing 'F0', 'F1', 'Alpha', 'Delta'
+            and 'tref') or a path to a .par file to read in the F0, F1 etc
         label, outdir: str
             A label and directory to read/write data from/to
         sftfilepath: str
@@ -481,8 +482,10 @@ class DMoff_NO_SPIN(GridSearch):
         if os.path.isdir(outdir) is False:
             os.mkdir(outdir)
 
-        if os.path.isfile(par_file):
-            self.par = read_par(filename=par_file)
+        if type(par) == dict:
+            self.par = par
+        elif type(par) == str and os.path.isfile(par):
+            self.par = read_par(filename=par)
         else:
             raise ValueError('The .par file does not exist')
 
-- 
GitLab