From b43d4bff1519a990ba4a4146f10fe68f10664ec2 Mon Sep 17 00:00:00 2001
From: Anna Bergamaschi <anna.bergamaschi@psi.ch>
Date: Fri, 26 Apr 2024 17:51:20 +0200
Subject: [PATCH] Fixed rotation of the noise map and of the image plot in colz
 function

---
 examples/clustersFunctions.py | 2 +-
 src/cluster_reader.c          | 5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/examples/clustersFunctions.py b/examples/clustersFunctions.py
index a9c3075..10de506 100644
--- a/examples/clustersFunctions.py
+++ b/examples/clustersFunctions.py
@@ -142,7 +142,7 @@ def plot_colz(hist2d, vmax=-1, vmin=0):
     if vmin>vmax:
         vmin=0
     fig1, axs1 = plt.subplots()
-    vv=axs1.imshow(hist2d,origin='upper',cmap=plt.cm.gray,vmax=vmax,vmin=vmin, interpolation='none' )
+    vv=axs1.imshow(np.transpose(hist2d),origin='upper',cmap=plt.cm.gray,vmax=vmax,vmin=vmin, interpolation='none' )
     fig1.colorbar(vv, ax=axs1)
     fig1.show()
 
diff --git a/src/cluster_reader.c b/src/cluster_reader.c
index e944530..2a51e73 100644
--- a/src/cluster_reader.c
+++ b/src/cluster_reader.c
@@ -125,8 +125,9 @@ size_t read_clusters_with_cut(FILE *fp, size_t n_clusters, Cluster *buf,
                             tot1 = ptr->data[4];
                             analyze_cluster(*ptr, &t2max, &tot3, NULL, NULL,
                                             NULL, NULL, NULL);
-                            noise = noise_map[ptr->y * nx + ptr->x];
-                            if (tot1 > noise && t2max > 2 * noise &&
+                            //noise = noise_map[ptr->y * nx + ptr->x];
+                            noise = noise_map[ptr->y + ny * ptr->x];
+			    if (tot1 > noise && t2max > 2 * noise &&
                                 tot3 > 3 * noise) {
                                 ;
                             } else