StingraySoftware / stingray

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

Bugfix issue#851 #855

Open spranav1205 opened 1 month ago

spranav1205 commented 1 month ago

Relevant Issue(s)/PR(s) #851

Textbook implementation of impulse response.

Edge cases are 0.5 and phase is taken into account. The response maybe zero if the width doesn't fall on the sampling times, a warning can be issued for the same.

Eg. start = 3 width = 5 dt = 4 = [0,1,0.5] start = 4 width = 4 dt = 4 = [0,0.5,0.5] start = 1 width = 3 dt = 4 = [0,0.5]

ps. the code has redundancies which I can remove once finalized

matteobachetti commented 1 month ago

@spranav1205 thanks! A few comments: edge cases should not be plainly 0.5, but account for the exact percentage of zeros and one in a given bin. Also, I suggest implementing tests that demonstrate that the new impulse response is working correctly. I think the formulas you are using will not give the expected results!

spranav1205 commented 4 weeks ago

The version I have written (and tested :sob:) assigns one if the impulse response lies on a sampling time plainly and 0.5 at the edge. I can write one where the next node (or the previous) is assigned based on how many ones and zeros lie in the bin (essentially the area right?). Is that what we are looking for??