LSSTDESC/healsparse

Can't get a boolean map from a healsparse polygon

Closed this issue · 2 comments

I am trying to make a boolean map from a healsparse polygon. I believe that this should be possible directly, but am running into an unexpected value error. I can get around this for now by just casting the map from an int to a bool, but it may be useful to have the behavior updated. The fix probably needs to happen somewhere in how the sentinel is checked.

(Pdb) hsp_polygon.get_map(nside_coverage=mdet_mask.nside_coverage, nside_sparse=mdet_mask.nside_sparse, dtype=int)
HealSparseMap: nside_coverage = 32, nside_sparse = 131072, int64, 2406757 valid pixels
(Pdb) hsp_polygon.get_map(nside_coverage=mdet_mask.nside_coverage, nside_sparse=mdet_mask.nside_sparse, dtype=bool)
*** ValueError: Sentinel not a boolean
(Pdb) hsp_polygon.get_map(nside_coverage=mdet_mask.nside_coverage, nside_sparse=mdet_mask.nside_sparse, dtype=int).astype(bool)
HealSparseMap: nside_coverage = 32, nside_sparse = 131072, bool, 2406757 valid pixels

This was a bug that was fixed in the most recent release of healsparse (1.10.0). Which version are you using?

In any event, I would not recommend using get_map() with a polygon if you can avoid it, since the efficiency is low. To put a polygon into a map you can use (e.g.) boolean_map |= polygon which will be much faster.

Ah, that's my bad, I'm on an older release. And thanks for the note about efficiency -- I was noticing that this was much slower than some other code I had that used indices into the boolean map and wondering about that