Skip to content

Commit

Permalink
add supporting functions
Browse files Browse the repository at this point in the history
  • Loading branch information
dstndstn committed May 4, 2021
1 parent 74fb9ab commit e7b37c5
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions py/desitarget/skybricks.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,3 +111,22 @@ def lookup_tile(self, tilera, tiledec, tileradius, ras, decs):
# FIXME -- look at surrounding pixels too??
good_sky[I] = (skymap[y, x] == 0)
return good_sky

def _radec2kd(ra, dec):
"""
Creates a scipy KDTree from the given *ra*, *dec* arrays (in deg).
"""
from scipy.spatial import KDTree
xyz = _radec2xyz(ra, dec)
return KDTree(xyz)

def _radec2xyz(ra, dec):
"""
Converts arrays from *ra*, *dec* (in deg) to XYZ unit-sphere
coordinates.
"""
rr = np.deg2rad(ra)
dd = np.deg2rad(dec)
return np.vstack((np.cos(rr) * np.cos(dd),
np.sin(rr) * np.cos(dd),
np.sin(dd))).T

0 comments on commit e7b37c5

Please sign in to comment.