From bdb6d33d831b01d2f120a571855ab1de6b4405c9 Mon Sep 17 00:00:00 2001
From: mancini <mancini@astron.nl>
Date: Mon, 11 Oct 2021 16:47:33 +0200
Subject: [PATCH] Fix inspect plot

---
 steps/inspect_flagging_dataloss.cwl | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/steps/inspect_flagging_dataloss.cwl b/steps/inspect_flagging_dataloss.cwl
index 4214dd5..d0eae14 100644
--- a/steps/inspect_flagging_dataloss.cwl
+++ b/steps/inspect_flagging_dataloss.cwl
@@ -68,10 +68,17 @@ requirements:
          n_baselines = int((n_antennas + 1) * n_antennas * .5)
          n_times = flags.shape[0] // n_baselines
          dataloss = np.array(vis == 0, dtype=np.int)
-
-         dataloss_matrix, (urange, vrange, wrange) = np.histogramdd(uvw, bins=[sampling, sampling, 1], weights=np.nanmean(dataloss, axis=(1,2)))
-         flag_matrix, (urange, vrange, wrange) = np.histogramdd(uvw, bins=[sampling, sampling, 1], weights=np.nanmean(flags, axis=(1,2)))
-         coverage, (urange, vrange, wrange) = np.histogramdd(uvw, bins=[sampling, sampling, 1])
+         urange = np.linspace(-np.max(uvw[:, 0]), np.max(uvw[:, 0]), sampling, endpoint=True)
+         vrange = np.linspace(-np.max(uvw[:, 1]), np.max(uvw[:, 1]), sampling, endpoint=True)
+         
+         dataloss_matrix, (urange, vrange, wrange) = np.histogramdd(uvw, bins=[urange, vrange, 1], weights=np.nanmean(dataloss, axis=(1,2)))
+         dataloss_matrix += np.histogramdd(-uvw, bins=[urange, vrange, 1], weights=np.nanmean(dataloss, axis=(1,2)))[0]
+         
+         flag_matrix, (urange, vrange, wrange) = np.histogramdd(uvw, bins=[urange, vrange, 1], weights=np.nanmean(flags, axis=(1,2)))
+         flag_matrix += np.histogramdd(-uvw, bins=[urange, vrange, 1], weights=np.nanmean(flags, axis=(1,2)))[0]
+         
+         coverage, (urange, vrange, wrange) = np.histogramdd(uvw, bins=[urange, vrange, 1])
+         coverage += np.histogramdd(-uvw, bins=[urange, vrange, 1])[0]
 
          flags = flags.reshape(n_times, n_baselines, *flags.shape[1:], order='C')
          dataloss = dataloss.reshape(n_times, n_baselines, *flags.shape[2:], order='C')
-- 
GitLab