Action #1695

Implement handling of extension number or name in GSkyMap::load() method

Added by Knödlseder Jürgen about 8 years ago. Updated about 8 years ago.

Status:ClosedStart date:02/17/2016
Priority:NormalDue date:
Assigned To:Knödlseder Jürgen% Done:


Target version:1.1.0


The GSkyMap::load() method should handle extension numbers or extension names so that the user can select from which extension a sky map should be loaded. This will allow to have for example a HEALPix and WCS map in the same file.


No recurrence.


#1 Updated by Knödlseder Jürgen about 8 years ago

  • Status changed from New to In Progress
  • Assigned To set to Knödlseder Jürgen
  • Target version set to 1.1.0
  • % Done changed from 0 to 50

While implementing a unit test I recognised that also the save() method needs to be modified.

I furthermore recognised that the save() method should use the GFilename::url() method as the filename, as a FITS error occurs otherwise when a yet non-existing extension is specified. Here the code snippet that works:

// Open or create FITS file (without extension name since the
// requested extension may not yet exist in the file)
GFits fits(filename.url(), true);

// If the FITS file contains already an extension with the same
// name then remove now this extension
if (fits.contains(extname)) {

// Append sky map to FITS file

// Save FITS file;

The same code structure should be implemented for other classes that should also be able to append extensions to existing FITS files.

#2 Updated by Knödlseder Jürgen about 8 years ago

  • % Done changed from 50 to 70
I modified also the following methods and implemented unit test to check that appending of extensions with a different name from the default name to an existing FITS file works:
  • GEbounds::save()
  • GEnergies::save()
  • GGti::save()
  • GNodeArray::save()
And for the following classes, extension names cannot be modified and are ignored:
  • GArf
  • GPha
  • GRmf

#3 Updated by Knödlseder Jürgen about 8 years ago

And here a list of all methods that should be considered:

inst/com/src/GCOMEventCube.cpp:    GFits fits(filename);
inst/com/src/GCOMResponse.cpp:    GFits fits(filename);
inst/cta/src/GCTAAeff2D.cpp:    GFits fits(filename);
inst/cta/src/GCTAAeff2D.cpp:    GFits fits(filename, true);
inst/cta/src/GCTAAeffArf.cpp:    GFits fits(filename);
inst/cta/src/GCTABackground3D.cpp:    GFits fits(filename);
inst/cta/src/GCTABackground3D.cpp:    GFits fits(filename, true);
inst/cta/src/GCTACubeBackground.cpp:    GFits fits(filename);
inst/cta/src/GCTACubeExposure.cpp:    GFits fits(filename);
inst/cta/src/GCTACubePsf.cpp:    GFits fits(filename);
inst/cta/src/GCTAEdisp2D.cpp:    GFits fits(filename);
inst/cta/src/GCTAEdisp2D.cpp:    GFits fits(filename, true);
inst/cta/src/GCTAEventCube.cpp:    GFits fits(filename);
inst/cta/src/GCTAEventList.cpp:    GFits fits(filename);
inst/cta/src/GCTAEventList.cpp:    GFits fits(filename, true);
inst/cta/src/GCTAObservation.cpp:    GFits fits(filename);
inst/cta/src/GCTAObservation.cpp:    GFits fits(filename.url(), true);
inst/cta/src/GCTAPointing.cpp:    GFits fits(filename);
inst/cta/src/GCTAPsf2D.cpp:    GFits fits(filename);
inst/cta/src/GCTAPsf2D.cpp:    GFits fits(filename, true);
inst/cta/src/GCTAPsfKing.cpp:    GFits fits(filename);
inst/cta/src/GCTAPsfKing.cpp:    GFits fits(filename, true);
inst/cta/src/GCTAPsfVector.cpp:    GFits fits(filename);
inst/cta/src/GCTAResponseIrf.cpp:        GFits fits(filename);
inst/cta/src/GCTAResponseIrf.cpp:        GFits fits(filename);
inst/cta/src/GCTAResponseIrf.cpp:        GFits fits(filename);
inst/lat/src/GLATAeff.cpp:    GFits fits(filename);
inst/lat/src/GLATEdisp.cpp:    GFits fits(filename);
inst/lat/src/GLATEventCube.cpp:    GFits fits(filename);
inst/lat/src/GLATEventList.cpp:    GFits fits(filename);
inst/lat/src/GLATLtCube.cpp:    GFits fits(filename);
inst/lat/src/GLATPsf.cpp:    GFits fits(filename);
inst/mwl/src/GMWLSpectrum.cpp:    GFits fits(filename);

Work to be done ...

#4 Updated by Knödlseder Jürgen about 8 years ago

The following classes do not need to be modified:
  • GMWLSpectrum
  • GCOMEventCube
  • GCOMResponse
  • GLATAeff
  • GLATEdisp
  • GLATPsf
  • GLATEventCube
  • GLATEventList
  • GLATLtCube

#5 Updated by Knödlseder Jürgen about 8 years ago

  • Status changed from In Progress to Closed
  • Remaining (hours) set to 0.0

Done and merged into devel.

Also available in: Atom PDF