From 9c84967a0afcee244b40b7ed7058faca7f9020ae Mon Sep 17 00:00:00 2001
From: Gregory Ashton <gregory.ashton@ligo.org>
Date: Wed, 20 Dec 2017 11:56:57 +0100
Subject: [PATCH] Adds the basic header with simple information

---
 pyfstat/grid_based_searches.py | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/pyfstat/grid_based_searches.py b/pyfstat/grid_based_searches.py
index 672ca26..6c1c464 100644
--- a/pyfstat/grid_based_searches.py
+++ b/pyfstat/grid_based_searches.py
@@ -186,10 +186,21 @@ class GridSearch(BaseSearchClass):
         if return_data:
             return data
         else:
-            logging.info('Saving data to {}'.format(self.out_file))
-            np.savetxt(self.out_file, data, delimiter=' ')
+            self.save_array_to_disk(data)
             self.data = data
 
+    def get_header(self):
+        header = ';'.join(['date:{}'.format(str(datetime.datetime.now())),
+                           'user:{}'.format(getpass.getuser()),
+                           'hostname:{}'.format(socket.gethostname())])
+        header += '\n' + ' '.join(self.keys)
+        return header
+
+    def save_array_to_disk(self, data):
+        logging.info('Saving data to {}'.format(self.out_file))
+        header = self.get_header()
+        np.savetxt(self.out_file, data, delimiter=' ', header=header)
+
     def convert_F0_to_mismatch(self, F0, F0hat, Tseg):
         DeltaF0 = F0[1] - F0[0]
         m_spacing = (np.pi*Tseg*DeltaF0)**2 / 12.
-- 
GitLab