Feature #2990

Extract spatial subregion of GSkyMap without changing projection

Added by Cardenzana Josh over 5 years ago. Updated about 5 years ago.

Status:ClosedStart date:08/22/2019
Priority:NormalDue date:
Assigned To:Cardenzana Josh% Done:

100%

Category:-
Target version:1.7.0
Duration:

Description

My idea is to implement a method similar to the existing 'GSkyMap::extract()' method. The existing method returns a new GSkyMap with the same projection but contains only a subset of the maps. The proposed methods would instead keep the existing number of maps and extract a subset of the spatial pixels while keeping the projection the same. This has two benefits:

  • It allows generating maps that have the projection reference point at a position other than the map center.
  • For models that use GSkyMaps, it allows extracting only the subregion of the map that overlaps the data being analyzed, saving memory.

Since the projection would be identical to the original map, there does not need to be any interpolating or creative sampling of the pixel values for the new map.

2990_spatial_map_extract.png (196 KB) Cardenzana Josh, 08/30/2019 04:25 PM

2990_spatial_map_extract

Recurrence

No recurrence.

History

#1 Updated by Cardenzana Josh over 5 years ago

I’ve added two methods to GSkyMap and associated tests to test_GSky:

# Extract a map with pixels in range [startx,stopx] and [starty,stopy] (inclusive)
GSkyMap extract(const int& startx, const int& stopx, const int& starty, const int& stopy) const

# Extract a map where the x,y pixel range is determined by those pixels that overlap
# with a given set of GSkyRegions
GSkyMap extract(const GSkyRegions& inclusions) const;

Note that the extracted GSkyMap contains the exact same number of maps (i.e. the z-axis is untouched). Additionally, the projection is exactly the same, so the values in each bin are also the exact same.

For example, creating an AIT projection with the center at [glon=0,glat=0] and then reducing the ypixels to only the upper half using the following code:

import gammalib
aitmap = gammalib.GSkyMap('AIT', 'GAL', 0, 0, 1, 1, 360, 180)
for i in range(360*180):
   aitmap[i] = i
aitmap2 = aitmap.extract(0, 360, 90, 180)

generates the following images for 'aitmap’ (left) and 'aitmap2’ (right)

Pull Request:
Repo: Josh Cardenzana/gammalib, https://cta-gitlab.irap.omp.eu/jcardenzana/gammalib.git
Branch: 2990_gskymap_extract_spatial

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

  • Status changed from Pull request to Closed
  • % Done changed from 90 to 100

Merged into devel.

Also available in: Atom PDF