Bug #1761

GModelSpatialDiffuseCube maps() and pixels() methods return 0

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

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

100%

Category:-
Target version:1.7.0
Duration:

Description

When constructing a GModelSpatialDiffuseCube object from a map cube file, the maps() and pixels() methods return 0 since the cube is only physically loaded on demand when the pixel values are accessed.

The map cube metadata such as number of pixels and number of maps should be loaded even if the cube itself is not loaded.


Recurrence

No recurrence.

History

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

  • Target version set to 1.2.0

#2 Updated by Knödlseder Jürgen over 7 years ago

  • Target version changed from 1.2.0 to 1.3.0

#3 Updated by Knödlseder Jürgen over 7 years ago

  • Target version changed from 1.3.0 to 1.4.0

#4 Updated by Knödlseder Jürgen over 7 years ago

  • Target version deleted (1.4.0)

#5 Updated by Knödlseder Jürgen over 4 years ago

  • Assigned To set to Knödlseder Jürgen
  • Target version set to 1.7.0

#6 Updated by Knödlseder Jürgen over 4 years ago

  • Status changed from New to In Progress
  • % Done changed from 0 to 10

The following test script

#!/usr/bin/env python
import gammalib

# Save map
map = gammalib.GSkyMap('CAR','GAL',0.0,0.0,1.0,1.0,360,180)
map.save('map.fits', True)

# Create diffuse map
diffuse_map = gammalib.GModelSpatialDiffuseMap('map.fits')
print('=== Diffuse map ===')
print(diffuse_map.value())

# Create diffuse cube
diffuse_cube = gammalib.GModelSpatialDiffuseCube('map.fits')
print('=== Diffuse cube ===')
print(diffuse_cube.value())
print(diffuse_cube.maps())
print(diffuse_cube.pixels())
gives the following output
=== Diffuse map ===
1.0
=== Diffuse cube ===
1.0
0
0

#7 Updated by Knödlseder Jürgen over 4 years ago

  • Status changed from In Progress to Pull request
  • % Done changed from 10 to 100

I decided to remove the GModelSpatialDiffuseCube::maps() and GModelSpatialDiffuseCube::pixels() methods since the same information can be accessed through the GModelSpatialDiffuseCube::cube().nmaps() and GModelSpatialDiffuseCube::cube().npix() methods.

I added a fetch_cube() call in the GModelSpatialDiffuseCube::cube() method so that the cube actually gets fetched before any access. This fixes also the GModelSpatialDiffuseCube::cube() method.

Two ctools unit tests needed to be adapted since they were using the GModelSpatialDiffuseCube::maps() and GModelSpatialDiffuseCube::pixels() methods.

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

  • Status changed from Pull request to Closed

Merged into devel.

Also available in: Atom PDF