StingraySoftware / stingray

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

Negative correlation at zero lag from stingray.crosscorrelation #704

Open hjsreehari opened 1 year ago

hjsreehari commented 1 year ago

I have fits light curves of 1ms binning. I imported these light curves into stingray as follows and computed cross correlation.

from astropy.io import fits from stingray import Lightcurve from stingray.crosscorrelation import CrossCorrelation hdu36=fits.open('Light_1ms_3.0_6.0keV.lc') hdu620=fits.open('Light_1ms_6.0_20.0keV.lc')

lc36=Lightcurve(hdu36[1].data['TIME'],hdu36[1].data['RATE'],use_counts=False,dt=1) lc620=Lightcurve(hdu620[1].data['TIME'],hdu620[1].data['RATE'],use_counts=False,dt=1)

cc = CrossCorrelation(lc36, lc620)

But, there is a negative correlation at zero lag. I have attached the figure. Please let me know why this happens and how to correct it.

I want to generate cross correlation with light curves of 1 ms resolution instead of the 1s binning used here. There also I see the same issue of negative correlation at zero lag. How can I address this issue? Am I importing the light curves incorrectly to stingray? Please let me know.

correlation_v2

matteobachetti commented 1 year ago

Hi @hjsreehari, I don't know why this happens, it might be something related to the data themselves. Have you ever used crosscorrelation before?

hjsreehari commented 1 year ago

Hi @matteobachetti , Thanks for the reply. I tried correlation of the same light curves (MAXI J1535-571) with heasoft tool crosscorr and it still gives negative correlation at zero lag. So, it must be issue with the data. The figure is attached.

Surprisingly, I have seen such negative correlation with some simulated data as well. What might be the reason? Thank you. corr_heasoft