{"action":"opened","issue":{"url":"https://api.github.com/repos/StingraySoftware/stingray/issues/82","repository_url":"https://api.github.com/repos/StingraySoftware/stingray","labels_url":"https://api.github.com/repos/StingraySoftware/stingray/issues/82/labels{/name}","comments_url":"https://api.github.com/repos/StingraySoftware/stingray/issues/82/comments","events_url":"https://api.github.com/repos/StingraySoftware/stingray/issues/82/events","html_url":"https://github.com/StingraySoftware/stingray/issues/82","id":140973501,"number":82,"title":"Inconsistency in the results of the binning methods","user":{"login":"evandromr","id":4422731,"avatar_url":"https://avatars.githubusercontent.com/u/4422731?v=3","gravatar_id":"","url":"https://api.github.com/users/evandromr","html_url":"https://github.com/evandromr","followers_url":"https://api.github.com/users/evandromr/followers","following_url":"https://api.github.com/users/evandromr/following{/other_user}","gists_url":"https://api.github.com/users/evandromr/gists{/gist_id}","starred_url":"https://api.github.com/users/evandromr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/evandromr/subscriptions","organizations_url":"https://api.github.com/users/evandromr/orgs","repos_url":"https://api.github.com/users/evandromr/repos","events_url":"https://api.github.com/users/evandromr/events{/privacy}","received_events_url":"https://api.github.com/users/evandromr/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-03-15T13:34:17Z","updated_at":"2016-03-15T13:34:17Z","closed_at":null,"body":"As far as I could understand:\r\n - On `powerspectrum._fourier_modulus` we are excluding the zeroth frequency (when doing `freqs[freqs > 0]`)\r\n    + This means that the first element of the frequency array is supposed to be equal to the frequency resolution (`freqs[0] = df`).\r\n    + This also means that the frequency array represent the _central value_ of each frequency bin.\r\n\r\n- On a `Lightcurve` object I also expect the `time` array to represent the _central value_ of each time bin.\r\n \r\nSo far so good, my problems are:\r\n\r\n -  When we call `Lightcurve.rebin_lightcurve`, the x-array (time bins) are not what I would expect if we want the central value. For example: if my time array is \\[1,2,3,4,5,6,7,8,9,10\\] (dt = 1) and I want to bin by a factor 2 (dt = 2), to keep the same logic I would expect to end up with \\[1.5, 3.5, 5.5, 7.5, 8.5\\] (dt = 2, and bins centered in the mean of the combined bins), instead we get \\[2,4,6,8,10\\]. Which I believe is connected to the expect behavior that I mention in the next bullet points.\r\n\r\n - When calling `Powerspectrum.rebin` we do (lines 283 and 284):\r\n\r\n            bin_ps.freq = np.hstack([binfreq[0] - self.df, binfsreq])\r\n            bin_ps.ps = np.hstack([self.ps[0], binps])\r\n\r\n Since we already excluded the zeroth frequency there's no need to stack the binned arrays that comes as output from `utils.rebin_data`, the resulting `binfreq` array has at the first index the new resolution `df_new` (assuming that the original frequency array starts at the original `df_old`, as expected but this is not checked). This would make [the test that I reference in this comment](https://github.com/StingraySoftware/stingray/pull/24#discussion_r55346165) pass.\r\n\r\nI may be able to make the necessary modifications but I need input in what and where to change. \r\nFor example, should we change the behavior of `Lightcurve.rebin_lightcurve`, `Powerspectrum.rebin` or `utils.rebin_data`?\r\n\r\nOr is it working as expected and I'm just confused?\r\n\r\nAlso I would suggest to either rename `Lightcurve.rebin_lightcurve`  to `Lightcurve.rebin`, or `Powerspectrum.rebin` to `Powerspectrum.rebin_powerspectrum`, thoughts?"}}