From 8eca0a4688d50be270e9fbc753cddc1ab664490b Mon Sep 17 00:00:00 2001 From: Sauravroy34 Date: Sat, 1 Mar 2025 18:51:00 +0530 Subject: [PATCH 1/2] fix for cross coerrelation --- stingray/crosscorrelation.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stingray/crosscorrelation.py b/stingray/crosscorrelation.py index f1a74f1cc..660faa707 100644 --- a/stingray/crosscorrelation.py +++ b/stingray/crosscorrelation.py @@ -197,8 +197,8 @@ def _make_corr(self, lc1, lc2): # Note that self.corr is normalized so that the maximum is # proportional to the number of bins in the first input # light curve. Hence, the division by the lc size - variance1 = np.var(lc1.counts) - np.mean(lc1.counts_err) ** 2 - variance2 = np.var(lc2.counts) - np.mean(lc2.counts_err) ** 2 + variance1 = np.var(lc1.counts) - np.var(lc1.counts_err) + variance2 = np.var(lc2.counts) - np.var(lc2.counts_err) self.corr = self.corr / np.sqrt(variance1 * variance2) / lc1_counts.size def cal_timeshift(self, dt=1.0): From 66a1ce1acefbe3b4d12257a52e00d357682cbcf3 Mon Sep 17 00:00:00 2001 From: Sauravroy34 Date: Thu, 3 Apr 2025 09:24:20 +0530 Subject: [PATCH 2/2] added changelog --- docs/changes/893.bugfix.rst | 1 + stingray/crosscorrelation.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) create mode 100644 docs/changes/893.bugfix.rst diff --git a/docs/changes/893.bugfix.rst b/docs/changes/893.bugfix.rst new file mode 100644 index 000000000..f01e1cafc --- /dev/null +++ b/docs/changes/893.bugfix.rst @@ -0,0 +1 @@ +Fix for variance normalisation for cross correlation method diff --git a/stingray/crosscorrelation.py b/stingray/crosscorrelation.py index 660faa707..ea1dd74c2 100644 --- a/stingray/crosscorrelation.py +++ b/stingray/crosscorrelation.py @@ -197,7 +197,7 @@ def _make_corr(self, lc1, lc2): # Note that self.corr is normalized so that the maximum is # proportional to the number of bins in the first input # light curve. Hence, the division by the lc size - variance1 = np.var(lc1.counts) - np.var(lc1.counts_err) + variance1 = np.var(lc1.counts) - np.var(lc1.counts_err) variance2 = np.var(lc2.counts) - np.var(lc2.counts_err) self.corr = self.corr / np.sqrt(variance1 * variance2) / lc1_counts.size