Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect results with rebinning #9

Closed
bghani opened this issue Jun 13, 2019 · 10 comments
Closed

Incorrect results with rebinning #9

bghani opened this issue Jun 13, 2019 · 10 comments

Comments

@bghani
Copy link

bghani commented Jun 13, 2019

Hi there,

First of all thank you for the package. I am trying to rebin but I am getting incorroct results:

So my data looks like:

x_old is [1.5 2.5 3.5 4.5 5.5 6.5]
y_old is [10 10 10 10 10]
x_new is [1.7 2.27332857 2.84665714 3.41998571 3.99331429 4.56664286
5.13997143 5.7133]
The y_new I get on using your script is:

[ 55.73328571 5.73328571 5.73328571 5.73328571 5.73328571 5.73328571 5.73328571]

There is clearly some problem with this result especially with the first bin result. Could you have some hints on what could be going wrong?

I am using the assumption of 'piecewise_constant' for bins.

Thank you so much!

Burooj

@andyfaff
Copy link
Contributor

I can confirm this. I'll have a look into it.

@jhykes
Copy link
Owner

jhykes commented Jun 14, 2019

It looks like the trigger for this is the 1.7 new lower bound which is above the old lower bound 1.5. If I adjust the new lower bound to 1.5 or lower, the results look okay.

I'm not sure when I'll have time to fix this.

Here is a script to repeat this calculation:

import numpy as np                                                    
import rebin                                                          
                                                                      
x_old = np.array([1.5, 2.5, 3.5, 4.5, 5.5, 6.5])                      
                                                                      
y_old = np.array([10., 10., 10., 10., 10.])                           
                                                                      
x_new = np.array([1.7, 2.27332857, 2.84665714, 3.41998571, 3.99331429,
                  4.56664286, 5.13997143, 5.7133 ])                   
                                                                      
y_new = rebin.rebin(x_old, y_old, x_new, 'piecewise_constant')        
                                                                      
print(y_new)                                                          

@bghani
Copy link
Author

bghani commented Jun 18, 2019

Thank you for your feedback. So you mean there is an error in the code?

@andyfaff
Copy link
Contributor

andyfaff commented Jun 18, 2019 via email

@bghani
Copy link
Author

bghani commented Jun 18, 2019

Alright, thanks a lot. Would it be possible for you to share the code for when there's no uncertainty in the meantime?

@endolith
Copy link

So is this fixed?

@bghani
Copy link
Author

bghani commented May 29, 2021

Yes, it is.

@endolith
Copy link

So why is it still Open? :)

@andyfaff
Copy link
Contributor

I think was fixed in #10

@jhykes
Copy link
Owner

jhykes commented Jun 1, 2021

Thanks guys for confirming that this is fixed! Closing the issue now...

@jhykes jhykes closed this as completed Jun 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants