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

create_bins_per_decade does not include the maximum value #187

Closed
SeiyaNozaki opened this issue Jul 15, 2022 · 4 comments
Closed

create_bins_per_decade does not include the maximum value #187

SeiyaNozaki opened this issue Jul 15, 2022 · 4 comments

Comments

@SeiyaNozaki
Copy link

binning edges obtained using create_bins_per_decade does not include the maximum value

>>> import astropy.units as u
>>> from pyirf.binning import create_bins_per_decade
>>> 
>>> energy_min = 0.01 * u.TeV
>>> energy_max = 100 * u.TeV
>>> create_bins_per_decade(energy_min, energy_max)
<Quantity [1.00000000e-02, 1.58489319e-02, 2.51188643e-02, 3.98107171e-02,
           6.30957344e-02, 1.00000000e-01, 1.58489319e-01, 2.51188643e-01,
           3.98107171e-01, 6.30957344e-01, 1.00000000e+00, 1.58489319e+00,
           2.51188643e+00, 3.98107171e+00, 6.30957344e+00, 1.00000000e+01,
           1.58489319e+01, 2.51188643e+01, 3.98107171e+01, 6.30957344e+01] TeV>

I think it would be better to implement like gammapy, what do you think?
https://docs.gammapy.org/0.20.1/_modules/gammapy/maps/axes.html#MapAxis.from_energy_bounds

@maxnoe
Copy link
Member

maxnoe commented Jul 15, 2022

No, I disagree. If I have a requirement to use n bins per decade, that's not approximate or negotiable. 5 bins per decade are 5 bins per decade, not 5.1 or 4.9 depending on the min and max values.

It's simply a question of what requirement takes precedence. And in my opinion, a function called create_bins_per_decade should give precedence to exactly that.

@maxnoe
Copy link
Member

maxnoe commented Jul 15, 2022

It's also documented here:

Maximum energy, exclusive

@SeiyaNozaki
Copy link
Author

ok, I see. Thanks.
Now, this function is used to create energy binning for IRF computation in lstchain, so I thought it would be better to use the same definition in pyirf (IRF computation) and gammapy (spectral calculation).

@maxnoe
Copy link
Member

maxnoe commented Jul 15, 2022

Ah, in the special case you give above case, it might be ok to include the endpoint though, if it fits exactly!

@maxnoe maxnoe closed this as completed in 9b73191 Jul 18, 2022
maxnoe added a commit that referenced this issue Jul 18, 2022
Include endpoint in create_bins_per_decade if it matches the regular spacing, fixes #187
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

2 participants