StingraySoftware / stingray

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

countrate does not take into account for GTIs #765

Closed eleonorav89 closed 9 months ago

eleonorav89 commented 1 year ago

For the Lightcurve class, countrate does not take into account for GTIs. Instead, when using meanrate, GTIs are applied. This could be a problem for a Stingray's first time user.

I faced the problem when calculating the Poisson noise level when reading the lightcurve: lc_hard=Lightcurve.read("band2_2000_10000_201.lc", gtistring="GTI00004", fmt="hea")

noise_hard = poisson_level(norm=norm, meanrate=lc_hard.meanrate)
noise_hard_c = poisson_level(norm=norm, meanrate=lc_hard.countrate.mean())

giving the different values: noise using meanrate 557.6120016984476 noise using countrate 443.13762621796326

matteobachetti commented 9 months ago

@eleonoraveronica I'm not sure this is fixable. The second thing you do is sort-of low level, because you are just taking the countrate array and calculating the mean, without taking GTIs into account. But the countrate array is just lc.counts/lc.dt, without caring if some of the counts are outside GTIs. The first thing is the right one, because you are using the internal machinery of Lightcurve which does take GTIs into account. So, I'm closing this, but feel free to re-open to propose a different approach.