Change request #1515

Invalid FITS unit string in background cube example file

Added by Deil Christoph almost 9 years ago. Updated almost 9 years ago.

Status:NewStart date:07/22/2015
Priority:NormalDue date:
Assigned To:-% Done:

0%

Category:-
Target version:-
Duration:

Description

While working on the generation of HESS cube background models, Manuel Paz Arribas came across this issue:

>>> from astropy.table import Table
>>> table = Table.read('https://github.com/gammalib/gammalib/raw/devel/inst/cta/test/data/bg_test.fits')
Downloading https://github.com/gammalib/gammalib/raw/devel/inst/cta/test/data/bg_test.fits
|=========================================================================================================|  37k/ 37k (100.00%)         0s
WARNING: UnitsWarning: '1/s/TeV/sr' did not parse as fits unit: Syntax error parsing unit '1/s/TeV/sr' [astropy.units.core]

From the FITS standard it’s not 100% clear if this unit string is invalid, but it’s at least discouraged:
https://github.com/astropy/astropy/issues/3986

I briefly looked through the Gammalib code and couldn’t find the place where FITS units are parsed or written for background cubes. Maybe fixed units are assumed?
So I’m not sure if this is actually an issue to be addressed by Gammalib code changes, or just by updating the FITS example file, or if you don’t care about this at all, I just thought I’d mention it here.

Michael Mayer will fix the FITS unit string written in the PA HESS exporters and then we’ll remove this temp workaround:
https://github.com/gammapy/gammapy/blob/4bc684d4c9dd33151849511d2b35d3e65f356d05/gammapy/background/models.py#L108


Recurrence

No recurrence.

History

#1 Updated by Deil Christoph almost 9 years ago

I checked ... Gammalib currently doesn’t use the unit specified in the FITS header at all:
http://nbviewer.ipython.org/github/gammapy/gammapy-extra/blob/master/checks/gammalib-background-cube-units-check.ipynb

Jürgen, is unit handling / conversion something you want to support at the FITS I/O level for such files as background cubes?

#2 Updated by Deil Christoph almost 9 years ago

Just to follow up on this: the current unit 1/s/TeV/sr is valid under the OGIP unit standard.
But not under the FITS unit standard.
See https://github.com/astropy/astropy/issues/3986#issuecomment-123820456

So I guess we have one more thing that needs to be discussed / decided / specified for CTA?

#3 Updated by Knödlseder Jürgen almost 9 years ago

I must admit that I was not aware that there exists a standard for this (I looked once for that but could not find any; I should have looked better). Anyways, I fully agree to use a FITS standard for this.

You are right that GammaLib does so far not analyze the units, basically because I did not know about the standards.

So we should make sure that actual software that writes FITS files (in your case probably the FITS exporters) write the correct units. At some point we should also interpret these units then in GammaLib.

Also available in: Atom PDF