Skip to content

Commit

Permalink
Added cone search functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
rongmon committed Feb 14, 2022
1 parent ce44476 commit 886aaeb
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions catalog/rb_search.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import numpy as np
def cone_search(ra_center,dec_center,ra_list,dec_list,angular_scale):
#--------------------------------------------------------
# Function to do a cone search around any (ra,dec) pointing with respect
# to a list of ra,dec entries.
#
# Input:- ra_center = RA of center (Degrees)
# dec_center = DEC of center (Degrees)
# ra_list = RA list of input catalogue (Degrees)
# dec_list = DEC list of input catalogue (Degrees)
# angular_scale = angular search radius in arcsec
#
#
# Output:- out:- struture containing RA,DEC and logical operator
# identifying the objects
#
# Written by R.B. Mar 11 2013
#---------------------------------------------------------

deg2rad=np.pi/180
rad2deg=180./np.pi

ra_center=deg2rad*np.array(ra_center)
dec_center=deg2rad*np.array(dec_center)
ra_list=deg2rad*np.array(ra_list)
dec_list=deg2rad*np.array(dec_list)

theta =np.arccos(np.sin(dec_center)*np.sin(dec_list) + np.cos(dec_center)*np.cos(dec_list)*np.cos(ra_center-ra_list))

sq= np.where(theta*rad2deg*3600<=angular_scale)

if sq[0].size>0:
outstr={'ra':ra_list[sq],'dec':dec_list[sq],'index':sq,'angle':theta[sq]*rad2deg*3600}
else:
outstr={'ra':-99,'dec':-99,'index':sq,'angle':-99}
return outstr

0 comments on commit 886aaeb

Please sign in to comment.