-
Notifications
You must be signed in to change notification settings - Fork 189
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
Introduce "gadf" format for RegionNDMap #3231
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3231 +/- ##
==========================================
- Coverage 93.91% 93.90% -0.01%
==========================================
Files 144 144
Lines 17450 17478 +28
==========================================
+ Hits 16388 16413 +25
- Misses 1062 1065 +3
Continue to review full report at Codecov.
|
Thanks @adonath for starting this.
Technically, we need a specific format for map serialization but it should decoupled from data level issues. I am not sure it is relevant to have
How about a simple table HDU?
Fine. As a side note, the region convention is a regular FITS convention, it is not connected to ogip, no?
OK
I think we need it. While OGIP format can support the 1D spectral analysis. It is not fully compliant with all use cases (e.g. what if I want to serialize a
+1
Indeed. And again something like
|
Thanks for the feedback @registerrier, I'll explore the use of a |
3dbb8b4
to
96a1946
Compare
@registerrier Following your suggestion I changed to use a I think together with the region HDU this is a very clean structure now. I'll start adding more tests and documentation now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @adonath . This looks good!
The proposed format is nice. I just wonder whether we should call it gadf for now.
I have left a few comments inline.
`~RegionNDMap.write()` and `~RegionNDMap.read()` methods. Currently | ||
the following formats are supported: | ||
|
||
- "gadf": a generic serialisation format with support for ND axes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we call it gadf, if it is still internal?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See my comment below...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Choosing a different name for this format is possible but introduces the problem of defining multiple formats in MapDataset.write()
. Consider the case where dataset.psf
is a RegionGeom
(assuming we want to support this) and one uses MapDataset.write(format="gadf")
. I guess we don't really want to introduce something like ,write(format={"counts": "gadf", "background": "fgst-ccube", "psf": "gp-region"})
, this would make the number of possible single fits file definitions for a MapDataset
explode...
|
||
- "gadf": a generic serialisation format with support for ND axes | ||
- "ogip" / "ogip-sherpa": an ogip-like counts spectrum with reconstructed energy axis | ||
- "ogip-arf" / "ogip-sherpa": an ogip-like effective area with true energy axis |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Technically you should also have the ogip-rmf for the Region EdispKernel
no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is true. My proposal would be that I enable the format for IRF maps such as PSFMap
and EDispKernelMap
in a follow up PR.
return "wcs" | ||
else: | ||
return "region" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be tested?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, I'll add a test...
Thanks a lot @registerrier, I have made a request here: open-gamma-ray-astro/gamma-astro-data-formats#170, if it is accepted, I think we can keep the "gadf" name, otherwise I'll choose a different one. |
b7c19e9
to
376eaeb
Compare
Following a suggestion by @registerrier in the developer call, I now changed to introducing a dedicated bin table HDU for the data as well. This allows to share a common bands HDU if multiple "spectra" are stored within the same FITS file (see e.g. serialisation of #3075) |
@registerrier In order to make progress, I'll take the risk and merge this PR as is. The PR in the gammapy astro data format repo is open and any user can go there to look at the definition. I assume it will be merged in a some version close to the proposed one. If we decide the definition of the FITS conventions is not part of GADF, I guess we have to adapt the tag in Gammapy consistently anyway. |
Description
This pull request introduces a proof of concept for a "gadf" format for
RegionNDMap
. It serialises as following:ImageHDU
with the data, but no WCS info (to be defined / documented)BinTableHDU
in the ogip like format (see https://fits.gsfc.nasa.gov/registry/region.html)The main question here is whether this is needed at all for now. The main use case I hand in mind was to be able to serialise a
RegionNDMap
with multiple axes. However this currently only applies to theEDispKernelMap
andPSFMap
, for both we can fall back to different solutions: they can be serialised as a WCS map with one spatial bin.Beside the extra axes the serialisation will also keep all the region information on the maps, which might be interesting for provenance and it provides a simple solution to serialise both
SpectrumDataset
as well asSpectrumDatasetOnOff
in single FITS file, which is probably a convenient alternative to the current ogip format.The goal here is not to define any official DL4 data format, but just provide a simple and convenient way to serialise a
RegionNDMap
of any kind. The format will not be optimised by any means, but contain all the info needed to allow for round-tripping of aRegionNDMap
, without loss of information.If we decide this is a useful addition to our serialisation functionality, the only remaining thing is to discuss the structure, that is used to store the data. Beside the
ImageHDU
, with no associated WCS, it could be anBinTableHDU
as well, similar to the IRF DL3 formats.