StingraySoftware / stingray

Anything can happen in the next half hour (including spectral timing made easy)!
https://stingray.science/stingray
MIT License
166 stars 137 forks source link

Error result from CrossCorrelation #817

Open yuzl00 opened 2 months ago

yuzl00 commented 2 months ago

I perform cross-correlation from one light curve like this:

corr = CrossCorrelation(lc, lc, norm='variance')

corr is much greater than 1 at time_lags = 0. The code in crosscorrelation.py (lines 200-201) may have a bug:

variance1 = np.var(lc1.counts) - np.mean(lc1.counts_err) ** 2
variance2 = np.var(lc2.counts) - np.mean(lc2.counts_err) ** 2

Should it be like this:

variance1 = np.var(lc1.counts) - np.var(lc1.counts_err) 
variance2 = np.var(lc2.counts) - np.var(lc2.counts_err)
matteobachetti commented 2 months ago

@yuzl00 thanks for the Issue, we're investigating it