From f770b66c9b2aa8bd7498fc86813b0c9bb8dce986 Mon Sep 17 00:00:00 2001
From: "gregory.ashton" <gregory.ashton@ligo.org>
Date: Tue, 13 Dec 2016 19:53:04 +0100
Subject: [PATCH] Fixes issues when using transient searches

Issues:
1) If tstart and duration where not explicity searched over, a loop
condition would quickly send the duration to infinity
2) Fixed half norm definition
---
 pyfstat.py | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/pyfstat.py b/pyfstat.py
index 7e4db11..a0f4184 100755
--- a/pyfstat.py
+++ b/pyfstat.py
@@ -1338,7 +1338,7 @@ class MCMCSearch(BaseSearchClass):
                 return p
 
         def halfnorm(x, loc, scale):
-            if x < 0:
+            if x < loc:
                 return -np.inf
             else:
                 return -0.5*((x-loc)**2/scale**2+np.log(0.5*np.pi*scale**2))
@@ -2488,12 +2488,11 @@ class MCMCTransientSearch(MCMCSearch):
     def logl(self, theta, search):
         for j, theta_i in enumerate(self.theta_idxs):
             self.fixed_theta[theta_i] = theta[j]
-        if self.fixed_theta[1] < 86400:
+        in_theta = copy.copy(self.fixed_theta)
+        in_theta[1] = in_theta[0] + in_theta[1]
+        if in_theta[1] > self.maxStartTime:
             return -np.inf
-        self.fixed_theta[1] += self.fixed_theta[0]
-        if self.fixed_theta[1] > self.maxStartTime:
-            return -np.inf
-        FS = search.run_computefstatistic_single_point(*self.fixed_theta)
+        FS = search.run_computefstatistic_single_point(*in_theta)
         return FS
 
     def unpack_input_theta(self):
-- 
GitLab