From 6f7a769e60cbdde12be55e3fb0e9cde93535aec9 Mon Sep 17 00:00:00 2001
From: Cristian C Lalescu <Cristian.Lalescu@ds.mpg.de>
Date: Thu, 23 Nov 2017 15:12:43 +0100
Subject: [PATCH] update mode counter

---
 meta/count_nmodes.py | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/meta/count_nmodes.py b/meta/count_nmodes.py
index daf9d0fc..19af4ab3 100644
--- a/meta/count_nmodes.py
+++ b/meta/count_nmodes.py
@@ -1,25 +1,32 @@
 import numpy as np
 
 def count_expensive(fk0, fk1):
-    kcomponent = np.arange(-fk1-1, fk1+2, 1).astype(np.float)
+    kcomponent = np.arange(-np.floor(fk1)-1, np.floor(fk1)+2, 1).astype(np.float)
     ksize = (kcomponent[:, None, None]**2 +
              kcomponent[None, :, None]**2 +
              kcomponent[None, None, :]**2)**.5
+    #print(ksize[0])
 
     good_indices = np.where(np.logical_and(
         ksize >= fk0,
         ksize <= fk1))
     #print(ksize[good_indices])
     #print(good_indices[0].shape)
-    return good_indices[0].shape[0]
+    return np.unique(ksize[good_indices].flatten(), return_counts = True)
 
 def main():
-    for ff in [[2, 4],
-               [1.5, 3],
-               [1, 2],
-               [1.5, 2.5],
-               [1.5, 2.3]]:
-        print(1 / ff[1], ff, count_expensive(ff[0], ff[1]))
+    for ff in [[1, 2],
+               [1.4, 2.3],
+               [1.4, 2.2]]:
+        modes, counts = count_expensive(ff[0], ff[1])
+        nmodes = np.sum(counts)
+        print(1 / ff[1], ff, nmodes)
+        modes_str  = ''
+        counts_str = ''
+        for ii in range(counts.shape[0]):
+            modes_str += '{0:>5g}\t'.format(modes[ii])
+            counts_str += '{0:>5g}\t'.format(counts[ii])
+        print(modes_str + '\n' + counts_str + '\n')
     return None
 
 if __name__ == '__main__':
-- 
GitLab