From 6d3e520049608c477e7f75f6ad8e93f7231d5f76 Mon Sep 17 00:00:00 2001
From: Gregory Ashton <gregory.ashton@ligo.org>
Date: Wed, 26 Oct 2016 17:00:59 +0200
Subject: [PATCH] Fix issues when nglitch = 1 in plot cumulative

---
 pyfstat.py | 19 ++++++++++++++-----
 1 file changed, 14 insertions(+), 5 deletions(-)

diff --git a/pyfstat.py b/pyfstat.py
index d1527cd..1673d3e 100755
--- a/pyfstat.py
+++ b/pyfstat.py
@@ -1567,12 +1567,21 @@ _        sftfilepath: str
             if key not in d:
                 d[key] = val
 
-        delta_F0s = [d['delta_F0_{}'.format(i)] for i in range(self.nglitch)]
-        delta_F0s.insert(self.theta0_idx, 0)
-        delta_F0s = np.array(delta_F0s)
-        delta_F0s[:self.theta0_idx] *= -1
+        if self.nglitch > 1:
+            delta_F0s = [d['delta_F0_{}'.format(i)] for i in
+                         range(self.nglitch)]
+            delta_F0s.insert(self.theta0_idx, 0)
+            delta_F0s = np.array(delta_F0s)
+            delta_F0s[:self.theta0_idx] *= -1
+            tglitches = [d['tglitch_{}'.format(i)] for i in
+                         range(self.nglitch)]
+        elif self.nglitch == 1:
+            delta_F0s = [d['delta_F0']]
+            delta_F0s.insert(self.theta0_idx, 0)
+            delta_F0s = np.array(delta_F0s)
+            delta_F0s[:self.theta0_idx] *= -1
+            tglitches = [d['tglitch']]
 
-        tglitches = [d['tglitch_{}'.format(i)] for i in range(self.nglitch)]
         tbounderies = [self.tstart] + tglitches + [self.tend]
 
         for j in range(self.nglitch+1):
-- 
GitLab