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
UnitConversionError in calculate_predicted_counts #869
Comments
I get this, not sure if it's relevant or if the number at the end makes sense:
It should be possible to debug or reproduce this by printing what I don't think so, but it might be that there's some configuration in |
Consider the following code
The issue could be cause be rounding differences in the
|
I just now came across this oddity trying to help @vorugantia with an example: >>> from gammapy.catalog import SourceCatalog3FGL
>>> cat = SourceCatalog3FGL()
>>> source = cat['3FGL J2021.1+3651']
>>> print(source.spectral_model)
ExponentialCutoffPowerLaw3FGL
ParameterList
Parameter(name='index', value=1.6358338594436646, unit=Unit(dimensionless), min=0, max=None, frozen=False)
Parameter(name='amplitude', value=1.2799539206298505e-10, unit=Unit("1 / (cm2 MeV s)"), min=0, max=None, frozen=False)
Parameter(name='reference', value=838.4884033203125, unit=Unit("MeV"), min=None, max=None, frozen=0)
Parameter(name='ecut', value=3042.514404296875, unit=Unit("MeV"), min=None, max=None, frozen=False)
Covariance: None
>>> import astropy.units as u
>>> source.spectral_model(1 * u.TeV)
<Quantity 1.8504322368224425e-148 MeV(5/8) / (cm2 s TeV(13/8))>
>>> source.spectral_model(1 * u.TeV).to('cm-2 s-1 TeV-1')
<Quantity 2.833153003692258e-152 1 / (cm2 s TeV)> @joleroi @adonath - I think we have to discuss (offline) what to do about |
Postponing to |
The |
This is a very complicated unit that we return from Gammapy:
If possible, I think we should return simpler units here. |
The following line in
gammapy.spectrum.utils.calculate_predicted_counts
is really strangeObviously, the unit of an astropy quantity should not matter. However, if you change the line to
the test
fails with
This looks like a bug in astropy (the unit should be convertible), but I cannot reproduce it with only astropy code.
The text was updated successfully, but these errors were encountered: