aboutsummaryrefslogtreecommitdiffstats
path: root/fg21sim
diff options
context:
space:
mode:
authorAaron LI <aaronly.me@outlook.com>2016-10-10 17:12:48 +0800
committerAaron LI <aaronly.me@outlook.com>2016-10-10 17:12:48 +0800
commit1e6b0669374276a58cf1b081fa6efbdffd8266c2 (patch)
tree6c7483a0e67cc2358a95143625bf6d3d2f77fc6e /fg21sim
parent5b40637b168ed98a3297be28a225438b415cd087 (diff)
downloadfg21sim-1e6b0669374276a58cf1b081fa6efbdffd8266c2.tar.bz2
utils: zea2healpix() also return the mask array
The mask array has values 0, 1, and 2, which indicate the different statuses of the reprojected HEALPix pixels. Also update the executable script to use the new return results.
Diffstat (limited to 'fg21sim')
-rw-r--r--fg21sim/utils/reproject.py18
1 files changed, 13 insertions, 5 deletions
diff --git a/fg21sim/utils/reproject.py b/fg21sim/utils/reproject.py
index 08dd1c9..f44c265 100644
--- a/fg21sim/utils/reproject.py
+++ b/fg21sim/utils/reproject.py
@@ -196,6 +196,14 @@ def zea2healpix(img1, img2, nside, order=1, inpaint=False,
Reprojected HEALPix data
hp_header : `~astropy.io.fits.Header`
FITS header for the reprojected HEALPix data
+ hp_mask : 1D `~numpy.ndarray`
+ Array of same shape as the above `hp_data` indicating the status of
+ each pixel of the output array.
+ Values of "0" indicate the missing pixels (i.e., there is no
+ transformation to the input images); values of "1" indicate the output
+ pixel maps to one and only one of the input images; values of "2"
+ indicate the duplicate/overlapping pixels that map to both of the two
+ input images.
NOTE
----
@@ -230,18 +238,18 @@ def zea2healpix(img1, img2, nside, order=1, inpaint=False,
hp_data2 = _image_to_healpix(zea_img2, zea_wcs2, nside=nside, order=order,
hemisphere=zea_hemisphere2.upper())
# Merge the two HEALPix data
- hp_footprint1 = (~np.isnan(hp_data1)).astype(np.int)
- hp_footprint2 = (~np.isnan(hp_data2)).astype(np.int)
+ hp_mask = ((~np.isnan(hp_data1)).astype(np.int) +
+ (~np.isnan(hp_data2)).astype(np.int))
hp_data1[np.isnan(hp_data1)] = 0.0
hp_data2[np.isnan(hp_data2)] = 0.0
hp_data = hp_data1 + hp_data2
logger.info("Done reprojection and merge two hemispheres")
# Duplicated pixels and missing pixels
- pix_dup = (hp_footprint1 + hp_footprint2) == 2
+ pix_dup = (hp_mask == 2)
if pix_dup.sum() > 0:
logger.warning("Reprojected HEALPix data has %d duplicated pixel(s)" %
pix_dup.sum())
- pix_missing = (hp_footprint1 + hp_footprint2) == 0
+ pix_missing = (hp_mask == 0)
if pix_missing.sum() > 0:
logger.warning("Reprojected HEALPix data has %d missing pixel(s)" %
pix_missing.sum())
@@ -258,4 +266,4 @@ def zea2healpix(img1, img2, nside, order=1, inpaint=False,
append_history=append_history,
append_comment=append_comment)
logger.info("Made HEALPix FITS header")
- return (hp_data, hp_header)
+ return (hp_data, hp_header, hp_mask)