From 0c41b602eaed93734eed054a0aef87d129e85065 Mon Sep 17 00:00:00 2001
From: David Keitel <david.keitel@ligo.org>
Date: Wed, 13 Dec 2017 15:27:19 +0000
Subject: [PATCH] gridsearch: add maxL t0,tau to main results file if
 transientWindowType

---
 pyfstat/grid_based_searches.py | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/pyfstat/grid_based_searches.py b/pyfstat/grid_based_searches.py
index 4617936..da2ad8f 100644
--- a/pyfstat/grid_based_searches.py
+++ b/pyfstat/grid_based_searches.py
@@ -164,12 +164,18 @@ class GridSearch(BaseSearchClass):
             detstat = self.search.get_det_stat(*vals)
             windowRange = getattr(self.search, 'windowRange', None)
             FstatMap = getattr(self.search, 'FstatMap', None)
-            data.append(list(vals) + [detstat])
-            if self.outputTransientFstatMap and self.transientWindowType:
-                tCWfile = os.path.splitext(self.out_file)[0]+'_tCW_%.16f_%.16f_%.16f_%.16g_%.16g.dat' % (vals[2],vals[5],vals[6],vals[3],vals[4]) # freq alpha delta f1dot f2dot
-                fo = lal.FileOpen(tCWfile, 'w')
-                lalpulsar.write_transientFstatMap_to_fp ( fo, FstatMap, windowRange, None )
-                del fo # instead of lal.FileClose() which is not SWIG-exported
+            thisCand = list(vals) + [detstat]
+            if self.transientWindowType:
+                if self.outputTransientFstatMap:
+                    tCWfile = os.path.splitext(self.out_file)[0]+'_tCW_%.16f_%.16f_%.16f_%.16g_%.16g.dat' % (vals[2],vals[5],vals[6],vals[3],vals[4]) # freq alpha delta f1dot f2dot
+                    fo = lal.FileOpen(tCWfile, 'w')
+                    lalpulsar.write_transientFstatMap_to_fp ( fo, FstatMap, windowRange, None )
+                    del fo # instead of lal.FileClose() which is not SWIG-exported
+                Fmn = FstatMap.F_mn.data
+                maxidx = np.unravel_index(Fmn.argmax(), Fmn.shape)
+                thisCand += [windowRange.t0+maxidx[0]*windowRange.dt0,
+                             windowRange.tau+maxidx[1]*windowRange.dtau]
+            data.append(thisCand)
 
         data = np.array(data, dtype=np.float)
         if return_data:
-- 
GitLab