Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-203: FootprintFilter removes NaN's #202

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions heracles/catalog/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ def __call__(self, page):


class FootprintFilter:
"""Filter a catalogue using a footprint map."""
"""Filter a catalogue using a footprint map.
This rempoves the pixels that are not in the footprint map.
Moreover, it removes the pixels which have NaN values in the
longitude and latitude columns."""

def __init__(self, footprint, lon, lat):
"""Filter using the given footprint map and position columns."""
Expand Down Expand Up @@ -91,6 +94,9 @@ def __call__(self, page):
from healpy import ang2pix

lon, lat = self._lonlat
ipix = ang2pix(self._nside, page[lon], page[lat], lonlat=True)
_lon, _lat = page[lon], page[lat]
good_entry = np.isfinite(_lon) & np.isfinite(_lat)
_lon, _lat = _lon[good_entry], _lat[good_entry]
ipix = ang2pix(self._nside, _lon, _lat, lonlat=True)
exclude = np.where(self._footprint[ipix] == 0)[0]
page.delete(exclude)