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

Fix Sherpa spectrum OGIP file issue #847

Merged
merged 2 commits into from Jan 26, 2017
Merged

Conversation

@joleroi
Copy link
Contributor

@joleroi joleroi commented Jan 25, 2017

I received the following issue via slack from @registerrier

it seems it is not possible to open the ogip files produced with SpectrumExtraction directly into sherpa at the moment.
It ends up with SystemError: error return without exception set.
Any idea on why that is?

Indeed, there was not test to make sure that our OGIP files are readable with Sherpa, so I added one. However, I cannot reproduce the issue described. @registerrier can you have a look at the test and tell me if I'm doing something different from what you do?

@registerrier
Copy link
Contributor

@registerrier registerrier commented Jan 25, 2017

The issue is due to the incorrect type assigned to the quality flag.
The OGIP definition states that the quality is a 2-byte integer whereas the code uses an int64.
See:
https://heasarc.gsfc.nasa.gov/docs/heasarc/ofwg/docs/spectra/ogip_92_007/node7.html
To correct one needs to change:
quality = np.zeros(self.energy.nbins, dtype=int)
to
quality = np.zeros(self.energy.nbins, dtype='i2')
in the constructor of PHACountsSpectrum

@cdeil
Copy link
Member

@cdeil cdeil commented Jan 25, 2017

Travis-ci fail is unrelated: https://travis-ci.org/gammapy/gammapy/jobs/195239530#L1827

@joleroi - Maybe it's worth to file an issue in the Sherpa tracker, providing an example test file and asking if they can improve the error message to be more explicit, not so cryptic?

@cdeil cdeil added this to the 0.6 milestone Jan 25, 2017
@cdeil cdeil mentioned this pull request Jan 25, 2017
@joleroi
Copy link
Contributor Author

@joleroi joleroi commented Jan 26, 2017

The issue is due to the incorrect type assigned to the quality flag.
The OGIP definition states that the quality is a 2-byte integer whereas the code uses an int64.

Do you understand why the test I added did not fail? Is this related to using sherpa in Ipython vs. using it from the command line? This would be odd, no?

@registerrier
Copy link
Contributor

@registerrier registerrier commented Jan 26, 2017

It's odd indeed.
I suppose it's a version issue. My standalone version is 4.8.1 whereas the bundled one is 4.8.0.
The files also make XSpec crash in a dirty way even after the change. There might be still some issues with data types.
XSPEC12>data 1 pha_obs33747.fits
libc++abi.dylib: terminating with uncaught exception of type RedAlert
Abort

Change dtype of quality array in PHACountSpectrum to have correct type w.r.t. OGIP specifications (2 byte integer)
see:  https://heasarc.gsfc.nasa.gov/docs/heasarc/ofwg/docs/spectra/ogip_92_007/node7.html
@joleroi
Copy link
Contributor Author

@joleroi joleroi commented Jan 26, 2017

Travis-ci fail is unrelated

I am merging this, I will file a reminder issue about the data types

@joleroi joleroi merged commit fd1d971 into gammapy:master Jan 26, 2017
0 of 2 checks passed
0 of 2 checks passed
continuous-integration/appveyor/pr Waiting for AppVeyor build to complete
Details
continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
@joleroi joleroi deleted the joleroi:add_sherpa_test branch Jan 26, 2017
@cdeil cdeil changed the title Add test to make sure OGIP files are readable with sherpa Fix Sherpa spectrum OGIP file issue Jan 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants