Feature #2990
Extract spatial subregion of GSkyMap without changing projection
Status: | Closed | Start date: | 08/22/2019 | |
---|---|---|---|---|
Priority: | Normal | Due 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.
Recurrence
No recurrence.
History
#1 Updated by Cardenzana Josh about 5 years ago
- File 2990_spatial_map_extract.png added
- Status changed from New to Pull request
- % Done changed from 0 to 90
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
.