From 0066bbced0562a7306bc807d5fdde233bceaffab Mon Sep 17 00:00:00 2001
From: Gregory Ashton <gregory.ashton@ligo.org>
Date: Mon, 2 Oct 2017 22:10:36 +0200
Subject: [PATCH] Write predicted Fstat file to local directory rather than tmp

- Previously, the predict_fstat directed lalapps_PredictFstat to write
  the output to /tmp/fs. This caused failure when /tmp could not be
  written to so instead it writes it to a file in the working directory
  and then removes it
---
 pyfstat/core.py | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/pyfstat/core.py b/pyfstat/core.py
index a67c3d0..5630135 100755
--- a/pyfstat/core.py
+++ b/pyfstat/core.py
@@ -153,6 +153,8 @@ def predict_fstat(h0, cosi, psi, Alpha, Delta, Freq, sftfilepattern,
         The expectation and standard deviation of 2F
 
     """
+    tempory_filename = 'fs.tmp'
+
     cl_pfs = []
     cl_pfs.append("lalapps_PredictFstat")
     cl_pfs.append("--h0={}".format(h0))
@@ -170,11 +172,12 @@ def predict_fstat(h0, cosi, psi, Alpha, Delta, Freq, sftfilepattern,
 
     cl_pfs.append("--minStartTime={}".format(int(minStartTime)))
     cl_pfs.append("--maxStartTime={}".format(int(maxStartTime)))
-    cl_pfs.append("--outputFstat=/tmp/fs")
+    cl_pfs.append("--outputFstat={}".format(tempory_filename))
 
     cl_pfs = " ".join(cl_pfs)
     helper_functions.run_commandline(cl_pfs)
-    d = read_par(filename='/tmp/fs')
+    d = read_par(filename=tempory_filename)
+    os.remove(tempory_filename)
     return float(d['twoF_expected']), float(d['twoF_sigma'])
 
 
-- 
GitLab